fix(outputs.Wavefront): If no "host" tag is provided, do not add "telegraf.host" tag (#11078)

Co-authored-by: ffaroo1 <svc-registry-github@intuit.com>
This commit is contained in:
Farukh Ali 2022-05-12 08:46:28 -07:00 committed by GitHub
parent 3c79acbd80
commit 906b24e31d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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 {