JMX Custom Metrics

To configure which JMX metrics to monitor, edit the agent configuration.yaml file.
    # JMX is NOT hot-reloaded and needs to be set before a JVM is discovered.
    # Supported attribute types are Number and Boolean
    # delta calculation is only supported for Number
    - object_name: 'java.lang:type=Compilation'
        - attributes: 'TotalCompilationTime'
          type: 'delta' # delta will report the change to the previous second
    - object_name: 'java.lang:type=ClassLoading'
        - attributes: 'LoadedClassCount'
          type: 'absolute' # absolute will report the value as-is

Two types of metrics are specified in the example above:

  • delta is used for values that increase over time, such as counters, where the relative change is considered interesting.
  • absolute is used to show the actual value each time the metric is accessed.

The attribute specified must either be Number (or one of its subclasses like Integer or Double) or a String representing a number.

On the JVM dashboard, the JMX metrics are displayed under Custom JMX metrics.

The object_name may contain wildcard patterns as specified in Java's ObjectName API documentation. Here's an example of a configuration with wildcard patterns:
    - object_name: 'kafka.*:type=*-metrics,client-id=*,*'
        - attributes: 'incoming-byte-rate'
          type: 'absolute'
        - attributes: 'incoming-byte-total'
          type: 'absolute'
        - attributes: 'outgoing-byte-rate'
          type: 'absolute'
        - attributes: 'outgoing-byte-total'
          type: 'absolute'