Skip to content

Update add bind view cachestats #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -61,6 +61,7 @@ type Server struct {
type View struct {
Name string
Cache []Gauge
CacheStats []Counter
ResolverStats []Counter
ResolverQueries []Counter
}
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
10 changes: 10 additions & 0 deletions bind_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ var (
"Number of RRSets in Cache database.",
[]string{"view", "type"}, nil,
)
resolverCacheStats = prometheus.NewDesc(
prometheus.BuildFQName(namespace, resolver, "cache_stats"),
"Number of Cache Stats in Cache database.",
[]string{"view", "stat"}, nil,
Comment on lines +80 to +83
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what "Cache Stats" are. Prometheus convention is that the metric name and help should be understandable by the end user without having to know what the underlying code implementation is.

Do you have a link to any upstream documentation about these values?

We typically don't just generically expose random values with "stat" labels. This provides for a poor user experience.

)
resolverQueries = prometheus.NewDesc(
prometheus.BuildFQName(namespace, resolver, "queries_total"),
"Number of outgoing DNS queries.",
Expand Down Expand Up @@ -323,6 +328,11 @@ func (c *viewCollector) Collect(ch chan<- prometheus.Metric) {
resolverCache, prometheus.GaugeValue, float64(s.Gauge), v.Name, s.Name,
)
}
for _, s := range v.CacheStats {
ch <- prometheus.MustNewConstMetric(
resolverCacheStats, prometheus.GaugeValue, float64(s.Counter), v.Name, s.Name,
)
}
for _, s := range v.ResolverQueries {
ch <- prometheus.MustNewConstMetric(
resolverQueries, prometheus.CounterValue, float64(s.Counter), v.Name, s.Name,
Expand Down
Loading