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

[aws] Fix missing metrics bug when include_linked_accounts set to false #40135

Merged

Conversation

kaiyan-sheng
Copy link
Contributor

@kaiyan-sheng kaiyan-sheng commented Jul 8, 2024

Proposed commit message

This PR is to fix a bug in cloudwatch metricbeat module when include_linked_accounts is false. Because where the wrongly put return, we are missing metrics in pagination. I also added a test for the case when there is more than one page of results from ListMetrics API.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

No disruptive user impact.

How to test this PR locally

  1. Setup your AWS account to have multiple RDS clusters and make sure we have metrics in CloudWatch.
  2. Start Metricbeat with aws.yml looks like this:
- module: aws
  period: 1m
  credential_profile_name: elastic-observability
  metricsets:
    - cloudwatch
  regions: eu-west-3
  latency: 10m
  include_linked_accounts: false
  metrics:
    - namespace: AWS/RDS
      name: ["CPUUtilization"]
      resource_type: rds
      statistic: ["Average"]

You should see metrics only being collected from 2 RDS clusters. But if you change the include_linked_accounts to true, then you will get metrics from all clusters (5 in this case).
3. Apply the changes from this PR and rebuild metricbeat locally. Run with the same aws.yml with include_linked_accounts equals to false and you should see metrics from all clusters now.
Screenshot 2024-07-08 at 12 04 59 AM

Related issues

@kaiyan-sheng kaiyan-sheng requested a review from a team as a code owner July 8, 2024 06:05
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 8, 2024
Copy link
Contributor

mergify bot commented Jul 8, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @kaiyan-sheng? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@kaiyan-sheng kaiyan-sheng added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label Jul 8, 2024
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 8, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@kaiyan-sheng kaiyan-sheng added backport-v8.14.0 Automated backport with mergify backport-8.15 Automated backport to the 8.15 branch with mergify labels Jul 8, 2024
@kaiyan-sheng kaiyan-sheng requested a review from zmoog July 8, 2024 14:12
Copy link
Contributor

@zmoog zmoog left a comment

Choose a reason for hiding this comment

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

LGTM

@kaiyan-sheng kaiyan-sheng merged commit 8da898f into elastic:main Jul 8, 2024
19 checks passed
@kaiyan-sheng kaiyan-sheng deleted the include_linked_accounts_false branch July 8, 2024 17:26
mergify bot pushed a commit that referenced this pull request Jul 8, 2024
mergify bot pushed a commit that referenced this pull request Jul 8, 2024
@kaiyan-sheng kaiyan-sheng added the backport-7.17 Automated backport to the 7.17 branch with mergify label Jul 8, 2024
mergify bot pushed a commit that referenced this pull request Jul 8, 2024
…se (#40135)

(cherry picked from commit 8da898f)

# Conflicts:
#	x-pack/metricbeat/module/aws/utils.go
#	x-pack/metricbeat/module/aws/utils_test.go
kaiyan-sheng added a commit that referenced this pull request Jul 8, 2024
…se (#40135) (#40138)

(cherry picked from commit 8da898f)

Co-authored-by: kaiyan-sheng <kaiyan.sheng@elastic.co>
kaiyan-sheng added a commit that referenced this pull request Jul 8, 2024
…nked_accounts set to false (#40137)

* [aws] Fix missing metrics bug when include_linked_accounts set to false (#40135)

(cherry picked from commit 8da898f)

* Update CHANGELOG.next.asciidoc

---------

Co-authored-by: kaiyan-sheng <kaiyan.sheng@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-7.17 Automated backport to the 7.17 branch with mergify backport-8.15 Automated backport to the 8.15 branch with mergify backport-v8.14.0 Automated backport with mergify Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aws] missing metrics when include_linked_accounts set to false
3 participants