hosts: add hostsfile as label for coredns_hosts_entries (#6801)

Signed-off-by: Paco Xu <paco.xu@daocloud.io>
This commit is contained in:
Paco Xu 2024-08-06 19:13:22 +08:00 committed by GitHub
parent ae65f4e0c7
commit e5945d2767
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -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()
}

View file

@ -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,