Skip to content

Commit

Permalink
Better implementation preventing empty tags
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelquati committed Dec 12, 2018
1 parent 925cd8f commit 048ce7e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions plugins/outputs/azure_monitor/azure_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ func hashIDWithTagKeysOnly(m telegraf.Metric) uint64 {
h.Write([]byte(m.Name()))
h.Write([]byte("\n"))
for _, tag := range m.TagList() {
if tag.Key == "" || tag.Value == "" {
continue
}

h.Write([]byte(tag.Key))
h.Write([]byte("\n"))
}
Expand All @@ -359,19 +363,12 @@ func translate(m telegraf.Metric, prefix string) (*azureMonitorMetric, error) {
continue
}

var key = tag.Key
var value = tag.Value

if key == "" {
if tag.Key == "" || tag.Value == "" {
continue
}

if value == "" {
value = "<empty>"
}

dimensionNames = append(dimensionNames, key)
dimensionValues = append(dimensionValues, value)
dimensionNames = append(dimensionNames, tag.Key)
dimensionValues = append(dimensionValues, tag.Value)
}

min, err := getFloatField(m, "min")
Expand Down

0 comments on commit 048ce7e

Please sign in to comment.