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] gcp: refactor service based metric filter creation #26973

Merged

Conversation

endorama
Copy link
Member

@endorama endorama commented Jul 20, 2021

What does this PR do?

metricsRequester.getFilterForMetric was using a regexp logic to
extract the service name from the metric name.

The service name is used to adapt the metric filter creation based on
the service the metric belongs to, as different services require
different filters and some are not supported.

With the changes required to supporting GKE, that has a different metric
prefix than other Google Cloud metrics, the logic was broken, creating a
filter that was always returning an empty metric set.

This commit change the logic to rely on metricsConfig.ServiceName
instead, removing the inference on the metric name.

Why is it important?

The implemented Regexp inference on the metric name does not work when the metric prefix is not in the form <servicename>.googleapis.com. This prevent adding metricsets not related to Google Cloud metrics.

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.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Scenario: add new metricsets to gcp module

	As a gcp Beat module developer
	Given I want to add a metricset not related to "Google Cloud" metrics
	Then I may need to control the metric filter creation logic

Screenshots

Logs

`metricsRequester.getFilterForMetric` was using a regexp logic to
extract the service name from the metric name.

The service name is used to adapt the metric filter creation based on
the service the metric belongs to, as different services require
different filters and some are not supported.

With the changes required to supporting GKE, that has a different metric
prefix than other Google Cloud metrics, the logic was broken, creating a
filter that was always returning an empty metric set.

This commit change the logic to rely on `metricsConfig.ServiceName`
instead, removing the inference on the metric name.
@endorama endorama added enhancement Team:Integrations Label for the Integrations team backport-v7.15.0 Automated backport with mergify labels Jul 20, 2021
@endorama endorama requested a review from sayden July 20, 2021 09:08
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jul 20, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 20, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-07-20T09:29:56.961+0000

  • Duration: 66 min 26 sec

  • Commit: 59b3c71

Test stats 🧪

Test Results
Failed 0
Passed 2512
Skipped 288
Total 2800

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 2512
Skipped 288
Total 2800

@endorama endorama changed the title gcp: refactor service based metric filter creation [Metricbeat] gcp: refactor service based metric filter creation Jul 20, 2021
@endorama endorama merged commit e1185e4 into elastic:master Jul 21, 2021
@endorama endorama deleted the gcp-refactor-service-filter-switch-logic branch July 21, 2021 13:07
mergify bot pushed a commit that referenced this pull request Jul 21, 2021
endorama added a commit that referenced this pull request Jul 21, 2021
…c filter creation (#27001)

Backport for #26973

Co-authored-by: endorama <526307+endorama@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.15.0 Automated backport with mergify enhancement Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants