From e0246a9aab26bb78061c49c4842fcfa29fcf89d6 Mon Sep 17 00:00:00 2001 From: Greg Bray Date: Mon, 15 Aug 2016 20:56:20 -0600 Subject: [PATCH] cmd/scollector: fix empty host= tags not working after PR #1856 The add function in cmd/scollector/collectors/collectors.go uses host= to indicate that tag should be omitted See https://github.com/bosun-monitor/bosun/blob/ac7f667fa1e649b877b77bfab7f2a643f5d8e615/cmd/scollector/collectors/collectors.go#L292 --- cmd/scollector/collectors/collectors.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/scollector/collectors/collectors.go b/cmd/scollector/collectors/collectors.go index c21e5ea90e..576505a199 100644 --- a/cmd/scollector/collectors/collectors.go +++ b/cmd/scollector/collectors/collectors.go @@ -241,6 +241,11 @@ func AddTS(md *opentsdb.MultiDataPoint, name string, ts int64, value interface{} } tags := t.Copy() + if host, present := tags["host"]; !present { + tags["host"] = util.Hostname + } else if host == "" { + delete(tags, "host") + } // if tags are not cleanable, log a message and skip it if err := tags.Clean(); err != nil { line := "" @@ -256,11 +261,6 @@ func AddTS(md *opentsdb.MultiDataPoint, name string, ts int64, value interface{} slog.Errorf("Invalid tagset discovered: %s. Skipping datapoint. Added from: %s", tags.String(), line) return } - if host, present := tags["host"]; !present { - tags["host"] = util.Hostname - } else if host == "" { - delete(tags, "host") - } if rate != metadata.Unknown { metadata.AddMeta(name, nil, "rate", rate, false) }