Skip to content

default jvm metrics are missing some fields and I can't add them myself #312

Description

@jmazzitelli

[note: I was told to file this issue here in client_java - see https://github.com/prometheus/jmx_exporter/issues/205#issuecomment-342983424]

java.lang.Memory attributes "HeapMemoryUsage" and "NonHeapMemoryUsage" are collected by default.

However, only the max, committed, and used sub-attributes of the composite attribute are collected. The "init" sub-attribute of the composite is not collected.

I tried collecting it myself, but jmx exporter is refusing to honor my lowercaseOutputName setting of true.

Here's my pattern:

lowercaseOutputName: true
lowercaseOutputLabelNames: true
whitelistObjectNames: [
  "java.lang:type=Memory"
]
rules:
  - pattern: "java.lang<type=Memory><(.+)MemoryUsage>(init):"
    attrNameSnakeCase: true
    lowercaseOutputName: true
    lowercaseOutputLabelNames: true
    name: test_jvm_memory_bytes_init
    type: GAUGE
    labels:
      area: $1
    help: TEST Initial bytes of a given JVM memory area

This results in:

# HELP test_jvm_memory_bytes_init TEST Initial bytes of a given JVM memory area
# TYPE test_jvm_memory_bytes_init gauge
test_jvm_memory_bytes_init{area="Heap",} 6.7108864E7
test_jvm_memory_bytes_init{area="NonHeap",} 2555904.0

Firstly, I was expecting to use all lowercase characters in the pattern, however, I was forced to use "Memory" and "MemoryUsage". That seems odd - all my other patterns I've used in the past match all ObjectNames only when the ObjectNames are converted to all lowercase (which I assume is due to the setting "lowercaseOutputName: true"). But in any case, that's not my real problem.

Notice the values of the labels - they are using camel-case Heap and NonHeap, as opposed to "heap" and "nonheap". Notice the difference between that and the default metrics jmx-exporter collects without any additional configuration:

# HELP jvm_memory_bytes_max Max (bytes) of a given JVM memory area.
# TYPE jvm_memory_bytes_max gauge
jvm_memory_bytes_max{area="heap",} 4.77626368E8
jvm_memory_bytes_max{area="nonheap",} 1.59383552E9

Finally, the same holds true with memory pool metrics - by default jmx exporter only collects max, committed, and used sub-attributes of the composite attribute called "Usage", it does not collect "init". I am referring to MBeans such as java.lang:type=MemoryPool,name=PS Old Gen

All my problems go away if the jmx exporter will simply collect the "init" sub-attribute of these composite attributes so I do not have to.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions