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][Azure]Check for metrics dimensions before matching two metrics together #42591

Conversation

MichaelKatsoulis
Copy link
Contributor

Proposed commit message

  • WHAT: Check for metrics dimensions before matching two metrics together in azure module.
  • WHY: Metric definitions are matched although they may contain different dimensions, leading to documents with <empty> value in ES

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

There will no longer be documents with empty value in its dimensions in ES. But this was a bug.

How to test this PR locally

Deploy metricbeat with azure module before and after the PR and set the following configuration for azure.yaml.
Set the right client_id, client_secret, tenant_id and subscription_id.

- module: azure
  metricsets:
  - storage
  enabled: true
  resources:
    - resource_group: ["mbranca-general"]
  period: 300s
  client_id: ''
  client_secret: ''
  tenant_id: ''
  subscription_id: ''
  refresh_list_interval: 600s

Related issues

Use cases

Screenshots

Before the PR. Version 8.17.0. Storage accounts.

8 17

After the PR:

pr-screenshot

Before the PR. Values of azure.dimensions.authentication

pt5m-authetication-8 17

After the PR. Values of azure.dimensions.authentication

pt5m-authentication-pr

Before the PR. Values of azure.dimensions.tier

PT1H-tier-8 17

After the PR. Values of azure.dimensions.tier

pt1h-tier-PR

@MichaelKatsoulis MichaelKatsoulis requested a review from a team as a code owner February 4, 2025 13:50
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Feb 4, 2025
@MichaelKatsoulis MichaelKatsoulis added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label Feb 4, 2025
@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Feb 4, 2025
Copy link
Contributor

mergify bot commented Feb 4, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @MichaelKatsoulis? 🙏.
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-8./d is the label to automatically backport to the 8./d branch. /d is the digit

@MichaelKatsoulis MichaelKatsoulis added the backport-8.x Automated backport to the 8.x branch with mergify label Feb 4, 2025
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.

Comparing metric definitions without taking dimensions into account seems incorrect.

Here's an example where, running the code on main, the matchMetrics() function returns true even when the two definitions have different dimensions:

image

While testing, I noticed that the docs with <empty> dimension sometimes contain the sum of the non-<empty> dimension values.

However, I also found documents where the value for <empty> dimensions seemed not to have any relation with others. Possibly a random assignment due to the incomplete comparison.

image

I would only suggest adding a test case similar to https://github.com/lastic/beats/blob/71900c4d89fa3b29f8709bb46a61a9ad78a1e9c2/x-pack/metricbeat/module/azure/client_utils_test.go#L61-L85

So we can prove and document the behavior using different dimensions.

LGTM, thank you for taking the time to dive deeper in this issue!

@MichaelKatsoulis MichaelKatsoulis enabled auto-merge (squash) February 6, 2025 08:20
@MichaelKatsoulis
Copy link
Contributor Author

/test

@MichaelKatsoulis MichaelKatsoulis added backport-8.18 Automated backport to the 8.18 branch backport-9.0 Automated backport to the 9.0 branch backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches and removed backport-9.0 Automated backport to the 9.0 branch labels Feb 6, 2025
@MichaelKatsoulis MichaelKatsoulis merged commit d9f5498 into elastic:main Feb 6, 2025
18 of 21 checks passed
mergify bot pushed a commit that referenced this pull request Feb 6, 2025
…etrics together (#42591)

* Check for metrics dimensions before matching two metrics together

* Add test case for metrics with different dimensions

(cherry picked from commit d9f5498)
mergify bot pushed a commit that referenced this pull request Feb 6, 2025
…etrics together (#42591)

* Check for metrics dimensions before matching two metrics together

* Add test case for metrics with different dimensions

(cherry picked from commit d9f5498)
mergify bot pushed a commit that referenced this pull request Feb 6, 2025
…etrics together (#42591)

* Check for metrics dimensions before matching two metrics together

* Add test case for metrics with different dimensions

(cherry picked from commit d9f5498)
MichaelKatsoulis added a commit that referenced this pull request Feb 6, 2025
…etrics together (#42591) (#42620)

* Check for metrics dimensions before matching two metrics together

* Add test case for metrics with different dimensions

(cherry picked from commit d9f5498)

Co-authored-by: Michalis Katsoulis <[email protected]>
MichaelKatsoulis added a commit that referenced this pull request Feb 6, 2025
…etrics together (#42591) (#42621)

* Check for metrics dimensions before matching two metrics together

* Add test case for metrics with different dimensions

(cherry picked from commit d9f5498)

Co-authored-by: Michalis Katsoulis <[email protected]>
MichaelKatsoulis added a commit that referenced this pull request Feb 6, 2025
…etrics together (#42591) (#42622)

* Check for metrics dimensions before matching two metrics together

* Add test case for metrics with different dimensions

(cherry picked from commit d9f5498)

Co-authored-by: Michalis Katsoulis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify backport-8.18 Automated backport to the 8.18 branch backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches bugfix 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.

[Azure monitor] Metric values are not mapped to the correct metric definition
3 participants