Remove hostname label

A host/port label is provided by prometheus
This commit is contained in:
Johannes 'fish' Ziemke 2013-07-24 15:53:30 +02:00
parent cbd350a381
commit ade7272a29
2 changed files with 4 additions and 11 deletions

View File

@ -87,8 +87,7 @@ func (c *gmondCollector) Update() (updates int, err error) {
name := strings.Replace(strings.ToLower(metric.Name), ".", "_", -1) name := strings.Replace(strings.ToLower(metric.Name), ".", "_", -1)
var labels = map[string]string{ var labels = map[string]string{
"hostname": host.Name, "cluster": cluster.Name,
"cluster": cluster.Name,
} }
c.setMetric(name, labels, metric) c.setMetric(name, labels, metric)
updates++ updates++

View File

@ -6,7 +6,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"io" "io"
"io/ioutil" "io/ioutil"
"os"
"os/exec" "os/exec"
"strconv" "strconv"
"strings" "strings"
@ -28,11 +27,6 @@ type nativeCollector struct {
// Takes a config struct and prometheus registry and returns a new Collector exposing // 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. // 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) { 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{ collector = nativeCollector{
name: "native_collector", name: "native_collector",
config: config, config: config,
@ -44,21 +38,21 @@ func NewNativeCollector(config config, registry prometheus.Registry) (collector
registry.Register( registry.Register(
"node_load", "node_load",
"node_exporter: system load.", "node_exporter: system load.",
map[string]string{"hostname": hostname}, prometheus.NilLabels,
collector.loadAvg, collector.loadAvg,
) )
registry.Register( registry.Register(
"node_last_login_seconds", "node_last_login_seconds",
"node_exporter: seconds since last login.", "node_exporter: seconds since last login.",
map[string]string{"hostname": hostname}, prometheus.NilLabels,
collector.lastSeen, collector.lastSeen,
) )
registry.Register( registry.Register(
"node_attributes", "node_attributes",
"node_exporter: system attributes.", "node_exporter: system attributes.",
map[string]string{"hostname": hostname}, prometheus.NilLabels,
collector.attributes, collector.attributes,
) )