You monitor application health in Spring Boot by adding spring-boot-starter-actuator and calling the /actuator/health endpoint. It aggregates health indicators for the database, disk space, message brokers and your own checks into a single status such as UP or DOWN, which load balancers, Kubernetes probes and monitoring tools can poll.
Only health is exposed over HTTP by default, and details are hidden until you configure them. The sections below show the setup, how to read and secure the output, how to add custom indicators and how to wire the endpoint into Kubernetes.
Add the starter to your build. With Maven:
With Gradle (Kotlin DSL):
Start the application and request the endpoint:
In current Spring Boot versions, health is the only endpoint exposed over HTTP by default. To expose more, list them explicitly instead of using a wildcard in production:
The show-details property controls how much the response reveals:
| Value | Behaviour |
|---|---|
never | Only the overall status is shown (default). |
when-authorized | Details are shown to authenticated users with the roles in management.endpoint.health.roles. |
always | Details are shown to everyone. Avoid on public endpoints. |
With details enabled, the response lists each component:
Spring Boot registers a HealthIndicator automatically when the matching dependency is on the classpath and configured. Common ones include:
db for a DataSource (runs a validation query).diskSpace for free disk space against a threshold.ping, a simple always-up check.redis, mongo, elasticsearch, cassandra for those stores.rabbit and kafka style brokers where the starter supplies an indicator.ssl for certificate validity of configured SSL bundles.The overall status is computed from the individual statuses. The default order is DOWN, OUT_OF_SERVICE, UP, UNKNOWN, so one DOWN component makes the whole application DOWN. A DOWN status returns HTTP 503 and UP returns 200, which is what load balancers rely on.
To turn off an indicator you do not want, disable it by name:
Implement HealthIndicator and register it as a bean. The bean name minus the HealthIndicator suffix becomes the component name, so the class below appears as paymentGateway.
Keep these checks fast and bounded with a timeout, because the endpoint is polled frequently. For reactive applications implement ReactiveHealthIndicator instead, and extend AbstractHealthIndicator if you prefer a template that handles exceptions for you.
Set management.endpoint.health.probes.enabled=true (it is enabled automatically when Spring Boot detects it is running on Kubernetes) to get two health groups:
/actuator/health/liveness tells the platform whether the process should be restarted./actuator/health/readiness tells the platform whether the application should receive traffic.You can also define your own groups, for example one that contains only the database and your payment check:
Do not put downstream dependencies such as the database into the liveness group. A database outage would make Kubernetes restart healthy pods and make the outage worse.
Health details can reveal hostnames, versions and capacity. Expose the endpoints on a separate management port, or protect them with Spring Security:
If Spring Security is on the classpath, allow the health endpoint publicly and require a role for everything else:
By default it is /actuator/health under your application's context path. You can change the base path with management.endpoints.web.base-path.
Details are hidden by default. Set management.endpoint.health.show-details to when-authorized or always to see the components.
The overall status is the worst status of all included indicators. Move non-critical checks out of the main group, or disable the indicator.
Yes. Point the health check at /actuator/health (or the readiness group) and treat HTTP 200 as healthy and 503 as unhealthy.
Add spring-boot-starter-actuator, expose health (plus only the endpoints you need), and control detail with show-details. Use built-in indicators for common dependencies, write a HealthIndicator for your own critical services, split liveness from readiness for Kubernetes, and keep the management endpoints secured or on a private port.