From 0d4af2b71c723347ebae4bfdeda128422baa7a7d Mon Sep 17 00:00:00 2001 From: SamB Date: Fri, 10 May 2019 09:40:13 +0200 Subject: [PATCH] No version metrics when default metrics disabled --- cmd/postgres_exporter/postgres_exporter.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/postgres_exporter/postgres_exporter.go b/cmd/postgres_exporter/postgres_exporter.go index 15e6ce72..8a0da87a 100644 --- a/cmd/postgres_exporter/postgres_exporter.go +++ b/cmd/postgres_exporter/postgres_exporter.go @@ -1231,8 +1231,10 @@ func (e *Exporter) checkMapVersions(ch chan<- prometheus.Metric, server *Server) versionDesc := prometheus.NewDesc(fmt.Sprintf("%s_%s", namespace, staticLabelName), "Version string as reported by postgres", []string{"version", "short_version"}, server.labels) - ch <- prometheus.MustNewConstMetric(versionDesc, - prometheus.UntypedValue, 1, versionString, semanticVersion.String()) + if !e.disableDefaultMetrics { + ch <- prometheus.MustNewConstMetric(versionDesc, + prometheus.UntypedValue, 1, versionString, semanticVersion.String()) + } return nil }