Skip to content

Commit 6a9964b

Browse files
Robert TothDean-Coakley
authored andcommitted
Add const labels to upMetric
1 parent 39585bd commit 6a9964b

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

collector/helper.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ func newGlobalMetric(namespace string, metricName string, docString string, cons
1111
return prometheus.NewDesc(namespace+"_"+metricName, docString, nil, constLabels)
1212
}
1313

14-
func newUpMetric(namespace string) prometheus.Gauge {
14+
func newUpMetric(namespace string, constLabels map[string]string) prometheus.Gauge {
1515
return prometheus.NewGauge(prometheus.GaugeOpts{
16-
Namespace: namespace,
17-
Name: "up",
18-
Help: "Status of the last metric scrape",
16+
Namespace: namespace,
17+
Name: "up",
18+
Help: "Status of the last metric scrape",
19+
ConstLabels: constLabels,
1920
})
2021
}
2122

collector/nginx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewNginxCollector(nginxClient *client.NginxClient, namespace string, constL
2929
"connections_waiting": newGlobalMetric(namespace, "connections_waiting", "Idle client connections", constLabels),
3030
"http_requests_total": newGlobalMetric(namespace, "http_requests_total", "Total http requests", constLabels),
3131
},
32-
upMetric: newUpMetric(namespace),
32+
upMetric: newUpMetric(namespace, constLabels),
3333
}
3434
}
3535

collector/nginx_plus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func NewNginxPlusCollector(nginxClient *plusclient.NginxClient, namespace string
136136
"timedout": newResolverMetric(namespace, "timedout", "Total number of timed out requests", constLabels),
137137
"unknown": newResolverMetric(namespace, "unknown", "Total requests completed with an unknown error", constLabels),
138138
},
139-
upMetric: newUpMetric(namespace),
139+
upMetric: newUpMetric(namespace, constLabels),
140140
}
141141
}
142142

0 commit comments

Comments
 (0)