aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/reload/README.md6
-rw-r--r--plugin/reload/metrics.go17
-rw-r--r--plugin/reload/reload.go1
3 files changed, 24 insertions, 0 deletions
diff --git a/plugin/reload/README.md b/plugin/reload/README.md
index 8d1f5db64..c1f5d206b 100644
--- a/plugin/reload/README.md
+++ b/plugin/reload/README.md
@@ -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).
diff --git a/plugin/reload/metrics.go b/plugin/reload/metrics.go
new file mode 100644
index 000000000..1f790d4c1
--- /dev/null
+++ b/plugin/reload/metrics.go
@@ -0,0 +1,17 @@
+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.",
+ })
+)
diff --git a/plugin/reload/reload.go b/plugin/reload/reload.go
index 3abc33835..7070218e9 100644
--- a/plugin/reload/reload.go
+++ b/plugin/reload/reload.go
@@ -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.