r/SpringBoot • u/fykup • 7d ago
Discussion Spring Boot's /actuator/metrics vs /actuator/prometheus - a distinction I initially missed
While building a monitoring integration for Spring Boot, I started with /actuator/metrics. It seemed like the natural choice: Actuator exposes application metrics as JSON, and that's a straightforward integration path.
Later, I received feedback that /actuator/metrics is primarily a diagnostic endpoint, not intended for continuous production scraping. That led me to add support for /actuator/prometheus while keeping the JSON integration for compatibility.
The interesting part is that both endpoints are useful, just for different purposes:
/actuator/metricslets you inspect individual meters, measurements, and tags./actuator/prometheusexposes metric series in a format designed for ongoing collection.- Both use Micrometer underneath. You don't need to replace Actuator or run a Prometheus server to use the second endpoint.
Looking back, the documentation explains all of this, but the distinction isn't necessarily obvious when you're starting from the usual Actuator examples.
I wrote up what I learned, including configuration examples for both endpoints and some common troubleshooting cases:
https://pvrlabs.xyz/articles/spring-boot-actuator-metrics-vs-prometheus.html
3
u/FriendshipCalm3162 6d ago
GET /actuator/metricsonly returns{"names": [...]}, so every value is a separate request to/actuator/metrics/{name}, and tag drill-down is another?tag=area:heapon top of that. Fine when you're inspecting one meter, less fine when there are a few hundred.The statistics are the bigger constraint. Spring's REST API page for that endpoint lists them as TOTAL, TOTAL_TIME, COUNT, MAX, VALUE, UNKNOWN, ACTIVE_TASKS and DURATION, so there is no percentile and no bucket in there. A Timer read that way gives you count, total time and max, which gets you a mean but never a p95. Percentiles only exist once you set
management.metrics.distribution.percentiles-histogramor.percentiles, and then they come out as series on the prometheus scrape, not in the JSON.The prometheus endpoint also isn't exposed by default, which is usually what's behind a 404 on the first try.
2
u/jonatan-ivanov 5d ago
Hi, Jonatan here from the Spring team (I'm one of the maintainers of Micrometer, and I also wrote the part of the Boot docs you are referring to). Is there anything we can do to make this more discoverable?
1
u/Minute_Owl3430 3d ago
Now OTel next