Enable Prometheus native histograms (#6524)

Add a NativeHistogramBucketFactor parameter to the use of
`NewHistogramVec` in order to enable use of Prometheus Native
Histograms.

This will store automatically computed sparse buckets in CoreDNS.
If a compatible Prometeus requests native histograms this data will
returned instead of the static buckets.

The default factor of 1.05 should provide high quality resolution data.

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
Ben Kochie
2024-03-11 21:09:09 +01:00
committed by GitHub
parent a4cbd95795
commit 0d6e113f90
7 changed files with 55 additions and 42 deletions

View File

@@ -10,11 +10,12 @@ import (
// Variables declared for monitoring.
var (
requestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
Namespace: plugin.Namespace,
Subsystem: "proxy",
Name: "request_duration_seconds",
Buckets: plugin.TimeBuckets,
Help: "Histogram of the time each request took.",
Namespace: plugin.Namespace,
Subsystem: "proxy",
Name: "request_duration_seconds",
Buckets: plugin.TimeBuckets,
NativeHistogramBucketFactor: plugin.NativeHistogramBucketFactor,
Help: "Histogram of the time each request took.",
}, []string{"proxy_name", "to", "rcode"})
healthcheckFailureCount = promauto.NewCounterVec(prometheus.CounterOpts{