Don't add empty healthcheck tags to consul input (#5575)

This commit is contained in:
Greg 2019-03-19 14:39:42 -06:00 committed by Daniel Nelson
parent 5e88824c15
commit 3b1ab6f362
1 changed files with 4 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"strings"
"github.com/hashicorp/consul/api"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal/tls"
"github.com/influxdata/telegraf/plugins/inputs"
@ -126,12 +127,12 @@ func (c *Consul) GatherHealthCheck(acc telegraf.Accumulator, checks []*api.Healt
for _, checkTag := range check.ServiceTags {
if c.TagDelimiter != "" {
splittedTag := strings.SplitN(checkTag, c.TagDelimiter, 2)
if len(splittedTag) == 1 {
if len(splittedTag) == 1 && checkTag != "" {
tags[checkTag] = checkTag
} else if len(splittedTag) == 2 {
} else if len(splittedTag) == 2 && splittedTag[1] != "" {
tags[splittedTag[0]] = splittedTag[1]
}
} else {
} else if checkTag != "" {
tags[checkTag] = checkTag
}
}