aboutsummaryrefslogtreecommitdiff
path: root/plugin/hosts
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/hosts')
-rw-r--r--plugin/hosts/README.md2
-rw-r--r--plugin/hosts/hostsfile.go18
-rw-r--r--plugin/hosts/metrics.go24
3 files changed, 25 insertions, 19 deletions
diff --git a/plugin/hosts/README.md b/plugin/hosts/README.md
index 7cfe8e933..65b7cbf51 100644
--- a/plugin/hosts/README.md
+++ b/plugin/hosts/README.md
@@ -76,7 +76,7 @@ hosts [FILE [ZONES...]] {
If monitoring is enabled (via the *prometheus* plugin) then the following metrics are exported:
-- `coredns_hosts_entries_count{}` - The combined number of entries in hosts and Corefile.
+- `coredns_hosts_entries{}` - The combined number of entries in hosts and Corefile.
- `coredns_hosts_reload_timestamp_seconds{}` - The timestamp of the last reload of hosts file.
## Examples
diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go
index 19cb7e7b3..924c827da 100644
--- a/plugin/hosts/hostsfile.go
+++ b/plugin/hosts/hostsfile.go
@@ -17,8 +17,6 @@ import (
"time"
"github.com/coredns/coredns/plugin"
-
- "github.com/prometheus/client_golang/prometheus"
)
// parseIP calls discards any v6 zone info, before calling net.ParseIP.
@@ -256,19 +254,3 @@ func (h *Hostsfile) LookupStaticAddr(addr string) []string {
copy(hostsCp[len(hosts1):], hosts2)
return hostsCp
}
-
-var (
- hostsEntries = prometheus.NewGaugeVec(prometheus.GaugeOpts{
- Namespace: plugin.Namespace,
- Subsystem: "hosts",
- Name: "entries_count",
- Help: "The combined number of entries in hosts and Corefile.",
- }, []string{})
-
- hostsReloadTime = prometheus.NewGauge(prometheus.GaugeOpts{
- Namespace: plugin.Namespace,
- Subsystem: "hosts",
- Name: "reload_timestamp_seconds",
- Help: "The timestamp of the last reload of hosts file.",
- })
-)
diff --git a/plugin/hosts/metrics.go b/plugin/hosts/metrics.go
new file mode 100644
index 000000000..f20a07775
--- /dev/null
+++ b/plugin/hosts/metrics.go
@@ -0,0 +1,24 @@
+package hosts
+
+import (
+ "github.com/coredns/coredns/plugin"
+
+ "github.com/prometheus/client_golang/prometheus"
+)
+
+var (
+ // hostsEntries is the combined number of entries in hosts and Corefile.
+ hostsEntries = prometheus.NewGaugeVec(prometheus.GaugeOpts{
+ Namespace: plugin.Namespace,
+ Subsystem: "hosts",
+ Name: "entries",
+ Help: "The combined number of entries in hosts and Corefile.",
+ }, []string{})
+ // hostsReloadTime is the timestamp of the last reload of hosts file.
+ hostsReloadTime = prometheus.NewGauge(prometheus.GaugeOpts{
+ Namespace: plugin.Namespace,
+ Subsystem: "hosts",
+ Name: "reload_timestamp_seconds",
+ Help: "The timestamp of the last reload of hosts file.",
+ })
+)