-
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
Metricbeat can call Jolokia with GET requests. (#8566) #9226
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
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.
Thanks @manios for the great effort here! 🎉 This is looking quite good, I have added some suggestions, let me know what you think.
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.
Thanks for addressing these comments! I have added some more comments. The most important ones are that I think that the Builders
shouldn't be called Builders anymore 🙂 and that probably the event mapping functions could be methods of the "builders" directly.
|
||
// This replacer is responsible for adding a "!" before special characters in GET request URIs | ||
// For more information refer: https://jolokia.org/reference/html/protocol.html | ||
var mbeanGetEssapeReplacer = strings.NewReplacer("\"", "!\"", ".", "!.", "!", "!!", "/", "!/") |
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.
Essape
wanted to be Escape
?
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.
Hi @jsoriano ! Thanks for noticing! Fixed! 👍
metricbeat/module/jolokia/jmx/jmx.go
Outdated
} | ||
http.SetMethod("POST") | ||
http.SetBody(body) | ||
jolokiaHTTPBuild := NewJolokiaHTTPRequestBuiler(config.HTTPMethod) |
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.
This is not a builder anymore, it is a Fetcher now 🙂
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.
Hi @jsoriano ! Thanks for noticing! Renamed to interface to JolokiaHTTPRequestFetcher
and structs to JolokiaHTTPGetFetcher
and JolokiaHTTPPostFetcher
. 👍
eventMapper := NewEventMapper(httpReqs[0].HTTPMethod) | ||
|
||
// Map response to Metricbeat events | ||
events, err := eventMapper.EventMapping(resBody, mapping) |
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.
Is there any reason to don't make these EventMapping methods of JolokiaHTTPPostBuilder
and JolokiaHTTPGetBuilder
directly?
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.
Hi @jsoriano ! Indeed, there is no reason. I moved EventMapping
methods to JolokiaHTTPGetFetcher
and JolokiaHTTPPostFetcher
. 👍
jenkins, test this please |
It LGTM, thanks @manios for your work on this! Let's wait for jenkins before merging. |
jenkins, test this again please |
@manios I think that the failing check in jenkins gets fixed by updating the branch with master, could you try? |
Hi @jsoriano ! I rebased with the latest changes from master. Is it ok now? Thanks for your assistance ! 👍 |
jenkins, test this |
Jenkins tests have passed 🎉 ! |
- attr: Uptime | ||
field: uptime | ||
---- | ||
will create 3 GET requests, one for every MBean. On the contrary, if you use HTTP POST, Metricbeat will create only 1 request to Jolokia. |
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.
@manios sorry, one last minor detail here, could you move the whole description about the example before the code block? So it is something like: For example the configuration below with 3 mappings creates 3 GET requests, one for every MBean. On the contrary, if you use HTTP POST, Metricbeat creates only 1 request to Jolokia.
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.
Hi @jsoriano ! Done! 👍
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.
Thanks!
jenkins, test this one last time |
…c#9226) Add a new `http_method` parameter to Jolokia module which by default will have the value POST and can accept GET as well. Fixes elastic#8566. (cherry picked from commit 463ce3e)
Hi @jsoriano ! Thank you for your time and your fruitful review! I hope I can contribute more in this project! 🎉 |
…yslog_host * elastic/master: Metricbeat can call Jolokia with GET requests. (elastic#8566) (elastic#9226) Add some missing references to PRs in changelog (elastic#9358)
…ts. (#8566) (#9375) Add a new `http_method` parameter to Jolokia module which by default will have the value POST and can accept GET as well. Fixes #8566. (cherry picked from commit 463ce3e) Add changelog for #8566 (cherry picked from commit d434b47) Co-authored-by: Christos Manios <maniopaido@gmail.com>
This pull request provides Metricbeat the option to call Jolokia using HTTP GET requests.
http_method
parameter toconfig.yml
which by default will have the valuePOST
and can acceptGET
as well.For more information, please refer to #8566.
Thanks in advance for your time.