Production-ready endpoints for health, metrics and info — and the exposure rules the exam loves to test.
Add spring-boot-starter-actuator and Boot exposes endpoints that report on and let
you manage a running app — health, info, metrics, beans,
env, loggers, mappings, threaddump, shutdown,
and more. Over HTTP they live under the base path /actuator (e.g.
/actuator/health).
Every endpoint has two independent switches:
| Concern | Means | Default |
|---|---|---|
| Enabled | the endpoint bean exists at all | All enabled except shutdown |
| Exposed (HTTP) | reachable over the web | Only health |
| Exposed (JMX) | reachable over JMX | All endpoints |
health is exposed by default. Over JMX, all endpoints are.
An endpoint can be enabled but not exposed — it exists, but you can't reach it over HTTP until you
include it. And shutdown is the one endpoint disabled by default.
# expose everything over HTTP
management.endpoints.web.exposure.include=*
# or a specific set, and exclude some
management.endpoints.web.exposure.include=health,info,metrics
management.endpoints.web.exposure.exclude=env,beans
UP, DOWN, OUT_OF_SERVICE, UNKNOWN. Severity order is configurable via management.endpoint.health.status.order.management.endpoint.health.show-details = never (default), when-authorized, or always.HealthIndicator (its health() returns a Health).@Component
public class QueueHealthIndicator implements HealthIndicator {
@Override public Health health() {
return queueOk() ? Health.up().build()
: Health.down().withDetail("queue", "full").build();
}
}
MeterRegistry and creating counters/gauges/timers./actuator/** to an ADMIN role.management.server.port, or change the base path with management.endpoints.web.base-path.Read "Enabling/Exposing Endpoints" (the default table), "Health Information", and "Metrics".
The exposure defaults and the enabled-vs-exposed distinction are the money questions. All answers verified against the Boot 2.5 docs. Options shuffle on every load.