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 (e.g.: Prometheus: /actuator/prometheus
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With