【问题标题】:Exposing percentile values of micrometer timer in springboot /metrics在 spring boot /metrics 中暴露千分尺计时器的百分位值
【发布时间】:2022-01-26 16:35:17
【问题描述】:

我目前有一个 spring boot 2.4.0 项目,它使用 /metrics/custom-timer 公开指标,我创建了一个自定义计时器,但它只给出了一些值而不是百分位数。

    "name": "custom-timer",
    "description": null,
    "base_unit": "seconds",
    "measurements": [
        {
            "statistic": "COUNT",
            "value": 1000.0
        },
        {
            "statistic": "TOTAL_TIME",
            "value": 100000.0
        },
        {
            "statistic": "MAX",
            "value": 100.0
        }
    ],
    "available_tags": []
}

我启动了自定义计时器

summary =  Timer.builder("custom-timer")
                .publishPercentileHistogram(true)
                .publishPercentiles(0.3, 0.5, 0.95)
                .register(Metrics.globalRegistry);

如何获取指标端点中的百分位数?

【问题讨论】:

    标签: java spring spring-boot micrometer


    【解决方案1】:

    Spring Boot Actuator 的 /metrics 端点不支持百分位数(它在后台使用 SimpleMeterRegistry)。 这主要是因为此端点并非用于从中提取生产指标,它仅用于提供信息/调试目的。

    您可以添加一个“真实的”注册表,您应该会看到百分位数(例如:Prometheus:/actuator/prometheus)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-30
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 1970-01-01
      • 2020-02-17
      • 2020-03-15
      • 2019-01-27
      相关资源
      最近更新 更多