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: Canonicalize MBean names in Jolokia module #7321

Merged
merged 1 commit into from
Jun 18, 2018

Conversation

jsoriano
Copy link
Member

We were setting the canonicalNaming option to false in requests to
Jolokia, assuming that it should leave MBean names in responses as they
are. We need MBeans in request and in responses to be the same for
mappings to work.

But in some scenarios, as when using wildcards, Jolokia is responding with
canonicalized names, what breaks mappings.

This change canonicalizes names from config only for mappings and the
pre-built request. If we see that after setting canonicalNaming to true
there is some scenario in which Jolokia replies with non-canonicalized
names, then we'd have to canonicalize also MBeans for responses, or rethink
how we do the mapping.

@jsoriano jsoriano added module review Metricbeat Metricbeat needs_backport PR is waiting to be backported to other branches. v6.3.1 labels Jun 13, 2018
@jsoriano jsoriano force-pushed the jolokia-wildcard-canonical-names branch from c2374dd to a84cbbf Compare June 13, 2018 18:05
@jsoriano
Copy link
Member Author

jenkins, test this again, please

return errors.Errorf("metric key '%v' for mbean '%s' not found in mapping (%+v)", attributeName, requestMbeanName, mapping)
// This shouldn't ever happen, if it does it is probably that some of our
// assumptions when building the request and the mapping is wrong.
logp.Debug("jolokia.jmx", fmt.Sprintf("mapping: %+v", mapping))
Copy link
Member

Choose a reason for hiding this comment

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

you don't need the fmt.Sprintf part here, you can write:

logp.Debug("jolokia.jmx", "mapping: %+v", mapping)

Copy link
Contributor

Choose a reason for hiding this comment

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

Or you can use Debugw with a the structured logger with a "jolokia" context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Much better without Sprintf yes, thanks :)

We were setting the `canonicalNaming` option to `false` in requests to
Jolokia, assuming that it should leave MBean names in responses as they
are. We need that for mappings to work.

But in some scenarios, as when using wildcards, Jolokia is responding with
canonicalized names, what breaks mappings.

This change canonicalizes names from config only for mappings and the
pre-built request. If we see that after setting `canonicalNaming` to `true`
there is some scenario in which Jolokia replies with non-canonicalized
names, then we'd have to canonicalize also MBeans for responses, or rethink
how we do the mapping.
@jsoriano jsoriano force-pushed the jolokia-wildcard-canonical-names branch from a84cbbf to 5e98ce5 Compare June 15, 2018 11:43
@ruflin ruflin merged commit ef70ea0 into elastic:master Jun 18, 2018
jsoriano added a commit to jsoriano/beats that referenced this pull request Jun 20, 2018
We were setting the `canonicalNaming` option to `false` in requests to
Jolokia, assuming that it should leave MBean names in responses as they
are. We need that for mappings to work.

But in some scenarios, as when using wildcards, Jolokia is responding with
canonicalized names, what breaks mappings.

This change canonicalizes names from config only for mappings and the
pre-built request. If we see that after setting `canonicalNaming` to `true`
there is some scenario in which Jolokia replies with non-canonicalized
names, then we'd have to canonicalize also MBeans for responses, or rethink
how we do the mapping.

(cherry picked from commit ef70ea0)
@jsoriano jsoriano added v6.3.1 and removed needs_backport PR is waiting to be backported to other branches. labels Jun 20, 2018
ruflin pushed a commit that referenced this pull request Jun 21, 2018
…okia module (#7385)

We were setting the `canonicalNaming` option to `false` in requests to
Jolokia, assuming that it should leave MBean names in responses as they
are. We need that for mappings to work.

But in some scenarios, as when using wildcards, Jolokia is responding with
canonicalized names, what breaks mappings.

This change canonicalizes names from config only for mappings and the
pre-built request. If we see that after setting `canonicalNaming` to `true`
there is some scenario in which Jolokia replies with non-canonicalized
names, then we'd have to canonicalize also MBeans for responses, or rethink
how we do the mapping.

(cherry picked from commit ef70ea0)
@jsoriano jsoriano deleted the jolokia-wildcard-canonical-names branch October 19, 2018 16:54
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
… in Jolokia module (elastic#7385)

We were setting the `canonicalNaming` option to `false` in requests to
Jolokia, assuming that it should leave MBean names in responses as they
are. We need that for mappings to work.

But in some scenarios, as when using wildcards, Jolokia is responding with
canonicalized names, what breaks mappings.

This change canonicalizes names from config only for mappings and the
pre-built request. If we see that after setting `canonicalNaming` to `true`
there is some scenario in which Jolokia replies with non-canonicalized
names, then we'd have to canonicalize also MBeans for responses, or rethink
how we do the mapping.

(cherry picked from commit 7dbdf8f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants