diff --git a/bind/bind.go b/bind/bind.go index c2379b44..e41e520b 100644 --- a/bind/bind.go +++ b/bind/bind.go @@ -63,6 +63,7 @@ type View struct { Cache []Gauge ResolverStats []Counter ResolverQueries []Counter + CacheStats []Counter } // View represents statistics for a single BIND zone view. diff --git a/bind/json/json.go b/bind/json/json.go index d20ecd2c..36eb4654 100644 --- a/bind/json/json.go +++ b/bind/json/json.go @@ -47,9 +47,10 @@ type Statistics struct { ZoneStats Counters `json:"zonestats"` Views map[string]struct { Resolver struct { - Cache Gauges `json:"cache"` - Qtypes Counters `json:"qtypes"` - Stats Counters `json:"stats"` + Cache Gauges `json:"cache"` + Qtypes Counters `json:"qtypes"` + Stats Counters `json:"stats"` + CacheStats Counters `json:"cachestats"` } `json:"resolver"` } `json:"views"` } @@ -156,6 +157,9 @@ func (c *Client) Stats(groups ...bind.StatisticGroup) (bind.Statistics, error) { for k, val := range view.Resolver.Stats { v.ResolverStats = append(v.ResolverStats, bind.Counter{Name: k, Counter: val}) } + for k, val := range view.Resolver.CacheStats { + v.CacheStats = append(v.CacheStats, bind.Counter{Name: k, Counter: val}) + } s.Views = append(s.Views, v) } } diff --git a/bind/xml/xml.go b/bind/xml/xml.go index cfa357c8..0b70b33b 100644 --- a/bind/xml/xml.go +++ b/bind/xml/xml.go @@ -34,13 +34,14 @@ const ( // ZonesPath is the HTTP path of the v3 zones resource. ZonesPath = "/xml/v3/zones" - nsstat = "nsstat" - opcode = "opcode" - qtype = "qtype" - resqtype = "resqtype" - resstats = "resstats" - zonestat = "zonestat" - rcode = "rcode" + nsstat = "nsstat" + opcode = "opcode" + qtype = "qtype" + resqtype = "resqtype" + resstats = "resstats" + zonestat = "zonestat" + rcode = "rcode" + cachestats = "cachestats" ) type Statistics struct { @@ -170,6 +171,8 @@ func (c *Client) Stats(groups ...bind.StatisticGroup) (bind.Statistics, error) { v.ResolverQueries = c.Counters case resstats: v.ResolverStats = c.Counters + case cachestats: + v.CacheStats = c.Counters } } s.Views = append(s.Views, v) diff --git a/bind_exporter.go b/bind_exporter.go index 7f89374c..fb7ae258 100644 --- a/bind_exporter.go +++ b/bind_exporter.go @@ -82,6 +82,11 @@ var ( "Number of outgoing DNS queries.", []string{"view", "type"}, nil, ) + cacheStats = prometheus.NewDesc( + prometheus.BuildFQName(namespace, resolver, "cache_stats"), + "Resolver cache statistics.", + []string{"view", "type"}, nil, + ) resolverQueryDuration = prometheus.NewDesc( prometheus.BuildFQName(namespace, resolver, "query_duration_seconds"), "Resolver query round-trip time in seconds.", @@ -333,6 +338,11 @@ func (c *viewCollector) Collect(ch chan<- prometheus.Metric) { resolverQueries, prometheus.CounterValue, float64(s.Counter), v.Name, s.Name, ) } + for _, s := range v.CacheStats { + ch <- prometheus.MustNewConstMetric( + cacheStats, prometheus.CounterValue, float64(s.Counter), v.Name, s.Name, + ) + } for _, s := range v.ResolverStats { if desc, ok := resolverMetricStats[s.Name]; ok { ch <- prometheus.MustNewConstMetric(