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

[Metricbeat] Check length of the slice instead of comparing with nil in cloudwatch #14525

Merged
merged 4 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Update azure configuration example. {issue}14224[14224]
- Fix cloudwatch metricset with names and dimensions in config. {issue}14376[14376] {pull}14391[14391]
- Fix marshaling of ms-since-epoch values in `elasticsearch/cluster_stats` metricset. {pull}14378[14378]
- Fix checking tagsFilter using length in cloudwatch metricset. {pull}14525[14525]

*Packetbeat*

Expand Down
6 changes: 3 additions & 3 deletions x-pack/metricbeat/module/aws/cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func (m *MetricSet) createEvents(svcCloudwatch cloudwatchiface.ClientAPI, svcRes
m.Logger().Info(errors.Wrap(err, "getResourcesTags failed, skipping region "+regionName))
}

if tagsFilter != nil && resourceTagMap == nil {
if len(tagsFilter) != 0 && resourceTagMap == nil {
continue
}

Expand All @@ -472,7 +472,7 @@ func (m *MetricSet) createEvents(svcCloudwatch cloudwatchiface.ClientAPI, svcRes
labels := strings.Split(*output.Label, labelSeperator)
if len(labels) != 5 {
// if there is no tag in labels but there is a tagsFilter, then no event should be reported.
if tagsFilter != nil {
if len(tagsFilter) != 0 {
continue
}
eventNew := aws.InitEvent(regionName, m.AccountName, m.AccountID)
Expand All @@ -483,7 +483,7 @@ func (m *MetricSet) createEvents(svcCloudwatch cloudwatchiface.ClientAPI, svcRes

identifierValue := labels[identifierValueIdx]
tags := resourceTagMap[identifierValue]
if tagsFilter != nil && tags == nil {
if len(tagsFilter) != 0 && tags == nil {
continue
}

Expand Down