middleware/proxy: sane(r) metrics

Add proxy_proto and re-instate proto to be the protocol of the incoming
query ("tcp" or "udp").
This commit is contained in:
Miek Gieben 2017-02-07 21:28:47 +00:00
parent dbe1b2510d
commit fa0abe7473
3 changed files with 7 additions and 7 deletions

View file

@ -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

View file

@ -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.

View file

@ -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
}