Commit ad352cee authored by Anshul Sharma's avatar Anshul Sharma Committed by Miek Gieben

plugin/reload: Add metrics (#2922)

* Issue 2920
- Add failed reload counter metrics

* typo fix

* Requested Changes
parent cd176f85
......@@ -92,6 +92,12 @@ In general be careful with assigning new port and expecting reload to work fully
Also any `import` statement is not discovered by this plugin. This means if any of these imported files
changes the *reload* plugin is ignorant of that fact.
## Metrics
If monitoring is enabled (via the *prometheus* directive) then the following metric is exported:
* `coredns_reload_failed_count_total{}` - counts the number of failed reload attempts.
## Also See
See coredns-import(7) and corefile(5).
package reload
import (
"github.com/coredns/coredns/plugin"
"github.com/prometheus/client_golang/prometheus"
)
// Metrics for the reload plugin
var (
FailedCount = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: plugin.Namespace,
Subsystem: "reload",
Name: "failed_count_total",
Help: "Counter of the number of failed reload attempts.",
})
)
......@@ -83,6 +83,7 @@ func hook(event caddy.EventName, info interface{}) error {
_, err := instance.Restart(corefile)
if err != nil {
log.Errorf("Corefile changed but reload failed: %s", err)
FailedCount.Add(1)
continue
}
// we are done, if the plugin was not set used, then it is not.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment