Skip to content

Commit e0246a9

Browse files
committed
cmd/scollector: fix empty host= tags not working after PR bosun-monitor#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
1 parent ac7f667 commit e0246a9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmd/scollector/collectors/collectors.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ func AddTS(md *opentsdb.MultiDataPoint, name string, ts int64, value interface{}
241241
}
242242

243243
tags := t.Copy()
244+
if host, present := tags["host"]; !present {
245+
tags["host"] = util.Hostname
246+
} else if host == "" {
247+
delete(tags, "host")
248+
}
244249
// if tags are not cleanable, log a message and skip it
245250
if err := tags.Clean(); err != nil {
246251
line := ""
@@ -256,11 +261,6 @@ func AddTS(md *opentsdb.MultiDataPoint, name string, ts int64, value interface{}
256261
slog.Errorf("Invalid tagset discovered: %s. Skipping datapoint. Added from: %s", tags.String(), line)
257262
return
258263
}
259-
if host, present := tags["host"]; !present {
260-
tags["host"] = util.Hostname
261-
} else if host == "" {
262-
delete(tags, "host")
263-
}
264264
if rate != metadata.Unknown {
265265
metadata.AddMeta(name, nil, "rate", rate, false)
266266
}

0 commit comments

Comments
 (0)