mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
add zones label to cache metrics (#5124)
* add zones to cache metrics Signed-off-by: Elijah Andrews <elijahcandrews@gmail.com>
This commit is contained in:
12
plugin/cache/cache.go
vendored
12
plugin/cache/cache.go
vendored
@@ -21,6 +21,8 @@ type Cache struct {
|
||||
Next plugin.Handler
|
||||
Zones []string
|
||||
|
||||
zonesMetricLabel string
|
||||
|
||||
ncache *cache.Cache
|
||||
ncap int
|
||||
nttl time.Duration
|
||||
@@ -162,11 +164,11 @@ func (w *ResponseWriter) WriteMsg(res *dns.Msg) error {
|
||||
if hasKey && duration > 0 {
|
||||
if w.state.Match(res) {
|
||||
w.set(res, key, mt, duration)
|
||||
cacheSize.WithLabelValues(w.server, Success).Set(float64(w.pcache.Len()))
|
||||
cacheSize.WithLabelValues(w.server, Denial).Set(float64(w.ncache.Len()))
|
||||
cacheSize.WithLabelValues(w.server, Success, w.zonesMetricLabel).Set(float64(w.pcache.Len()))
|
||||
cacheSize.WithLabelValues(w.server, Denial, w.zonesMetricLabel).Set(float64(w.ncache.Len()))
|
||||
} else {
|
||||
// Don't log it, but increment counter
|
||||
cacheDrops.WithLabelValues(w.server).Inc()
|
||||
cacheDrops.WithLabelValues(w.server, w.zonesMetricLabel).Inc()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +197,7 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration
|
||||
case response.NoError, response.Delegation:
|
||||
i := newItem(m, w.now(), duration)
|
||||
if w.pcache.Add(key, i) {
|
||||
evictions.WithLabelValues(w.server, Success).Inc()
|
||||
evictions.WithLabelValues(w.server, Success, w.zonesMetricLabel).Inc()
|
||||
}
|
||||
// when pre-fetching, remove the negative cache entry if it exists
|
||||
if w.prefetch {
|
||||
@@ -205,7 +207,7 @@ func (w *ResponseWriter) set(m *dns.Msg, key uint64, mt response.Type, duration
|
||||
case response.NameError, response.NoData, response.ServerError:
|
||||
i := newItem(m, w.now(), duration)
|
||||
if w.ncache.Add(key, i) {
|
||||
evictions.WithLabelValues(w.server, Denial).Inc()
|
||||
evictions.WithLabelValues(w.server, Denial, w.zonesMetricLabel).Inc()
|
||||
}
|
||||
|
||||
case response.OtherError:
|
||||
|
||||
Reference in New Issue
Block a user