diff --git a/plugin/metrics/vars/report.go b/plugin/metrics/vars/report.go index 5d8f2ba64..568a291e3 100644 --- a/plugin/metrics/vars/report.go +++ b/plugin/metrics/vars/report.go @@ -20,7 +20,7 @@ func Report(req request.Request, zone, rcode string, size int, start time.Time) typ := req.QType() RequestCount.WithLabelValues(zone, net, fam).Inc() - RequestDuration.WithLabelValues(zone).Observe(float64(time.Since(start) / time.Millisecond)) + RequestDuration.WithLabelValues(zone).Observe(time.Since(start).Seconds()) if req.Do() { RequestDo.WithLabelValues(zone).Inc() diff --git a/plugin/metrics/vars/vars.go b/plugin/metrics/vars/vars.go index 826f9ebed..e5a0d7c43 100644 --- a/plugin/metrics/vars/vars.go +++ b/plugin/metrics/vars/vars.go @@ -18,9 +18,9 @@ var ( RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: plugin.Namespace, Subsystem: subsystem, - Name: "request_duration_milliseconds", - Buckets: append(prometheus.DefBuckets, []float64{50, 100, 200, 500, 1000, 2000, 3000, 4000, 5000, 10000}...), - Help: "Histogram of the time (in milliseconds) each request took.", + Name: "request_duration_seconds", + Buckets: plugin.TimeBuckets, + Help: "Histogram of the time (in seconds) each request took.", }, []string{"zone"}) RequestSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{ diff --git a/plugin/plugin.go b/plugin/plugin.go index d6b7c9976..3f2d01f9e 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -100,3 +100,6 @@ func ClientWrite(rcode int) bool { // Namespace is the namespace used for the metrics. const Namespace = "coredns" + +// TimeBuckets is based on Prometheus client_golang prometheus.DefBuckets +var TimeBuckets = []float64{0.00025, 0.0005, 0.001, 0.0025, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10} diff --git a/plugin/proxy/metrics.go b/plugin/proxy/metrics.go index d6dc0ea30..96be50893 100644 --- a/plugin/proxy/metrics.go +++ b/plugin/proxy/metrics.go @@ -19,9 +19,9 @@ var ( RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: plugin.Namespace, Subsystem: "proxy", - Name: "request_duration_milliseconds", - Buckets: append(prometheus.DefBuckets, []float64{15, 20, 25, 30, 40, 50, 100, 200, 500, 1000, 2000, 3000, 4000, 5000, 10000}...), - Help: "Histogram of the time (in milliseconds) each request took.", + Name: "request_duration_seconds", + Buckets: plugin.TimeBuckets, + Help: "Histogram of the time (in seconds) each request took.", }, []string{"proto", "proxy_proto", "family", "to"}) )