Skip to content

Commit 906b24e

Browse files
farukhaliffaroo1
andauthored
fix(outputs.Wavefront): If no "host" tag is provided, do not add "telegraf.host" tag (#11078)
Co-authored-by: ffaroo1 <[email protected]>
1 parent 3c79acb commit 906b24e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

plugins/outputs/wavefront/wavefront.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ func (w *Wavefront) buildTags(mTags map[string]string) (string, map[string]strin
190190
for k, v := range mTags {
191191
if k == s {
192192
source = v
193-
mTags["telegraf_host"] = mTags["host"]
193+
if mTags["host"] != "" {
194+
mTags["telegraf_host"] = mTags["host"]
195+
}
196+
194197
sourceTagFound = true
195198
delete(mTags, k)
196199
break

plugins/outputs/wavefront/wavefront_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ func TestBuildTagsWithSource(t *testing.T) {
243243
"r-@l\"Ho/st",
244244
map[string]string{"something": "abc"},
245245
},
246+
{
247+
map[string]string{"hostagent": "realHost", "env": "qa", "tag": "val"},
248+
"realHost",
249+
map[string]string{"env": "qa", "tag": "val"},
250+
},
246251
}
247252

248253
for _, tt := range tagtests {

0 commit comments

Comments
 (0)