From e5945d2767ee45b1a2a4a2aba8daf8c470c4519c Mon Sep 17 00:00:00 2001 From: Paco Xu Date: Tue, 6 Aug 2024 19:13:22 +0800 Subject: [PATCH] hosts: add hostsfile as label for coredns_hosts_entries (#6801) Signed-off-by: Paco Xu --- plugin/hosts/hostsfile.go | 2 +- plugin/hosts/metrics.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/hosts/hostsfile.go b/plugin/hosts/hostsfile.go index e5aff0d6d..04747ef8d 100644 --- a/plugin/hosts/hostsfile.go +++ b/plugin/hosts/hostsfile.go @@ -138,7 +138,7 @@ func (h *Hostsfile) readHosts() { h.mtime = stat.ModTime() h.size = stat.Size() - hostsEntries.WithLabelValues().Set(float64(h.inline.Len() + h.hmap.Len())) + hostsEntries.WithLabelValues(h.path).Set(float64(h.inline.Len() + h.hmap.Len())) hostsReloadTime.Set(float64(stat.ModTime().UnixNano()) / 1e9) h.Unlock() } diff --git a/plugin/hosts/metrics.go b/plugin/hosts/metrics.go index f97497bf2..d3999e1e9 100644 --- a/plugin/hosts/metrics.go +++ b/plugin/hosts/metrics.go @@ -14,7 +14,7 @@ var ( Subsystem: "hosts", Name: "entries", Help: "The combined number of entries in hosts and Corefile.", - }, []string{}) + }, []string{"hostsfile"}) // hostsReloadTime is the timestamp of the last reload of hosts file. hostsReloadTime = promauto.NewGauge(prometheus.GaugeOpts{ Namespace: plugin.Namespace,