aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg/dnsutil/monitor.go
diff options
context:
space:
mode:
authorGravatar Maxime Ginters <maxime.ginters+github@gmail.com> 2021-01-28 10:37:17 -0500
committerGravatar GitHub <noreply@github.com> 2021-01-28 16:37:17 +0100
commitb1173ed2a583cc6102b46b02b4675828f87ebfd8 (patch)
treef4a816ccfcfd8b281680098dccdd2f1dc1d2317c /plugin/pkg/dnsutil/monitor.go
parent2ab304078b96ac53b90cb0b9a9c7a9f449b6848b (diff)
downloadcoredns-b1173ed2a583cc6102b46b02b4675828f87ebfd8.tar.gz
coredns-b1173ed2a583cc6102b46b02b4675828f87ebfd8.tar.zst
coredns-b1173ed2a583cc6102b46b02b4675828f87ebfd8.zip
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 <maxime.ginters@shopify.com> * Control the cardinality of query type Signed-off-by: Maxime Ginters <maxime.ginters@shopify.com>
Diffstat (limited to 'plugin/pkg/dnsutil/monitor.go')
-rw-r--r--plugin/pkg/dnsutil/monitor.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/plugin/pkg/dnsutil/monitor.go b/plugin/pkg/dnsutil/monitor.go
new file mode 100644
index 000000000..b86f8e43a
--- /dev/null
+++ b/plugin/pkg/dnsutil/monitor.go
@@ -0,0 +1,37 @@
+package dnsutil
+
+import (
+ "github.com/miekg/dns"
+)
+
+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"
+
+// QTypeMonitorLabel returns dns type label based on a list of monitored types.
+// Will return "other" for unmonitored ones.
+func QTypeMonitorLabel(qtype uint16) string {
+ if _, known := monitorType[qtype]; known {
+ return dns.Type(qtype).String()
+ }
+ return other
+}