Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix translate empty tag values #5083

Merged
merged 3 commits into from
Dec 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion plugins/outputs/azure_monitor/azure_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<empty>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can dimensions be added with the value as the empty string instead of using a placeholder value?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can't have empty strings at all, I'd like to try this instead:

diff --git a/plugins/outputs/azure_monitor/azure_monitor.go b/plugins/outputs/azure_monitor/azure_monitor.go
index 5c435ac0..1c933072 100644
--- a/plugins/outputs/azure_monitor/azure_monitor.go
+++ b/plugins/outputs/azure_monitor/azure_monitor.go
@@ -340,6 +340,9 @@ 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"))
        }

Copy link
Contributor Author

@raphaelquati raphaelquati Dec 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. this implementation is better. I've tested here with success.
image

}

dimensionNames = append(dimensionNames, tag.Key)
dimensionValues = append(dimensionValues, tag.Value)
}
Expand Down