2016-10-28 12:54:49 +01:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"sync"
|
|
|
|
|
|
2017-02-21 22:51:47 -08:00
|
|
|
"github.com/coredns/coredns/middleware"
|
2016-10-28 12:54:49 +01:00
|
|
|
|
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Metrics the proxy middleware exports.
|
|
|
|
|
var (
|
|
|
|
|
RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
|
|
|
|
Namespace: middleware.Namespace,
|
2017-01-15 08:12:58 +00:00
|
|
|
Subsystem: "proxy",
|
2016-10-28 12:54:49 +01:00
|
|
|
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.",
|
2017-02-07 21:28:47 +00:00
|
|
|
}, []string{"proto", "proxy_proto", "from"})
|
2016-10-28 12:54:49 +01:00
|
|
|
)
|
|
|
|
|
|
2017-02-06 19:32:48 +00:00
|
|
|
// OnStartupMetrics sets up the metrics on startup. This is done for all proxy protocols.
|
|
|
|
|
func OnStartupMetrics() error {
|
2016-10-28 12:54:49 +01:00
|
|
|
metricsOnce.Do(func() {
|
|
|
|
|
prometheus.MustRegister(RequestDuration)
|
|
|
|
|
})
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var metricsOnce sync.Once
|