diff --git a/middleware/proxy/README.md b/middleware/proxy/README.md index 20fbef720..56469cb74 100644 --- a/middleware/proxy/README.md +++ b/middleware/proxy/README.md @@ -87,10 +87,10 @@ example.org. 1799 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016110711 7200 If monitoring is enabled (via the *prometheus* directive) then the following metric is exported: -* coredns_proxy_request_count_total{proto, from} +* coredns_proxy_request_count_total{proto, proxy_proto, from} -Where `proto` is the protocol used (`dns`, or `https_google`) and `from` is **FROM** specified in -the config. +Where `proxy_proto` is the protocol used (`dns`, or `https_google`) and `from` is **FROM** specified in +the config, `proto` is the protocol used by the incoming query ("tcp" or "udp"). ## Examples diff --git a/middleware/proxy/metrics.go b/middleware/proxy/metrics.go index 485b594c7..1b238148b 100644 --- a/middleware/proxy/metrics.go +++ b/middleware/proxy/metrics.go @@ -16,7 +16,7 @@ var ( 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.", - }, []string{"proto", "from"}) + }, []string{"proto", "proxy_proto", "from"}) ) // OnStartupMetrics sets up the metrics on startup. This is done for all proxy protocols. diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index b8b50adc6..1a595d99e 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -93,7 +93,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( host := upstream.Select() if host == nil { - RequestDuration.WithLabelValues(upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) + RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) return dns.RcodeServerFailure, errUnreachable } @@ -116,7 +116,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( if backendErr == nil { w.WriteMsg(reply) - RequestDuration.WithLabelValues(upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) + RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) return 0, nil } @@ -131,7 +131,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ( }(host, timeout) } - RequestDuration.WithLabelValues(upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) + RequestDuration.WithLabelValues(state.Proto(), upstream.Exchanger().Protocol(), upstream.From()).Observe(float64(time.Since(start) / time.Millisecond)) return dns.RcodeServerFailure, errUnreachable }