| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | package vars
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import (
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin"
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/prometheus/client_golang/prometheus"
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	"github.com/prometheus/client_golang/prometheus/promauto"
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | )
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-13 14:03:12 +00:00
										 |  |  | // Request* and Response* are the prometheus counters and gauges we are using for exporting metrics.
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | var (
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	RequestCount = promauto.NewCounterVec(prometheus.CounterOpts{
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Subsystem: subsystem,
 | 
					
						
							| 
									
										
										
										
											2020-03-26 09:17:33 +01:00
										 |  |  | 		Name:      "requests_total",
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Help:      "Counter of DNS requests made per zone, protocol and family.",
 | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zone", "view", "proto", "family", "type"})
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	RequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Subsystem: subsystem,
 | 
					
						
							| 
									
										
										
										
											2017-11-27 22:34:26 +01:00
										 |  |  | 		Name:      "request_duration_seconds",
 | 
					
						
							|  |  |  | 		Buckets:   plugin.TimeBuckets,
 | 
					
						
							| 
									
										
										
										
											2021-03-19 12:59:26 +01:00
										 |  |  | 		Help:      "Histogram of the time (in seconds) each request took per zone.",
 | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zone", "view"})
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	RequestSize = promauto.NewHistogramVec(prometheus.HistogramOpts{
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Subsystem: subsystem,
 | 
					
						
							|  |  |  | 		Name:      "request_size_bytes",
 | 
					
						
							| 
									
										
										
										
											2021-03-19 12:59:26 +01:00
										 |  |  | 		Help:      "Size of the EDNS0 UDP buffer in bytes (64K for TCP) per zone and protocol.",
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Buckets:   []float64{0, 100, 200, 300, 400, 511, 1023, 2047, 4095, 8291, 16e3, 32e3, 48e3, 64e3},
 | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zone", "view", "proto"})
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	RequestDo = promauto.NewCounterVec(prometheus.CounterOpts{
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Subsystem: subsystem,
 | 
					
						
							| 
									
										
										
										
											2020-03-26 09:17:33 +01:00
										 |  |  | 		Name:      "do_requests_total",
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Help:      "Counter of DNS requests with DO bit set per zone.",
 | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zone", "view"})
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	ResponseSize = promauto.NewHistogramVec(prometheus.HistogramOpts{
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Subsystem: subsystem,
 | 
					
						
							|  |  |  | 		Name:      "response_size_bytes",
 | 
					
						
							|  |  |  | 		Help:      "Size of the returned response in bytes.",
 | 
					
						
							|  |  |  | 		Buckets:   []float64{0, 100, 200, 300, 400, 511, 1023, 2047, 4095, 8291, 16e3, 32e3, 48e3, 64e3},
 | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zone", "view", "proto"})
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	ResponseRcode = promauto.NewCounterVec(prometheus.CounterOpts{
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Subsystem: subsystem,
 | 
					
						
							| 
									
										
										
										
											2020-03-26 09:17:33 +01:00
										 |  |  | 		Name:      "responses_total",
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | 		Help:      "Counter of response status codes.",
 | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zone", "view", "rcode", "plugin"})
 | 
					
						
							| 
									
										
										
										
											2018-05-05 19:47:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	Panic = promauto.NewCounter(prometheus.CounterOpts{
 | 
					
						
							| 
									
										
										
										
											2018-05-05 19:47:41 +02:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							| 
									
										
										
										
											2020-03-26 09:17:33 +01:00
										 |  |  | 		Name:      "panics_total",
 | 
					
						
							| 
									
										
										
										
											2018-05-05 19:47:41 +02:00
										 |  |  | 		Help:      "A metrics that counts the number of panics.",
 | 
					
						
							|  |  |  | 	})
 | 
					
						
							| 
									
										
										
										
											2019-03-23 10:43:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	PluginEnabled = promauto.NewGaugeVec(prometheus.GaugeOpts{
 | 
					
						
							| 
									
										
										
										
											2019-03-23 10:43:15 +01:00
										 |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							|  |  |  | 		Name:      "plugin_enabled",
 | 
					
						
							|  |  |  | 		Help:      "A metric that indicates whether a plugin is enabled on per server and zone basis.",
 | 
					
						
							| 
									
										
										
										
											2022-09-14 20:45:45 +02:00
										 |  |  | 	}, []string{"server", "zone", "view", "name"})
 | 
					
						
							| 
									
										
										
										
											2022-02-17 14:37:40 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	HTTPSResponsesCount = promauto.NewCounterVec(prometheus.CounterOpts{
 | 
					
						
							|  |  |  | 		Namespace: plugin.Namespace,
 | 
					
						
							|  |  |  | 		Subsystem: subsystem,
 | 
					
						
							|  |  |  | 		Name:      "https_responses_total",
 | 
					
						
							|  |  |  | 		Help:      "Counter of DoH responses per server and http status code.",
 | 
					
						
							|  |  |  | 	}, []string{"server", "status"})
 | 
					
						
							| 
									
										
										
										
											2016-10-26 10:01:52 +01:00
										 |  |  | )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const (
 | 
					
						
							|  |  |  | 	subsystem = "dns"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Dropped indicates we dropped the query before any handling. It has no closing dot, so it can not be a valid zone.
 | 
					
						
							|  |  |  | 	Dropped = "dropped"
 | 
					
						
							|  |  |  | )
 |