The HealthIndicator interface in Spring Boot Actuator lets you define a health check for one component, such as a database, a message broker or a downstream API. Each implementation returns a Health object with a status (UP, DOWN, OUT_OF_SERVICE or UNKNOWN) and optional details, and Actuator aggregates all indicators into the /actuator/health endpoint.
Load balancers, container orchestrators such as Kubernetes and monitoring tools call that endpoint to decide whether an instance should receive traffic or be restarted. A custom HealthIndicator is how you make that decision reflect the dependencies your application really needs.
HealthIndicator lives in org.springframework.boot.actuate.health. It has a single method, health(), which returns a Health instance. Spring Boot collects every HealthIndicator bean in the application context, runs it when the health endpoint is requested, and combines the results into one overall status.
Boot already registers indicators for many things when the matching dependency is on the classpath: DataSourceHealthIndicator, DiskSpaceHealthIndicator, RedisHealthIndicator, MongoHealthIndicator, the Kafka, Elasticsearch and mail indicators, and more. You write your own when a resource is not covered, or when "reachable" is not a strong enough definition of "healthy" for your business.
| Status | Meaning | Default HTTP code |
|---|---|---|
UP | The component works | 200 |
DOWN | The component is failing | 503 |
OUT_OF_SERVICE | Deliberately taken out of service | 503 |
UNKNOWN | State could not be determined | 200 |
The aggregate status is the most severe status among all indicators, using the order DOWN, OUT_OF_SERVICE, UP, UNKNOWN. One failing indicator therefore turns the whole application DOWN. You can change the order and the HTTP mapping with management.endpoint.health.status.order and management.endpoint.health.status.http-mapping.*.
Add the Actuator starter first.
Then implement the interface and register the class as a bean.
The component name in the response is derived from the bean name by removing the HealthIndicator suffix and lower-casing the first letter, so this bean appears as paymentGateway. The response looks like this:
AbstractHealthIndicator handles exceptions for you: anything thrown from doHealthCheck becomes a DOWN status with the error message attached.
Here QueueClient stands for your own client class.
By default only the overall status is shown and only health is exposed over HTTP. These properties control it:
show-details accepts never, when-authorized and always. Health details can leak internal host names and versions, so avoid always on a public endpoint.
Health groups let you expose different subsets of indicators. Spring Boot provides built-in liveness and readiness probes for Kubernetes at /actuator/health/liveness and /actuator/health/readiness, enabled automatically on Kubernetes or with management.endpoint.health.probes.enabled=true. You can define your own group:
Keep liveness checks free of external dependencies. If a database outage makes liveness fail, the orchestrator restarts healthy pods and makes the outage worse. Put dependency checks in readiness.
In a WebFlux application, use ReactiveHealthIndicator so the check does not block an event-loop thread. It returns a Mono<Health>.
when-authorized.health() and asserting the returned Status.A HealthIndicator contributes one component to the standard /actuator/health response and follows its status rules. A custom endpoint, built with @Endpoint, exposes arbitrary data on its own path.
Check that it is a Spring bean, that management.endpoint.health.show-components or show-details allows output for your user, and that you have not disabled it with management.health.<name>.enabled=false. The component name is the bean name without the HealthIndicator suffix.
Remove it from the groups used by your probes, or return a status such as UNKNOWN for non-critical components. You can also define a health group that includes only the critical indicators.
Usually not. A liveness probe should only tell the platform that the process is stuck and needs a restart. Use readiness for dependencies.
HealthIndicator is the extension point for Spring Boot Actuator health checks. Implement health() (or extend AbstractHealthIndicator), return Health.up() or Health.down() with useful details, and register the class as a bean. Use ReactiveHealthIndicator on WebFlux, control visibility with show-details, and use health groups for liveness and readiness so orchestrators react correctly.