需要什么配置才能使带有 spring-boot 的千分尺输出 jvm_info{} 量表?

Jon*_*Jon 5 spring-boot spring-micrometer

我有许多非 spring-boot 服务,它们使用io.prometheus simpleclient_hotspot.

我试图获得与这些以及从我的 spring-boot 服务生成的 JVM 指标的奇偶性,这些服务使用 micrometer 的默认设置。

我需要一些额外的千分尺配置才能生成指标,例如:

# TYPE jvm_info gauge
jvm_info{version="
...
jvm_memory_bytes_used
jvm_memory_pool_bytes_max
etc...
Run Code Online (Sandbox Code Playgroud)

我很欣赏开箱即用的千分尺正在记录:jvm_memory_used_bytes它与 simpleclient_hotspot 中相同指标的名称不匹配:(

如果可能的话,我希望实现一致性,并且jvm_info对于千分尺/弹簧靴特别有用。

jol*_*olo 1

我建议您查看NamingConvention千分尺核心库中的内容。有几个使用它来将名称转换为不同监控系统的示例(查找实现的类NamingConvention)。例如,如果您正在使用 Prometheus(看起来您可能使用的是 Prometheus),您可以将其PrometheusNamingConvention作为示例。看起来您会对实现/覆盖该public String name(String name, Meter.Type type, @Nullable String baseUnit)方法感兴趣。