mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-29 01:04:15 -04:00 
			
		
		
		
	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>
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package proxy
 | |
| 
 | |
| import (
 | |
| 	"github.com/coredns/coredns/plugin"
 | |
| 
 | |
| 	"github.com/prometheus/client_golang/prometheus"
 | |
| 	"github.com/prometheus/client_golang/prometheus/promauto"
 | |
| )
 | |
| 
 | |
| // Variables declared for monitoring.
 | |
| var (
 | |
| 	requestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
 | |
| 		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{
 | |
| 		Namespace: plugin.Namespace,
 | |
| 		Subsystem: "proxy",
 | |
| 		Name:      "healthcheck_failures_total",
 | |
| 		Help:      "Counter of the number of failed healthchecks.",
 | |
| 	}, []string{"proxy_name", "to"})
 | |
| 
 | |
| 	connCacheHitsCount = promauto.NewCounterVec(prometheus.CounterOpts{
 | |
| 		Namespace: plugin.Namespace,
 | |
| 		Subsystem: "proxy",
 | |
| 		Name:      "conn_cache_hits_total",
 | |
| 		Help:      "Counter of connection cache hits per upstream and protocol.",
 | |
| 	}, []string{"proxy_name", "to", "proto"})
 | |
| 
 | |
| 	connCacheMissesCount = promauto.NewCounterVec(prometheus.CounterOpts{
 | |
| 		Namespace: plugin.Namespace,
 | |
| 		Subsystem: "proxy",
 | |
| 		Name:      "conn_cache_misses_total",
 | |
| 		Help:      "Counter of connection cache misses per upstream and protocol.",
 | |
| 	}, []string{"proxy_name", "to", "proto"})
 | |
| )
 |