From a091ddc2ff82be3d25b14041f4912cfa7f665df3 Mon Sep 17 00:00:00 2001 From: Raphael Couto Date: Tue, 4 Dec 2018 12:08:24 -0200 Subject: [PATCH 1/3] Fix translate empty tag values --- plugins/outputs/azure_monitor/azure_monitor.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/outputs/azure_monitor/azure_monitor.go b/plugins/outputs/azure_monitor/azure_monitor.go index 5c435ac0dbb9b..8da430b25ed89 100644 --- a/plugins/outputs/azure_monitor/azure_monitor.go +++ b/plugins/outputs/azure_monitor/azure_monitor.go @@ -359,10 +359,17 @@ func translate(m telegraf.Metric, prefix string) (*azureMonitorMetric, error) { continue } - if tag.Key == "" || tag.Value == "" { + var key = tag.Key + var value = tag.Value + + if key == "" { continue } + if value == "" { + value = "" + } + dimensionNames = append(dimensionNames, tag.Key) dimensionValues = append(dimensionValues, tag.Value) } From 925cd8f53953d6a87a12227110a27d038b6e5f20 Mon Sep 17 00:00:00 2001 From: Raphael Couto Date: Thu, 6 Dec 2018 14:46:48 -0200 Subject: [PATCH 2/3] Fix typo --- plugins/outputs/azure_monitor/azure_monitor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/outputs/azure_monitor/azure_monitor.go b/plugins/outputs/azure_monitor/azure_monitor.go index 8da430b25ed89..7e817e0a47f2d 100644 --- a/plugins/outputs/azure_monitor/azure_monitor.go +++ b/plugins/outputs/azure_monitor/azure_monitor.go @@ -370,8 +370,8 @@ func translate(m telegraf.Metric, prefix string) (*azureMonitorMetric, error) { value = "" } - dimensionNames = append(dimensionNames, tag.Key) - dimensionValues = append(dimensionValues, tag.Value) + dimensionNames = append(dimensionNames, key) + dimensionValues = append(dimensionValues, value) } min, err := getFloatField(m, "min") From 048ce7ec38e4f3985109ced11f0b6814faedac40 Mon Sep 17 00:00:00 2001 From: Raphael Couto Date: Wed, 12 Dec 2018 01:49:12 -0200 Subject: [PATCH 3/3] Better implementation preventing empty tags --- plugins/outputs/azure_monitor/azure_monitor.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/plugins/outputs/azure_monitor/azure_monitor.go b/plugins/outputs/azure_monitor/azure_monitor.go index 7e817e0a47f2d..e52d66b991d9b 100644 --- a/plugins/outputs/azure_monitor/azure_monitor.go +++ b/plugins/outputs/azure_monitor/azure_monitor.go @@ -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")) } @@ -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 = "" - } - - dimensionNames = append(dimensionNames, key) - dimensionValues = append(dimensionValues, value) + dimensionNames = append(dimensionNames, tag.Key) + dimensionValues = append(dimensionValues, tag.Value) } min, err := getFloatField(m, "min")