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