aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Anshul Sharma <sharmaanshul2102@gmail.com> 2019-06-26 09:38:46 +0300
committerGravatar Miek Gieben <miek@miek.nl> 2019-06-26 07:38:46 +0100
commitad352cee88a6be7154e55a2eb0ef1f95ffa858df (patch)
treee126ced62794b26ef235697cd480ba9833f53341
parentcd176f859b2e71d8919c56ff67235c226ab5b48e (diff)
downloadcoredns-ad352cee88a6be7154e55a2eb0ef1f95ffa858df.tar.gz
coredns-ad352cee88a6be7154e55a2eb0ef1f95ffa858df.tar.zst
coredns-ad352cee88a6be7154e55a2eb0ef1f95ffa858df.zip
plugin/reload: Add metrics (#2922)
* Issue 2920 - Add failed reload counter metrics * typo fix * Requested Changes
-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.