-
Notifications
You must be signed in to change notification settings - Fork 870
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
Add ability to capture non-numeric MBean attributes as metrics #12229
Comments
One of the downsides of sending a constant After reflecting a bit more on this issue, I think that having the ability to define "state metrics" would be possible by trying to implement the following with Tomcat as example: JMX object name: We can capture this as
Example if we have a single
The list of values for
In order to normalize the values that are read from JMX and underlying implementation, we will need to have a way to express a 1:1 mapping for each value, for example:
Of course, doing that with YAML syntax could be a challenge, but it does not sound like something impossible. |
I just opened a first draft implementation PR for this: #12369, as usual, feedback is welcome. |
For now, the current implementation of JMX Insights only allows to capture numeric MBean attributes as metrics.
However, it is common to find MBean attributes that expose internal state as a string, boolean or even enum. For example, with Tomcat
Catalina:type=Connector,port=*
MBean where thestateName
attribute (see code) and the string values come from LifeCycleState enum (code).The JMX Gatherer in contrib provides a way to create metrics from non-numeric MBean attributes, but replicating this with YAML seems tricky.
For string attributes, we can already capture them as a metric attribute of another metric, but it has two caveats:
Prometheus exporter has this ability, and I think it would be relevant to add it here as well.
When looking at the implementation in this PR for enums, we can see that they use a "filter" on the attribute value to implement this, for example in prometheus configuration:
With this configuration:
kafka_streams_state_running
with value of1
is issued whenstate
=RUNNING
kafka_streams_state_rebalancing
with value of1
is issued whenstate
=REBALANCING
state
value does not match no metric is issuedI think there are a few solutions to implement a similar feature with YAML configuration, which in the case of Tomcat could be something like this for
http.server.tomcat.connector
metric:Here the
value: 1
indicates the metric value will be a constant value of 1 and thebeanattrmap
allows to translate the original values. Thisbeanattrmap
function would support mappingstring
,boolean
andenums
through their string representation.In short, the metric value will be constant, but the attributes of the metric will change over time.
As a simpler version of this, we could also capture the attribute values as-is, in which case the original upper-case values would be preserved with
state: beanattr(state)
As another alternative, we could map using distinct metrics to make it closer to prometheus solution:
Where the
valuematch(XXX,1,0)
function would return0
value when attribute value does not match and1
when it does.Also, the YAML syntax does not allow for duplicate beans mapping.
I have the following questions that I'd like to have feedback on:
0
to cancel the previous1
when state changes ?The text was updated successfully, but these errors were encountered: