Skip to content

Commit 2f13b28

Browse files
glintonbitcharmer
authored andcommitted
Don't add empty healthcheck tags to consul input (influxdata#5575)
1 parent a71cbfe commit 2f13b28

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

plugins/inputs/consul/consul.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66

77
"github.com/hashicorp/consul/api"
8+
89
"github.com/influxdata/telegraf"
910
"github.com/influxdata/telegraf/internal/tls"
1011
"github.com/influxdata/telegraf/plugins/inputs"
@@ -126,12 +127,12 @@ func (c *Consul) GatherHealthCheck(acc telegraf.Accumulator, checks []*api.Healt
126127
for _, checkTag := range check.ServiceTags {
127128
if c.TagDelimiter != "" {
128129
splittedTag := strings.SplitN(checkTag, c.TagDelimiter, 2)
129-
if len(splittedTag) == 1 {
130+
if len(splittedTag) == 1 && checkTag != "" {
130131
tags[checkTag] = checkTag
131-
} else if len(splittedTag) == 2 {
132+
} else if len(splittedTag) == 2 && splittedTag[1] != "" {
132133
tags[splittedTag[0]] = splittedTag[1]
133134
}
134-
} else {
135+
} else if checkTag != "" {
135136
tags[checkTag] = checkTag
136137
}
137138
}

0 commit comments

Comments
 (0)