I am trying to pattern match and name prometheus metrics with the jmx_exporter java agent (https://github.com/prometheus/jmx_exporter).
There is not much documentation on how to pattern match on MBean attributes and items within these attributes when dealing with CompositeType.
For instance, I got to the point where I pattern in such a way:
rules:
- pattern: "java.lang<type=Memory><>HeapMemoryUsage"
name: jmx_jvm_memory_HeapMemoryUsed
But if you look in VisualVM at HeapMemoryUsed attribute. You can also see in the Attribute Description in openType the following:
javax.management.openmbean.CompositeType(
name=java.lang.management.MemoryUsage,
items=(
(itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
(itemName=init,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),
(itemName=used,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long))
)
)
I want to be able to name the metric based on these items. For example, I would like to have a metrics such as:
- jmx_jvm_memory_HeapMemoryUsed_used
- jmx_jvm_memory_HeapMemoryUsed_max
etc...
Thanks!
If you look at the
HELPin the metrics output, that's what you're matching against. However there's no need for you to worry about any of the java.lang metrics, the jmx exporter java agent will provide them for you automatically under thejvm_metrics prefix.