Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type View struct {
Cache []Gauge
ResolverStats []Counter
ResolverQueries []Counter
CacheStats []Counter
}

// View represents statistics for a single BIND zone view.
Expand Down
10 changes: 7 additions & 3 deletions bind/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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)
}
}
Expand Down
17 changes: 10 additions & 7 deletions bind/xml/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions bind_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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(
Expand Down