From 1451ea73eed9c70c156a2d3f713b68044349b013 Mon Sep 17 00:00:00 2001 From: Jan Grewe <jan.grewe@flixbus.com> Date: Thu, 7 Jun 2018 14:30:41 +0200 Subject: [PATCH] Add 'host' label to all metrics --- main.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 2cc2e1b..1276f33 100644 --- a/main.go +++ b/main.go @@ -93,47 +93,49 @@ func NewExporter(uri string) *Exporter { prometheus.BuildFQName(namespace, "", "up"), "Is the Nexenta API reachable", nil, - nil), + prometheus.Labels{"host":*apiHost}, + ), scrapeFailures: prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: namespace, - Name: "exporter_scrape_failures_total", - Help: "Number of errors while scraping the Nexenta API", + Namespace: namespace, + Name: "exporter_scrape_failures_total", + Help: "Number of errors while scraping the Nexenta API", + ConstLabels: prometheus.Labels{"host":*apiHost}, }), volumeOnline: prometheus.NewDesc( prometheus.BuildFQName(namespace, "volume", "online"), "Status of volume.", []string{"volume"}, - nil, + prometheus.Labels{"host":*apiHost}, ), jbodStatus: prometheus.NewDesc( prometheus.BuildFQName(namespace, "jbod", "status"), "Status of JBOD.", []string{"jbod"}, - nil, + prometheus.Labels{"host":*apiHost}, ), jbodTemp: prometheus.NewDesc( prometheus.BuildFQName(namespace, "jbod", "temp"), "Temperature of JBOD.", []string{"jbod", "name", "state"}, - nil, + prometheus.Labels{"host":*apiHost}, ), jbodVoltage: prometheus.NewDesc( prometheus.BuildFQName(namespace, "jbod", "voltage"), "Voltage of JBOD.", []string{"jbod", "name", "state"}, - nil, + prometheus.Labels{"host":*apiHost}, ), jbodSlotStatus: prometheus.NewDesc( prometheus.BuildFQName(namespace, "jbod", "slot_status"), "Status of JBOD slot.", []string{"jbod", "slot", "state"}, - nil, + prometheus.Labels{"host":*apiHost}, ), licenseDaysLeft: prometheus.NewDesc( prometheus.BuildFQName(namespace, "license", "days_left"), "License days left.", nil, - nil, + prometheus.Labels{"host":*apiHost}, ), client: &http.Client{ Transport: &http.Transport{ -- GitLab