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

API handles double slash inconsistently #18084

Closed
damianpfister opened this issue Apr 29, 2020 · 6 comments
Closed

API handles double slash inconsistently #18084

damianpfister opened this issue Apr 29, 2020 · 6 comments
Labels

Comments

@damianpfister
Copy link
Contributor

  • The problem: The elasticsearch API does not handle double slashes (\\) in a consistent way

  • Alternative problem: The metricbeat elasticsearch module does not check for a double slash prior to calling the API

  • How did we get here:

    I'm setting up monitoring for a cluster using the elasticsearch module in metricbeat. Despite having done everything like correctly, I could not get the node, node_stats, and pending_tasks metricsets to work. They would all report an error message: 401 Unauthorized.

    Obviously, the user configured in metricbeat is lacking some permissions, right? So I lost a good deal of my sanity trying to configure permissions to no avail.

    I had a look at the module source code to see what API endpoint the different metric sets were hitting. As soon as I saw that node was hitting /_nodes/_local I had a suspicion. Pretty sure I configured an ending / in my host config.

    When I log in the browser with the same username and password and hit /_nodes/_local it works. But when I hit //_nodes/_local (note the double slash) I get an unauthorized error.
    The index metric set on the other hand (as an example) hits /_stats/docs?filter_path=indices. And when I hit //_stats/docs?filter_path=indices it's just as happy to give me the same response.

    So, to conclude, if one has a typo which adds a trailing slash in the metricbeat elasticsearch module host config, the API endpoints that are called end up having a double slash in them (//).
    Where it gets confusing is that the API will sometimes answer to such a malformed URL in the same way as if one where to hit the correct URL, yet for some endpoints it will give you an unauthorized error.

    This inconsistent behavior of the API makes it difficult to troubleshoot things. I certainly was convinced it was a permissions problem because some metricsets worked while others do not.

    This doesn't seem to be the first time double slashes cause problems. A quick search revealed:

    Avoid double slash when join url and path (#5503) #5517
    Windows paths in List Format result in: "found unknown escape character. Exiting." or "found unexpected ':'. Exiting." #1495
    ES URL with Trailing Slash Causes Exception #5503

    as such, it might also be a good idea to update the elasticsearch module in metricbeat and have it strip out the trailing slash so that things 'just work'.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 29, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 29, 2020
@joostdecock
Copy link
Contributor

API does not handle double slashes (\\) in a consistent way

That should be // instead of \\

@andresrc andresrc added the Team:Services (Deprecated) Label for the former Integrations-Services team label May 9, 2020
@elasticmachine
Copy link
Collaborator

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

@botelastic
Copy link

botelastic bot commented Apr 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@botelastic botelastic bot added the Stalled label Apr 11, 2021
@botelastic botelastic bot closed this as completed May 11, 2021
@zube zube bot removed the [zube]: Done label Aug 10, 2021
@joostdecock
Copy link
Contributor

This was an issue that was reported through our enterprise support contract.
The result of which is:

  • Support creates an issue here
  • Issue goes stale
  • Issue gets closed

Obviously this is not an important issue, but it's not a good look.

cc @damianpfister

@andresrc andresrc added Team:Integrations Label for the Integrations team and removed v7.6.0 Stalled Team:Services (Deprecated) Label for the former Integrations-Services team labels Sep 9, 2021
@andresrc andresrc reopened this Sep 9, 2021
@botelastic
Copy link

botelastic bot commented Sep 9, 2022

Hi!
We just realized that we haven't looked into this issue in a while. We're sorry!

We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1.
Thank you for your contribution!

@botelastic botelastic bot added the Stalled label Sep 9, 2022
@botelastic botelastic bot closed this as completed Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants