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 can call Jolokia with GET requests. (#8566) #9226

Merged
merged 7 commits into from
Dec 4, 2018
Merged

Metricbeat can call Jolokia with GET requests. (#8566) #9226

merged 7 commits into from
Dec 4, 2018

Conversation

manios
Copy link
Contributor

@manios manios commented Nov 25, 2018

This pull request provides Metricbeat the option to call Jolokia using HTTP GET requests.

  • It adds a new http_method parameter to config.yml which by default will have the value POST and can accept GET as well.
  • Proxy requests are not supported.

For more information, please refer to #8566.

Thanks in advance for your time.

@elasticmachine
Copy link
Collaborator

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?

Copy link
Member

@jsoriano jsoriano left a 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.

metricbeat/module/jolokia/jmx/_meta/docs.asciidoc Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/_meta/docs.asciidoc Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/config.go Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/config.go Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/data.go Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/data.go Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/_meta/docs.asciidoc Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/_meta/docs.asciidoc Outdated Show resolved Hide resolved
metricbeat/module/jolokia/jmx/config.go Show resolved Hide resolved
@ruflin ruflin added the Team:Integrations Label for the Integrations team label Nov 27, 2018
Copy link
Member

@jsoriano jsoriano left a 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("\"", "!\"", ".", "!.", "!", "!!", "/", "!/")
Copy link
Member

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?

Copy link
Contributor Author

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! 👍

}
http.SetMethod("POST")
http.SetBody(body)
jolokiaHTTPBuild := NewJolokiaHTTPRequestBuiler(config.HTTPMethod)
Copy link
Member

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 🙂

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

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

@jsoriano
Copy link
Member

jenkins, test this please

@jsoriano
Copy link
Member

It LGTM, thanks @manios for your work on this! Let's wait for jenkins before merging.

@jsoriano
Copy link
Member

jenkins, test this again please

@jsoriano
Copy link
Member

@manios I think that the failing check in jenkins gets fixed by updating the branch with master, could you try?

@manios
Copy link
Contributor Author

manios commented Nov 30, 2018

Hi @jsoriano ! I rebased with the latest changes from master. Is it ok now? Thanks for your assistance ! 👍

@jsoriano
Copy link
Member

jenkins, test this

@manios
Copy link
Contributor Author

manios commented Nov 30, 2018

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.
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jsoriano ! Done! 👍

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@jsoriano
Copy link
Member

jsoriano commented Dec 2, 2018

jenkins, test this one last time

@jsoriano jsoriano merged commit 463ce3e into elastic:master Dec 4, 2018
jsoriano pushed a commit to jsoriano/beats that referenced this pull request Dec 4, 2018
…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)
@jsoriano
Copy link
Member

jsoriano commented Dec 4, 2018

Hi @manios, I have merged this, it was missing a changelog entry but I am adding one on #9374. This feature will probably get released on Metricbeat 6.6.0. Thanks! 🎉

@manios
Copy link
Contributor Author

manios commented Dec 4, 2018

Hi @jsoriano ! Thank you for your time and your fruitful review! I hope I can contribute more in this project! 🎉

jasontedor added a commit to jasontedor/beats that referenced this pull request Dec 4, 2018
…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)
jsoriano added a commit that referenced this pull request Dec 12, 2018
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Metricbeat Metricbeat module review Team:Integrations Label for the Integrations team v6.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants