-
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
Fix: don't miss address scheme #16205
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
metricbeat/mb/testdata/lightmodules/httpextended/extends/manifest.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
default: true | ||
input: | ||
module: http | ||
metricset: json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: httpextended | ||
metricsets: | ||
- extends |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take into account that there can be hosts that don't parse as urls, like some formats for MySQL or PostgreSQL, or in general any metricset that uses a custom host parser, or the
PassThruHostParser
.At this point of the code we only want to parse hosts with the
HostParser
, and we should parse the original setting in the configuration, doesn'tbase.host
contain it? 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, all tests passed here unless I missed something. What I want to do I fix the issue while using
http
module as base one, so if you know any different workaround, it would be great.Without this change
base.host
contained stripped address (e.g. https://ceph-restful:8003 -> ceph-restful:8003,http
module picked it up as defaulthttp://
).@jsoriano do you suggest to fallback to base.host in case of err here (line 89)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I guess that there are no tests for light modules with configured hosts that cannot be parsed by
url.Parse
🙁 Each metricset can implement its own host parser, for their own host strings. We shouldn't assume that they are URLs in all cases.Yes, I see the problem, actually this call to
HostParser
in this override for light modules was also motivated by some http service. In that moment the problem was that thequery
defined in a manifest was not being considered, because this is added in theURLHostParserBuilder
(same parser as the one used inhttp
module).I don't know of any workaround at the moment.
I mean that in the call to
HostParser
we should use the same host (or an equivalent one) to the one in the configuration file. I was wondering ifbase.host
would contain it, but I see now thatbase.host
is modified in the first call to theHostParser
inmetricbeat/mb/builders.go
.Maybe we can try using
base.hostData.URI
, the URI there should be the complete host.But I am not sure if all hosts parsers actually maintain the complete host.
Other possible source to get the original source is
base.module.Config().Hosts
, but this can contain all the hosts configured in a module and we may don't know which one is the one for the current metricset.Maybe we need to keep the original host in some other field in the
BaseMetricSet
(apart fromhost
that gets modified by some host parsers).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, let's do this change, but keeping previous behaviour for hosts that don't parse as URLs. We will think further in other possible cases where this host parser override won't work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsoriano Thanks, fixed!