什么条件影响打印MBean属性的顺序?

时间:2019-05-01 18:19:53

标签: javabeans jmx jmx-exporter

我有一堆Java应用程序,需要通过prometheus jmx-exporter进行监视。问题在于它们具有不同的Bean属性顺序,从而导致由jmx-exporter生成的Prometheus度量标准的名称不同。例如application1有bean

java.lang<type=MemoryPool, name=JIT data cache><Usage>used

已转换为普罗米修斯度量标准

java_lang_memorypool_usage_used{name="JIT data cache"}

application2具有bean(注意交换了nametype属性)

java.lang<name=JIT data cache, type=MemoryPool><Usage>used

已转换为普罗米修斯度量标准

java_lang_jit_data_cache_usage_used{type=MemoryPool}

差异是由运行JVM或Java版本的应用程序引起的。拥有type的人首先在openjdk版本1.8.0_172上运行。拥有name的人首先在openj9版本11.0.2上运行。

我想将application2配置为以与application1相同的顺序返回属性,而不管它们在JVM上运行。有办法吗?

P.S。通过将模式放入jmx-exporter配置中,我设法解决了这个问题,例如:

    - pattern: "java.lang<name=(.*), type=MemoryPool><(\\w+)>(\\w+)"
      name: "java_lang_memorypool_$2_$3"
      labels:
        name: "$1"

但这对我来说似乎不是合适的解决方案,因为它要求为每个可用指标编写模式,并在指标列表发生更改时保持模式列表为最新。

0 个答案:

没有答案