JMX 自定义指标

要配置要监控的 JMX 指标,请按照以下示例所示编辑代理 configuration.yaml 文件:

com.instana.plugin.java:
  jmx:
    # 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'
      metrics:
        - attributes: 'TotalCompilationTime'
          type: 'delta' # delta will report the change to the previous second
    - object_name: 'java.lang:type=ClassLoading'
      metrics:
        - attributes: 'LoadedClassCount'
          type: 'absolute' # absolute will report the value as-is

configuration.yaml 示例指定了两种指标类型:

  • delta 用于随时间推移而增大的值(例如计数器),在这些值中,相对更改被视为有意义。
  • 每次访问度量值时,absolute 都用于显示实际值。

指定的属性必须是 Number(或它的某个子类,例如 IntegerDouble)或者表示数字的 String

在 JVM 仪表板上,JMX 指标显示在定制 JMX 指标下。

该文件 object_name 可能包含通配符模式,具体请参阅 Java 的文档 : ObjectName API。 以下是具有通配符模式的配置的示例:

com.instana.plugin.java:
  jmx:
    - object_name: 'kafka.*:type=*-metrics,client-id=*,*'
      metrics:
        - attributes: 'incoming-byte-rate'
          type: 'absolute'
        - attributes: 'incoming-byte-total'
          type: 'absolute'
        - attributes: 'outgoing-byte-rate'
          type: 'absolute'
        - attributes: 'outgoing-byte-total'
          type: 'absolute'