blob: 4977b02a353b2952fc3ef51fd8cdcd293fb480c9 [file] [log] [blame]
Jan Schär75ea9f42024-07-29 17:01:41 +02001package forward
2
3// Taken and modified from CoreDNS, under Apache 2.0.
4
5import (
6 "github.com/prometheus/client_golang/prometheus"
7
8 "source.monogon.dev/osbase/net/dns"
9)
10
11// Variables declared for monitoring.
12var (
13 // Possible results:
14 // * hit: Item found and returned from cache.
15 // * miss: Item not found in cache.
16 // * refresh: Item found in cache, but is either expired, or
17 // truncated while the client used TCP.
18 cacheLookupsCount = dns.MetricsFactory.NewCounterVec(prometheus.CounterOpts{
19 Namespace: "dnsserver",
20 Subsystem: "forward",
21 Name: "cache_lookups_total",
22 Help: "Counter of the number of cache lookups.",
23 }, []string{"result"})
24
25 // protocol is one of:
26 // * udp
27 // * udp_truncated
28 // * tcp
29 // rcode can be an uppercase rcode name, a numeric rcode if the rcode is not
30 // known, or one of:
31 // * timeout
32 // * network_error
33 // * protocol_error
34 upstreamDuration = dns.MetricsFactory.NewHistogramVec(prometheus.HistogramOpts{
35 Namespace: "dnsserver",
36 Subsystem: "forward",
37 Name: "upstream_duration_seconds",
38 Buckets: prometheus.ExponentialBuckets(0.00025, 2, 16), // from 0.25ms to 8 seconds
39 Help: "Histogram of the time each upstream request took.",
40 }, []string{"to", "protocol", "rcode"})
41
42 // Possible reasons:
43 // * concurrency_limit: Too many concurrent upstream queries.
44 // * no_upstreams: There are no upstreams configured.
45 // * no_recursion_desired: Client did not set Recursion Desired flag.
46 rejectsCount = dns.MetricsFactory.NewCounterVec(prometheus.CounterOpts{
47 Namespace: "dnsserver",
48 Subsystem: "forward",
49 Name: "rejects_total",
50 Help: "Counter of the number of queries rejected and not forwarded to an upstream.",
51 }, []string{"reason"})
52
53 healthcheckBrokenCount = dns.MetricsFactory.NewCounter(prometheus.CounterOpts{
54 Namespace: "dnsserver",
55 Subsystem: "forward",
56 Name: "healthcheck_broken_total",
57 Help: "Counter of the number of complete failures of the healthchecks.",
58 })
59)