From b1173ed2a583cc6102b46b02b4675828f87ebfd8 Mon Sep 17 00:00:00 2001 From: Maxime Ginters Date: Thu, 28 Jan 2021 10:37:17 -0500 Subject: plugin/forward Add rcode and rtype to request_duration_seconds metric (#4391) * plugin/forward Add rcode and rtype to request_duration_seconds metric Signed-off-by: Maxime Ginters * Control the cardinality of query type Signed-off-by: Maxime Ginters --- plugin/metrics/vars/report.go | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 'plugin/metrics') diff --git a/plugin/metrics/vars/report.go b/plugin/metrics/vars/report.go index 96b29d9fb..9bad43582 100644 --- a/plugin/metrics/vars/report.go +++ b/plugin/metrics/vars/report.go @@ -3,9 +3,8 @@ package vars import ( "time" + "github.com/coredns/coredns/plugin/pkg/dnsutil" "github.com/coredns/coredns/request" - - "github.com/miekg/dns" ) // Report reports the metrics data associated with request. This function is exported because it is also @@ -19,45 +18,17 @@ func Report(server string, req request.Request, zone, rcode string, size int, st fam = "2" } - typ := req.QType() + qtype := dnsutil.QTypeMonitorLabel(req.QType()) if req.Do() { RequestDo.WithLabelValues(server, zone).Inc() } - if _, known := monitorType[typ]; known { - RequestCount.WithLabelValues(server, zone, net, fam, dns.Type(typ).String()).Inc() - RequestDuration.WithLabelValues(server, zone, dns.Type(typ).String()).Observe(time.Since(start).Seconds()) - } else { - RequestCount.WithLabelValues(server, zone, net, fam, other).Inc() - RequestDuration.WithLabelValues(server, zone, other).Observe(time.Since(start).Seconds()) - } + RequestCount.WithLabelValues(server, zone, net, fam, qtype).Inc() + RequestDuration.WithLabelValues(server, zone, qtype).Observe(time.Since(start).Seconds()) ResponseSize.WithLabelValues(server, zone, net).Observe(float64(size)) RequestSize.WithLabelValues(server, zone, net).Observe(float64(req.Len())) ResponseRcode.WithLabelValues(server, zone, rcode).Inc() } - -var monitorType = map[uint16]struct{}{ - dns.TypeAAAA: {}, - dns.TypeA: {}, - dns.TypeCNAME: {}, - dns.TypeDNSKEY: {}, - dns.TypeDS: {}, - dns.TypeMX: {}, - dns.TypeNSEC3: {}, - dns.TypeNSEC: {}, - dns.TypeNS: {}, - dns.TypePTR: {}, - dns.TypeRRSIG: {}, - dns.TypeSOA: {}, - dns.TypeSRV: {}, - dns.TypeTXT: {}, - // Meta Qtypes - dns.TypeIXFR: {}, - dns.TypeAXFR: {}, - dns.TypeANY: {}, -} - -const other = "other" -- cgit v1.2.3