From ade7272a29443f2b5cdc3671014aac95d4e2985d Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Wed, 24 Jul 2013 15:53:30 +0200 Subject: [PATCH] Remove hostname label A host/port label is provided by prometheus --- exporter/gmond_collector.go | 3 +-- exporter/native_collector.go | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/exporter/gmond_collector.go b/exporter/gmond_collector.go index 1425cb93..c126f432 100644 --- a/exporter/gmond_collector.go +++ b/exporter/gmond_collector.go @@ -87,8 +87,7 @@ func (c *gmondCollector) Update() (updates int, err error) { name := strings.Replace(strings.ToLower(metric.Name), ".", "_", -1) var labels = map[string]string{ - "hostname": host.Name, - "cluster": cluster.Name, + "cluster": cluster.Name, } c.setMetric(name, labels, metric) updates++ diff --git a/exporter/native_collector.go b/exporter/native_collector.go index ead9739e..cc545ae0 100644 --- a/exporter/native_collector.go +++ b/exporter/native_collector.go @@ -6,7 +6,6 @@ import ( "github.com/prometheus/client_golang/prometheus" "io" "io/ioutil" - "os" "os/exec" "strconv" "strings" @@ -28,11 +27,6 @@ type nativeCollector struct { // Takes a config struct and prometheus registry and returns a new Collector exposing // load, seconds since last login and a list of tags as specified by config. func NewNativeCollector(config config, registry prometheus.Registry) (collector nativeCollector, err error) { - hostname, err := os.Hostname() - if err != nil { - return nativeCollector{}, fmt.Errorf("Couldn't get hostname: %s", err) - } - collector = nativeCollector{ name: "native_collector", config: config, @@ -44,21 +38,21 @@ func NewNativeCollector(config config, registry prometheus.Registry) (collector registry.Register( "node_load", "node_exporter: system load.", - map[string]string{"hostname": hostname}, + prometheus.NilLabels, collector.loadAvg, ) registry.Register( "node_last_login_seconds", "node_exporter: seconds since last login.", - map[string]string{"hostname": hostname}, + prometheus.NilLabels, collector.lastSeen, ) registry.Register( "node_attributes", "node_exporter: system attributes.", - map[string]string{"hostname": hostname}, + prometheus.NilLabels, collector.attributes, )