diff options
author | 2017-10-08 04:30:44 -0700 | |
---|---|---|
committer | 2017-10-08 04:30:44 -0700 | |
commit | 7c6ba3fcbd78d8698b62925451b39cb103cbadbc (patch) | |
tree | b27370ba8bb9ac9f57d0b7823bba6f7f1d19f762 /plugin/proxy/metrics.go | |
parent | c1b9f74f98d2c3b65b026e8de06da7b1c4f41c7e (diff) | |
download | coredns-7c6ba3fcbd78d8698b62925451b39cb103cbadbc.tar.gz coredns-7c6ba3fcbd78d8698b62925451b39cb103cbadbc.tar.zst coredns-7c6ba3fcbd78d8698b62925451b39cb103cbadbc.zip |
plugin/proxy: fix metrics (#1137)
Add Counter metrics and fix duration to use upstream name (and only use
it when we have one).
Fix the documentation to reflect this.
Fixes #1134
Diffstat (limited to 'plugin/proxy/metrics.go')
-rw-r--r-- | plugin/proxy/metrics.go | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/plugin/proxy/metrics.go b/plugin/proxy/metrics.go index 893c26d6b..d6dc0ea30 100644 --- a/plugin/proxy/metrics.go +++ b/plugin/proxy/metrics.go @@ -10,21 +10,40 @@ import ( // Metrics the proxy plugin exports. var ( + RequestCount = prometheus.NewCounterVec(prometheus.CounterOpts{ + Namespace: plugin.Namespace, + Subsystem: "proxy", + Name: "request_count_total", + Help: "Counter of requests made per protocol, proxy protocol, family and upstream.", + }, []string{"proto", "proxy_proto", "family", "to"}) RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: plugin.Namespace, Subsystem: "proxy", Name: "request_duration_milliseconds", - Buckets: append(prometheus.DefBuckets, []float64{50, 100, 200, 500, 1000, 2000, 3000, 4000, 5000, 10000}...), + 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.", - }, []string{"proto", "proxy_proto", "from"}) + }, []string{"proto", "proxy_proto", "family", "to"}) ) // OnStartupMetrics sets up the metrics on startup. This is done for all proxy protocols. func OnStartupMetrics() error { metricsOnce.Do(func() { + prometheus.MustRegister(RequestCount) prometheus.MustRegister(RequestDuration) }) return nil } +// familyToString returns the string form of either 1, or 2. Returns +// empty string is not a known family +func familyToString(f int) string { + if f == 1 { + return "1" + } + if f == 2 { + return "2" + } + return "" +} + var metricsOnce sync.Once |