【问题标题】:How can I publish all health check info from /actuator/health to /actuator/prometheus?如何将 /actuator/health 中的所有健康检查信息发布到 /actuator/prometheus?
【发布时间】:2021-11-15 16:40:22
【问题描述】:

我想将 /actuator/health 上的所有信息发布到 /actuator/prometheus,因为 /actuator/prometheus 端点不包含有关磁盘空间或 LDAP/数据库可用性的指标。我发现可以创建一个 DiskSpaceMetricsConfiguration 类 (https://www.ivankrizsan.se/2021/01/23/spring-boot-prometheus-disk-space-metrics),这很有效,但是 我不知道如何为应用程序状态、数据库状态和 ldap 状态做同样的事情。

我正在使用 spring-boot 2.1.9、spring-boot-starter-actuator 2.5.1 和 micrometer-registry-prometheus 1.2.1。

【问题讨论】:

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


    【解决方案1】:

    您使用的版本不兼容,请使用Spring Boot BOM,它会为您设置版本。

    Spring Boot 文档中有一个关于 Mapping Health Indicators to Micrometer Metrics 的部分。您可以对每个健康指标执行相同的操作。

    这里的技巧是将健康指示器转换为Gauge,您可以通过多种方式执行此操作,这取决于您,您可以使用 0/1 值来指示服务是否为UP 或您可以按照上述文档的建议为每种状态使用不同的值。

    【讨论】:

      猜你喜欢
      • 2019-08-05
      • 1970-01-01
      • 1970-01-01
      • 2020-01-20
      • 1970-01-01
      • 2020-05-24
      • 1970-01-01
      • 2023-03-10
      • 2015-12-06
      相关资源
      最近更新 更多