diff options
author | 2018-05-05 19:47:41 +0200 | |
---|---|---|
committer | 2018-05-05 19:47:41 +0200 | |
commit | 7c275777073372a592e54921761881b526d2870c (patch) | |
tree | b05f1e5024514a944198c4f28be86ad9421a9c17 /plugin | |
parent | 41f1a1434ace180f955317d1d8965a8644c6aa31 (diff) | |
download | coredns-7c275777073372a592e54921761881b526d2870c.tar.gz coredns-7c275777073372a592e54921761881b526d2870c.tar.zst coredns-7c275777073372a592e54921761881b526d2870c.zip |
plugin/metrics: add panic counter (#1778)
Count and export number of panics we see.
Fixes #1294
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/metrics/README.md | 1 | ||||
-rw-r--r-- | plugin/metrics/metrics.go | 13 | ||||
-rw-r--r-- | plugin/metrics/vars/vars.go | 6 |
3 files changed, 13 insertions, 7 deletions
diff --git a/plugin/metrics/README.md b/plugin/metrics/README.md index 882e1fcb2..c962068a4 100644 --- a/plugin/metrics/README.md +++ b/plugin/metrics/README.md @@ -11,6 +11,7 @@ The default location for the metrics is `localhost:9153`. The metrics path is fi The following metrics are exported: * `coredns_build_info{version, revision, goversion}` - info about CoreDNS itself. +* `coredns_panic_count_total{}` - total number of panics. * `coredns_dns_request_count_total{server, zone, proto, family}` - total query count. * `coredns_dns_request_duration_seconds{server, zone}` - duration to process each query. * `coredns_dns_request_size_bytes{server, zone, proto}` - size of the request in bytes. diff --git a/plugin/metrics/metrics.go b/plugin/metrics/metrics.go index 5816288a4..af4afc6ac 100644 --- a/plugin/metrics/metrics.go +++ b/plugin/metrics/metrics.go @@ -41,6 +41,7 @@ func New(addr string) *Metrics { // Add all of our collectors met.MustRegister(buildInfo) + met.MustRegister(vars.Panic) met.MustRegister(vars.RequestCount) met.MustRegister(vars.RequestDuration) met.MustRegister(vars.RequestSize) @@ -137,10 +138,8 @@ func keys(m map[string]bool) []string { // we listen on "localhost:0" and need to retrieve the actual address. var ListenAddr string -var ( - buildInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{ - Namespace: plugin.Namespace, - Name: "build_info", - Help: "A metric with a constant '1' value labeled by version, revision, and goversion from which CoreDNS was built.", - }, []string{"version", "revision", "goversion"}) -) +var buildInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Namespace: plugin.Namespace, + Name: "build_info", + Help: "A metric with a constant '1' value labeled by version, revision, and goversion from which CoreDNS was built.", +}, []string{"version", "revision", "goversion"}) diff --git a/plugin/metrics/vars/vars.go b/plugin/metrics/vars/vars.go index 3b3c083c8..a25a0894c 100644 --- a/plugin/metrics/vars/vars.go +++ b/plugin/metrics/vars/vars.go @@ -59,6 +59,12 @@ var ( Name: "response_rcode_count_total", Help: "Counter of response status codes.", }, []string{"server", "zone", "rcode"}) + + Panic = prometheus.NewCounter(prometheus.CounterOpts{ + Namespace: plugin.Namespace, + Name: "panic_count_total", + Help: "A metrics that counts the number of panics.", + }) ) const ( |