| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | package cache | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"github.com/coredns/coredns/plugin" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/prometheus/client_golang/prometheus" | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	"github.com/prometheus/client_golang/prometheus/promauto" | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var ( | 
					
						
							|  |  |  | 	// cacheSize is total elements in the cache by cache type. | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	cacheSize = promauto.NewGaugeVec(prometheus.GaugeOpts{ | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							| 
									
										
										
										
											2020-04-04 00:30:06 +08:00
										 |  |  | 		Name:      "entries", | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 		Help:      "The number of elements in the cache.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "type", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2021-08-16 07:54:36 +02:00
										 |  |  | 	// cacheRequests is a counter of all requests through the cache. | 
					
						
							|  |  |  | 	cacheRequests = promauto.NewCounterVec(prometheus.CounterOpts{ | 
					
						
							|  |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							|  |  |  | 		Name:      "requests_total", | 
					
						
							|  |  |  | 		Help:      "The count of cache requests.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 	// cacheHits is counter of cache hits by cache type. | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	cacheHits = promauto.NewCounterVec(prometheus.CounterOpts{ | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							|  |  |  | 		Name:      "hits_total", | 
					
						
							|  |  |  | 		Help:      "The count of cache hits.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "type", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2021-08-16 07:54:36 +02:00
										 |  |  | 	// cacheMisses is the counter of cache misses. - Deprecated | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	cacheMisses = promauto.NewCounterVec(prometheus.CounterOpts{ | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							|  |  |  | 		Name:      "misses_total", | 
					
						
							| 
									
										
										
										
											2021-08-16 07:54:36 +02:00
										 |  |  | 		Help:      "The count of cache misses. Deprecated, derive misses from cache hits/requests counters.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 	// cachePrefetches is the number of time the cache has prefetched a cached item. | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	cachePrefetches = promauto.NewCounterVec(prometheus.CounterOpts{ | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							|  |  |  | 		Name:      "prefetch_total", | 
					
						
							| 
									
										
										
										
											2020-06-24 10:49:42 -04:00
										 |  |  | 		Help:      "The number of times the cache has prefetched a cached item.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 	// cacheDrops is the number responses that are not cached, because the reply is malformed. | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	cacheDrops = promauto.NewCounterVec(prometheus.CounterOpts{ | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							|  |  |  | 		Name:      "drops_total", | 
					
						
							|  |  |  | 		Help:      "The number responses that are not cached, because the reply is malformed.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 	// servedStale is the number of requests served from stale cache entries. | 
					
						
							| 
									
										
										
										
											2020-07-25 23:06:28 +08:00
										 |  |  | 	servedStale = promauto.NewCounterVec(prometheus.CounterOpts{ | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							|  |  |  | 		Name:      "served_stale_total", | 
					
						
							|  |  |  | 		Help:      "The number of requests served from stale cache entries.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2021-03-21 08:58:16 -07:00
										 |  |  | 	// evictions is the counter of cache evictions. | 
					
						
							|  |  |  | 	evictions = promauto.NewCounterVec(prometheus.CounterOpts{ | 
					
						
							|  |  |  | 		Namespace: plugin.Namespace, | 
					
						
							|  |  |  | 		Subsystem: "cache", | 
					
						
							|  |  |  | 		Name:      "evictions_total", | 
					
						
							|  |  |  | 		Help:      "The count of cache evictions.", | 
					
						
							| 
									
										
										
										
											2022-09-08 14:56:27 -04:00
										 |  |  | 	}, []string{"server", "type", "zones", "view"}) | 
					
						
							| 
									
										
										
										
											2020-03-31 14:07:36 +08:00
										 |  |  | ) |