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) }