Browse Source

Option to disable detailed prometheus metrics

Also fix public debug queries to be a proper configuration option
Ask Bjørn Hansen 2 years ago
parent
commit
8b59dac3d4
4 changed files with 25 additions and 2 deletions
  1. 5 0
      CHANGES.md
  2. 6 0
      dns/geodns.conf.sample
  3. 6 1
      server/serve.go
  4. 8 1
      server/server.go

+ 5 - 0
CHANGES.md

@@ -1,5 +1,10 @@
 # GeoDNS Changelog
 # GeoDNS Changelog
 
 
+## Next
+- DNS configuration options (see dns/geodns.conf.sample) for
+  disabling qnames being in the prometheus labels and enabling
+  public debug queries.
+
 ## 3.3.3 August 2023
 ## 3.3.3 August 2023
 - Fix how NS / SOA queries are treated for alias records pointing
 - Fix how NS / SOA queries are treated for alias records pointing
   to the zone apex
   to the zone apex

+ 6 - 0
dns/geodns.conf.sample

@@ -3,6 +3,12 @@
 ; It is recommended to distribute the configuration file globally
 ; It is recommended to distribute the configuration file globally
 ; with your .json zone files.
 ; with your .json zone files.
 
 
+[dns]
+# allow _status queries from anywhere (versus only localhost)
+publicdebugqueries = false
+# include query label in prometheus metrics
+detailedmetrics    = true
+
 [geoip]
 [geoip]
 ;; Directory containing the GeoIP2 .mmdb database files; defaults
 ;; Directory containing the GeoIP2 .mmdb database files; defaults
 ;; to looking through a list of common directories looking for one
 ;; to looking through a list of common directories looking for one

+ 6 - 1
server/serve.go

@@ -311,11 +311,16 @@ func (srv *Server) serve(w dns.ResponseWriter, req *dns.Msg, z *zones.Zone) {
 		m.Ns = append(m.Ns, z.SoaRR())
 		m.Ns = append(m.Ns, z.SoaRR())
 	}
 	}
 
 
+	qlabelMetric := "_"
+	if srv.DetailedMetrics {
+		qlabelMetric = qlabel
+	}
+
 	srv.metrics.Queries.With(
 	srv.metrics.Queries.With(
 		prometheus.Labels{
 		prometheus.Labels{
 			"zone":  z.Origin,
 			"zone":  z.Origin,
 			"qtype": dns.TypeToString[qtype],
 			"qtype": dns.TypeToString[qtype],
-			"qname": qlabel,
+			"qname": qlabelMetric,
 			"rcode": dns.RcodeToString[m.Rcode],
 			"rcode": dns.RcodeToString[m.Rcode],
 		}).Inc()
 		}).Inc()
 
 

+ 8 - 1
server/server.go

@@ -80,7 +80,14 @@ func NewServer(config *appconfig.AppConfig, si *monitor.ServerInfo) *Server {
 		Queries: queries,
 		Queries: queries,
 	}
 	}
 
 
-	return &Server{mux: mux, info: si, metrics: metrics}
+	return &Server{
+		PublicDebugQueries: appconfig.Config.DNS.PublicDebugQueries,
+		DetailedMetrics:    appconfig.Config.DNS.DetailedMetrics,
+
+		mux:     mux,
+		info:    si,
+		metrics: metrics,
+	}
 }
 }
 
 
 // SetQueryLogger configures the query logger. For now it only supports writing to
 // SetQueryLogger configures the query logger. For now it only supports writing to