Skip to content

Commit ab15238

Browse files
author
maxiaoyu
committed
update add bind view cachestats
Signed-off-by: maxiaoyu <[email protected]>
1 parent ea563db commit ab15238

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Diff for: bind/bind.go

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Server struct {
6161
type View struct {
6262
Name string
6363
Cache []Gauge
64+
CacheStats []Counter
6465
ResolverStats []Counter
6566
ResolverQueries []Counter
6667
}

Diff for: bind/json/json.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ type Statistics struct {
4747
ZoneStats Counters `json:"zonestats"`
4848
Views map[string]struct {
4949
Resolver struct {
50-
Cache Gauges `json:"cache"`
51-
Qtypes Counters `json:"qtypes"`
52-
Stats Counters `json:"stats"`
50+
Cache Gauges `json:"cache"`
51+
Qtypes Counters `json:"qtypes"`
52+
Stats Counters `json:"stats"`
53+
CacheStats Counters `json:"cachestats"`
5354
} `json:"resolver"`
5455
} `json:"views"`
5556
}
@@ -156,6 +157,9 @@ func (c *Client) Stats(groups ...bind.StatisticGroup) (bind.Statistics, error) {
156157
for k, val := range view.Resolver.Stats {
157158
v.ResolverStats = append(v.ResolverStats, bind.Counter{Name: k, Counter: val})
158159
}
160+
for k, val := range view.Resolver.CacheStats {
161+
v.CacheStats = append(v.CacheStats, bind.Counter{Name: k, Counter: val})
162+
}
159163
s.Views = append(s.Views, v)
160164
}
161165
}

Diff for: bind_exporter.go

+10
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ var (
7777
"Number of RRSets in Cache database.",
7878
[]string{"view", "type"}, nil,
7979
)
80+
resolverCacheStats = prometheus.NewDesc(
81+
prometheus.BuildFQName(namespace, resolver, "cache_stats"),
82+
"Number of Cache Stats in Cache database.",
83+
[]string{"view", "stat"}, nil,
84+
)
8085
resolverQueries = prometheus.NewDesc(
8186
prometheus.BuildFQName(namespace, resolver, "queries_total"),
8287
"Number of outgoing DNS queries.",
@@ -323,6 +328,11 @@ func (c *viewCollector) Collect(ch chan<- prometheus.Metric) {
323328
resolverCache, prometheus.GaugeValue, float64(s.Gauge), v.Name, s.Name,
324329
)
325330
}
331+
for _, s := range v.CacheStats {
332+
ch <- prometheus.MustNewConstMetric(
333+
resolverCacheStats, prometheus.GaugeValue, float64(s.Counter), v.Name, s.Name,
334+
)
335+
}
326336
for _, s := range v.ResolverQueries {
327337
ch <- prometheus.MustNewConstMetric(
328338
resolverQueries, prometheus.CounterValue, float64(s.Counter), v.Name, s.Name,

0 commit comments

Comments
 (0)