Skip to content

Commit

Permalink
Merge pull request #2 from vinted/feature/add_scrape_time_metric
Browse files Browse the repository at this point in the history
Add exporter scrape time metric
  • Loading branch information
Seitanas authored Dec 12, 2019
2 parents 5186c17 + 0651100 commit cec95cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"reflect"
"regexp"
"strings"
"time"
)

var schema = make(map[string]string)
Expand Down Expand Up @@ -70,6 +71,7 @@ func GetDeviceType(socketName string) map[string]string {

func (collector *cephCollector) Collect(ch chan<- prometheus.Metric) {

scrapeTime := time.Now()
var osdSchema map[string]interface{}
var cephMetrics map[string]interface{}
var cephDevice map[string]string
Expand Down Expand Up @@ -106,6 +108,8 @@ func (collector *cephCollector) Collect(ch chan<- prometheus.Metric) {
}
}
}
description := prometheus.NewDesc("ceph_exporter_scrape_time", "Duration of a collector scrape", nil, nil)
ch <- prometheus.MustNewConstMetric(description, prometheus.GaugeValue, time.Since(scrapeTime).Seconds())
log.Debug("Finished")
}

Expand All @@ -118,7 +122,7 @@ func CephNormalizeMetricName(metric string) string {
}

func CephPrometheusDesc(metricName string, description string) *prometheus.Desc{
return prometheus.NewDesc(metricName, description, []string{"device"}, nil,)
return prometheus.NewDesc(metricName, description, []string{"device"}, nil,)
}

// Get schema for defined socket. Either query ceph or use stored map if exists.
Expand Down

0 comments on commit cec95cb

Please sign in to comment.