简体   繁体   中英

Exposing percentile values of micrometer timer in springboot /metrics

I currently have a spring boot 2.4.0 project which exposes metrics with /metrics/custom-timer, I created a custom timer but it only gives some values but not the percentiles.

    "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": []
}

I initiated the custom timer as

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

How to get the percentile values in metrics endpoint?

Spring Boot Actuator's /metrics endpoint does not support percentiles (it uses SimpleMeterRegistry under the hood). This is mostly because this endpoint is not meant to be used to pull production metrics from it, it is just for informational/debugging purposes.

You can add a "real" registry and you should see the percentiles (eg: Prometheus: /actuator/prometheus ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM