From 6a9964bcce3e327409b9abc044d2e22cd77636e0 Mon Sep 17 00:00:00 2001 From: Robert Toth Date: Fri, 17 Apr 2020 13:35:59 +0200 Subject: [PATCH] Add const labels to upMetric --- collector/helper.go | 9 +++++---- collector/nginx.go | 2 +- collector/nginx_plus.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/collector/helper.go b/collector/helper.go index aeea5c9..305efde 100644 --- a/collector/helper.go +++ b/collector/helper.go @@ -11,11 +11,12 @@ func newGlobalMetric(namespace string, metricName string, docString string, cons return prometheus.NewDesc(namespace+"_"+metricName, docString, nil, constLabels) } -func newUpMetric(namespace string) prometheus.Gauge { +func newUpMetric(namespace string, constLabels map[string]string) prometheus.Gauge { return prometheus.NewGauge(prometheus.GaugeOpts{ - Namespace: namespace, - Name: "up", - Help: "Status of the last metric scrape", + Namespace: namespace, + Name: "up", + Help: "Status of the last metric scrape", + ConstLabels: constLabels, }) } diff --git a/collector/nginx.go b/collector/nginx.go index c6576db..ec8a6fa 100644 --- a/collector/nginx.go +++ b/collector/nginx.go @@ -29,7 +29,7 @@ func NewNginxCollector(nginxClient *client.NginxClient, namespace string, constL "connections_waiting": newGlobalMetric(namespace, "connections_waiting", "Idle client connections", constLabels), "http_requests_total": newGlobalMetric(namespace, "http_requests_total", "Total http requests", constLabels), }, - upMetric: newUpMetric(namespace), + upMetric: newUpMetric(namespace, constLabels), } } diff --git a/collector/nginx_plus.go b/collector/nginx_plus.go index 40c89cb..fc1992b 100644 --- a/collector/nginx_plus.go +++ b/collector/nginx_plus.go @@ -136,7 +136,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string "timedout": newResolverMetric(namespace, "timedout", "Total number of timed out requests", constLabels), "unknown": newResolverMetric(namespace, "unknown", "Total requests completed with an unknown error", constLabels), }, - upMetric: newUpMetric(namespace), + upMetric: newUpMetric(namespace, constLabels), } }