Use the same namespace for collector and version.

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2019-12-14 10:02:45 +01:00
parent 3abcff9dbf
commit d44324d3c7
1 changed files with 3 additions and 2 deletions

View File

@ -18,15 +18,16 @@ const oneDecimalPoint = 10
func (u *UnifiPoller) RunPrometheus() error { func (u *UnifiPoller) RunPrometheus() error {
u.Logf("Exporting Measurements for Prometheus at https://%s/metrics", u.Config.HTTPListen) u.Logf("Exporting Measurements for Prometheus at https://%s/metrics", u.Config.HTTPListen)
http.Handle("/metrics", promhttp.Handler()) http.Handle("/metrics", promhttp.Handler())
ns := strings.Replace(u.Config.Namespace, "-", "", -1)
prometheus.MustRegister(promunifi.NewUnifiCollector(promunifi.UnifiCollectorCnfg{ prometheus.MustRegister(promunifi.NewUnifiCollector(promunifi.UnifiCollectorCnfg{
Namespace: strings.Replace(u.Config.Namespace, "-", "", -1), Namespace: ns,
CollectFn: u.ExportMetrics, CollectFn: u.ExportMetrics,
LoggingFn: u.LogExportReport, LoggingFn: u.LogExportReport,
ReportErrors: true, // XXX: Does this need to be configurable? ReportErrors: true, // XXX: Does this need to be configurable?
})) }))
version.Version = Version version.Version = Version
prometheus.MustRegister(version.NewCollector("unifipoller")) prometheus.MustRegister(version.NewCollector(ns))
return http.ListenAndServe(u.Config.HTTPListen, nil) return http.ListenAndServe(u.Config.HTTPListen, nil)
} }