Skip to content

jmx metrics with yaml: need ability to post-process some attribute values #13361

@SylvainJuge

Description

@SylvainJuge

JMX Insight is now reused by jmx-scraper in contrib repository, so in theory it would be possible to now capture stable JVM runtime metrics that are part of semconv with declarative YAML from outside of the JVM with jmx scraper.

The current implementation in instrumentation is in instrumentation/runtime-telemetry/runtime-telemetry-java8 does not rely on this declarative YAML metrics capture, even if it relies on the same JMX interface.

When attempting to capture semconv-compliant JVM runtime metrics, we currently can't post-process or normalize the metric attributes, for example with the jvm.memory.{used,committed,limit} metrics, the value of jvm.memory.type comes from an MBean attribute name with values heap and non_heap.

The best we can so so far is to capture those metrics with their original MBean attribute values, the following YAML would capture HEAP and NON_HEAP for jvm.memory.type metric attribute:

rules:

  - bean: java.lang:type=MemoryPool,name=*
    prefix: jvm.memory.
    type: updowncounter
    unit: By
    metricAttribute:
      jvm.memory.pool.name: param(name)
      jvm.memory.type: beanattr(type)
    mapping:
      Usage.used:
        metric: used
        desc: Measure of memory used.
      Usage.committed:
        metric: committed
        desc: Measure of memory committed.
      Usage.max:
        metric: limit
        desc: Measure of max obtainable memory.

In order to solve this, we could introduce a simple lowercase(...) function int he yaml syntax as most of the attributes in semconv are lowercase, for example it could look like this:

  - bean: java.lang:type=MemoryPool,name=*
    prefix: jvm.memory.
    type: updowncounter
    unit: By
    metricAttribute:
      jvm.memory.pool.name: param(name)
      jvm.memory.type: lowercase(beanattr(type))
    mapping:
     # ...

The same logic could be applied to capture jvm.thread.state attribute that has the same issue as the values are provided in upper-case and are lower-cased in semconv.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions