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] Kibana/stats set exclude_usage=true in the init phase #29911

Closed

Conversation

afharo
Copy link
Member

@afharo afharo commented Jan 19, 2022

What does this PR do?

It moves the full URL generation to the init phase for the Kibana-stats collection module.

Why is it important?

Since m.isUsageExcludable is calculated in the init phase, I think that it's not necessary to overwrite it on every fetch.

Also, because of the previous defer statement, when building the event later on, it showed the original URL instead of the one actually performed (including &exclude_usage=true).
image

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [x] I have made corresponding changes to the documentation
    - [x] 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

  • Q to the beats maintainers (as a Go NOOB): do we call the init method multiple times? Can this be an issue when calling the GetVersion method?

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@afharo afharo added the cleanup label Jan 19, 2022
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jan 19, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 19, 2022

This pull request does not have a backport label. Could you fix it @afharo? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Jan 19, 2022
@afharo afharo added Metricbeat Metricbeat Feature:Stack Monitoring Team:Services (Deprecated) Label for the former Integrations-Services team labels Jan 19, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jan 19, 2022
@afharo afharo added backport-v8.1.0 Automated backport with mergify backport-v8.2.0 Automated backport with mergify backport-v8.3.0 Automated backport with mergify labels Jan 19, 2022
@mergify mergify bot removed the backport-skip Skip notification from the automated backport with mergify label Jan 19, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 19, 2022

💚 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: 2022-01-20T09:00:21.579+0000

  • Duration: 82 min 53 sec

  • Commit: 4e54607

Test stats 🧪

Test Results
Failed 0
Passed 9412
Skipped 2423
Total 11835

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@afharo afharo marked this pull request as ready for review January 20, 2022 09:02
@elasticmachine
Copy link
Collaborator

Pinging @elastic/stack-monitoring (Stack monitoring)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

Copy link
Contributor

@matschaffer matschaffer left a comment

Choose a reason for hiding this comment

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

Makes sense to me! Maybe good to get @sayden to weigh-in

Copy link
Contributor

@sayden sayden left a comment

Choose a reason for hiding this comment

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

Please, double check the thing I commented. I also suggest to test with both metricsets at the same time, again, just to double check. Every metricset uses a different http client based on the metricset but I'd prefer to confirm this before the storm of SDH's appear.

// Add exclude_usage=true if the Kibana Version supports it
if kibana.IsUsageExcludable(kibanaVersion) {
origURI := statsHTTP.GetURI()
statsHTTP.SetURI(origURI + "&exclude_usage=true")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll double check this change. The code in this part is definitely obscure but if the defer statement is deleted here, it might be the case that the uri will be &exclude_usage=true&exclude_usage=true&exclude_usage=true after 3 periods.

Copy link
Member Author

Choose a reason for hiding this comment

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

it makes perfect sense! Is there any documentation I can use to run this PR? Or any artifacts generated during CI that I can use to test?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope sorry, you'll have to do a go build and setup everything 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

oh wait you can use https://github.com/elastic/elastic-package to spin up the entire environment and then use go build with your code.

Copy link
Member Author

@afharo afharo Feb 2, 2022

Choose a reason for hiding this comment

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

@sayden I spent a while trying to test it locally, but I'm on an M1 Mac now and there's a library that is no-longer compatible. I'd appreciate some help when you have some time 😇

Copy link
Contributor

Choose a reason for hiding this comment

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

I have just seen this. I'll do a try asap

@mergify
Copy link
Contributor

mergify bot commented Feb 1, 2022

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b metricbeat/kibana/stats/exclude_usage upstream/metricbeat/kibana/stats/exclude_usage
git merge upstream/master
git push upstream metricbeat/kibana/stats/exclude_usage

@mergify mergify bot assigned afharo Feb 8, 2022
@jlind23
Copy link
Collaborator

jlind23 commented Mar 31, 2022

@sayden @matschaffer what should we do with this PR?

@sayden
Copy link
Contributor

sayden commented Apr 1, 2022

@klacabane you should be aware of this

@matschaffer
Copy link
Contributor

I opened #31118 to have this reviewed and possibly merged.

@matschaffer matschaffer self-requested a review April 4, 2022 04:36
@mergify mergify bot assigned afharo Apr 4, 2022
@matschaffer matschaffer requested review from matschaffer and removed request for matschaffer April 5, 2022 00:44
@afharo
Copy link
Member Author

afharo commented Apr 6, 2022

Closing in favour of the new approach discussed in #31118.

@afharo afharo closed this Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.1.0 Automated backport with mergify backport-v8.2.0 Automated backport with mergify backport-v8.3.0 Automated backport with mergify cleanup Feature:Stack Monitoring Metricbeat Metricbeat Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants