user168983
user168983

Reputation: 844

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?

Upvotes: 4

Views: 5783

Answers (1)

Jonatan Ivanov
Jonatan Ivanov

Reputation: 6863

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).

Upvotes: 2

Related Questions