Skip to content

Commit

Permalink
Cherry-pick #14525 to 7.5: [Metricbeat] Check length of the slice ins…
Browse files Browse the repository at this point in the history
…tead of comparing with nil in cloudwatch (#14538)

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

* Check length of the slice instead of comparing with nil

(cherry picked from commit 8dce4b1)

* Fix changelog
  • Loading branch information
kaiyan-sheng authored Nov 15, 2019
1 parent c003d65 commit 69bcf67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Metricbeat*

- 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 && len(resourceTagMap) == 0 {
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 && len(tags) == 0 {
continue
}

Expand Down

0 comments on commit 69bcf67

Please sign in to comment.