-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Comments
Pinging @elastic/ingest-management (Team:Ingest Management) |
That should be |
Pinging @elastic/integrations-services (Team:Services) |
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. |
This was an issue that was reported through our enterprise support contract.
Obviously this is not an important issue, but it's not a good look. |
Hi! We're labeling this issue as |
The problem: The elasticsearch API does not handle double slashes (
\\
) in a consistent wayAlternative 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
, andpending_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'.
The text was updated successfully, but these errors were encountered: