Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 435
user168983 Avatar asked Oct 15 '25 04:10

user168983


1 Answers

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 (e.g.: Prometheus: /actuator/prometheus).

like image 184
Jonatan Ivanov Avatar answered Oct 16 '25 16:10

Jonatan Ivanov