【问题标题】:Is there any way to add `application` tag to standard prometheus micrometer metrics?有没有办法将“应用程序”标签添加到标准普罗米修斯千分尺指标?
【发布时间】:2022-11-03 01:24:34
【问题描述】:

我很少有带有执行器和公开普罗米修斯指标的 spring-boot 微服务。例如:

# HELP process_uptime_seconds The uptime of the Java virtual machine
# TYPE process_uptime_seconds gauge
process_uptime_seconds 3074.971

但是没有application 标签,所以我无法将它绑定到grafana仪表板中的某个应用程序......

此外,我希望一些微服务的应用程序实例很少,所以总的来说,添加一个instance 标签会很好。

有没有办法使用这些标签自定义标准指标?

【问题讨论】:

    标签: spring-boot prometheus spring-boot-actuator micrometer


    【解决方案1】:

    添加标签的最佳方式是使用 Prometheus 服务发现。这使这些标签远离您的应用程序代码,并使其不必担心它的存在位置。

    但是有时如果你绝对需要那些额外的标签(由于服务有额外的洞察力,Prometheus 服务发现没有出现)你不能使用 Java 简单客户端(Go 客户端确实支持这个)

    我发现这个特性是通过一个名为“Common Tags”的 Micrometer 特性提供的,它封装了 Prometheus Java 客户端。您设置您的客户端,以便可以通过 config() 调用使用标签。

    registry.config().commonTags("stack", "prod", "region", "us-east-1");
    

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 2018-08-16
      • 2022-12-02
      • 2022-12-22
      • 2020-01-10
      • 2020-11-12
      • 1970-01-01
      • 2022-11-22
      • 1970-01-01
      相关资源
      最近更新 更多