Skip to content

Commit

Permalink
fix(outputs.Wavefront): If no "host" tag is provided, do not add "tel…
Browse files Browse the repository at this point in the history
…egraf.host" tag (#11078)

Co-authored-by: ffaroo1 <svc-registry-github@intuit.com>
  • Loading branch information
farukhali and ffaroo1 committed May 12, 2022
1 parent 3c79acb commit 906b24e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/outputs/wavefront/wavefront.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ func (w *Wavefront) buildTags(mTags map[string]string) (string, map[string]strin
for k, v := range mTags {
if k == s {
source = v
mTags["telegraf_host"] = mTags["host"]
if mTags["host"] != "" {
mTags["telegraf_host"] = mTags["host"]
}

sourceTagFound = true
delete(mTags, k)
break
Expand Down
5 changes: 5 additions & 0 deletions plugins/outputs/wavefront/wavefront_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ func TestBuildTagsWithSource(t *testing.T) {
"r-@l\"Ho/st",
map[string]string{"something": "abc"},
},
{
map[string]string{"hostagent": "realHost", "env": "qa", "tag": "val"},
"realHost",
map[string]string{"env": "qa", "tag": "val"},
},
}

for _, tt := range tagtests {
Expand Down

0 comments on commit 906b24e

Please sign in to comment.