-
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: Support wildcards in jolokia (#6453) #6462
Conversation
Could you share an example of two json events on how they would look like with option 1? |
@ruflin I have added an example for option 1 to the description. |
I guess that something like option 2 fits better with |
After talking offline with @exekias about this I will go for option 1 implementing the |
9ec8def
to
21142da
Compare
|
||
"github.com/joeshaw/multierror" | ||
"github.com/pkg/errors" | ||
|
||
"github.com/elastic/beats/libbeat/common" | ||
) | ||
|
||
const ( | ||
MBeanEventKey = "mbean" |
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.
exported const MBeanEventKey should have comment (or a comment on this block) or be unexported
21142da
to
a83c3fd
Compare
After playing a bit with Jolokia and metricbeat I think that we cannot just generate an event for each mbean as I though. I see two main use cases for this module:
|
90020db
to
439dae4
Compare
|
439dae4
to
8768ad7
Compare
@ruflin thanks for your comments, find answers inline.
It will depend on the mappings the user configures, for example for the case mentioned in #6453 (comment) it'd be about 20 metrics per matching mbean, but it could be only 2 as in the example I posted.
The case of building an only event from multiple known mbeans would still be supported, as well as the case of generating multiple events for known mbeans using multiple instances of the module. Multiple events would only be generated when using wildcards.
I think this would be more confusing, in general if a wildcard is used, multiple matches of similar things should be expected, so as I see it, multiple events should be generated to avoid conflicts with field names, and to support the case of #6453 (comment) that I think it fits better with the use of wildcards.
Well, conflicts here wouldn't come from having dots in the names but by having directly multiple fields with exactly the same name coming from similar mbeans. |
When using wildcards with Jolokia, if multiple mbeans match, they will each one have their own metrics. If we only generate an event each match will overwrite the previous ones. Previous behaviour is kept for Jolokia requests without wildcards, this can be used to compose an only event from multiple specific mbeans.
8768ad7
to
5c73b4c
Compare
} | ||
type AttributeMapping map[attributeMappingKey]Attribute | ||
|
||
func (m AttributeMapping) Get(mbean, attr string) (Attribute, bool) { |
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.
exported method AttributeMapping.Get should have comment or be unexported
type attributeMappingKey struct { | ||
mbean, attr string | ||
} | ||
type AttributeMapping map[attributeMappingKey]Attribute |
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.
exported type AttributeMapping should have comment or be unexported
5c73b4c
to
c66a46e
Compare
As talked offline, and in the line of #6585, I have added explicit grouping of metrics. An optional |
…etrics A new optional `event` option is added to attribute mappings, so attributes with the same `event` are sent in the same event to Elastic and attributes with different `event` are sent in different events. Some additional related refactorings done to improve type safety.
c66a46e
to
f3bb1ca
Compare
jenkins, test it again please |
|
||
// Get the mapping options for the attribute of an mbean | ||
func (m AttributeMapping) Get(mbean, attr string) (Attribute, bool) { | ||
a, found := m[attributeMappingKey{mbean, attr}] |
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.
Nit: Seems like you could return here 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.
I think it doesn't work when the expression is a value obtained from a map.
@jsoriano Thanks for pushing this forward. Could you update the PR message above with the end solution you went with so people coming to this PR know directly what changed? Would be great to have a blog post about jolokia/jmx monitoring. |
Updated description |
Is this going to make it into 6.3 or left for 7.0? |
@NeQuissimus Will be in 6.3 |
Partially support wildcards in jolokia. This would cover the case of #6453 where wildcard is used to match one of two possible names. In a more general case this implementation is incomplete because if multiple mbeans match, their field mapping will collide and only one value will be stored.
Update: The option finally chosen and implemented is:
event
parameter is added to field mappings, to explicitly separate metrics that have different values.To solve this I see two options:
New events would contain also the mbean, so with a wildcard these events could be generated:
Would generate events like this one:
I think option 1 is more intuitive, but I'm not sure if generating multiple events fits with the general design of the module, opinions?