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] support basepath in beat module #28162

Merged
merged 2 commits into from
Sep 29, 2021

Conversation

stuartnelson3
Copy link
Contributor

@stuartnelson3 stuartnelson3 commented Sep 28, 2021

What does this PR do?

Support basepath in the beat module, as per the documentation

Why is it important?

This is expected behavior, and it's documented as being supported.

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.

How to test this PR locally

Related issues

@stuartnelson3 stuartnelson3 requested a review from a team September 28, 2021 15:32
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 28, 2021
@mergify
Copy link
Contributor

mergify bot commented Sep 28, 2021

This pull request does not have a backport label. Could you fix it @stuartnelson3? 🙏
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 Sep 28, 2021
@stuartnelson3 stuartnelson3 added backport-v7.16.0 Automated backport with mergify Team:Observability and removed backport-skip Skip notification from the automated backport with mergify labels Sep 28, 2021
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 28, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 28, 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-09-28T15:33:39.144+0000

  • Duration: 92 min 36 sec

  • Commit: 8893ad7

Test stats 🧪

Test Results
Failed 0
Passed 9145
Skipped 2413
Total 11558

💚 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.

@stuartnelson3 stuartnelson3 requested review from a team and removed request for a team September 28, 2021 15:48
Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

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

LGTM - but let's wait for someone from the agent team to review.

@sayden
Copy link
Contributor

sayden commented Sep 29, 2021

Hi 🙂

This is a screencapture from Wireshark of Beat module in the current state (master) without PR.

image

And this is my Beat config:

# Module: beat
# Docs: https://www.elastic.co/guide/en/beats/metricbeat/master/metricbeat-module-beat.html

- module: beat
  basepath: "/processes/metricbeat-default"
  metricsets:
    - stats
    - state
  period: 10s
  hosts: ["http://localhost:5066"]

Are we talking about the same thing? Because it seems to me that it's working as expected 🙂

@stuartnelson3
Copy link
Contributor Author

That is what we're talking about, but it contradicts what I found when adding some logging (see #28159), and the tests I wrote confirm the original behavior strips the basepath, as well.

Check your wireshark capture further, I'm guessing there are also requests sent to localhost:5066 and localhost:5066/state.

Once I implemented my changes, it was successfully scraping the basepath and no longer 404'ing.

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.

Jeeezzz I was getting crazy because I really couldn't see anything wrong on wireshark but I now have seen in the code a second call.

My test wasn't trying that call because I was already getting the 404 so the code-path was unreachable. Just because I was lazy to setup an nginx.

Good catch! Thank you for the explanation and the contribution. I leave you the "honor" of merging 😄

@stuartnelson3 stuartnelson3 merged commit dda5848 into elastic:master Sep 29, 2021
@stuartnelson3 stuartnelson3 deleted the mb-respect-basepath branch September 29, 2021 08:45
mergify bot pushed a commit that referenced this pull request Sep 29, 2021
(cherry picked from commit dda5848)

# Conflicts:
#	metricbeat/module/beat/beat_test.go
stuartnelson3 added a commit that referenced this pull request Sep 29, 2021
…28179)

* [metricbeat] support basepath in beat module (#28162)

(cherry picked from commit dda5848)

# Conflicts:
#	metricbeat/module/beat/beat_test.go

* split out internal and external package tests

Co-authored-by: stuart nelson <stuartnelson3@gmail.com>
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[metricbeat] basepath ignored/erased in beat module
4 participants