There is no @HealthIndicator annotation in Spring Boot. What you are looking for is the HealthIndicator interface from Spring Boot Actuator. You implement it in a Spring bean, return a Health object with status UP or DOWN, and Actuator aggregates all indicators into the /actuator/health endpoint that load balancers, Kubernetes and monitoring tools poll.
This article explains how to write a custom health indicator, how to expose and secure the endpoint, and how to use health groups for liveness and readiness probes in Spring Boot 3.
HealthIndicator isHealthIndicator isSpring Boot Actuator ships built-in indicators for the database (DataSource), disk space, Redis, Kafka and other components found on the classpath. Each one reports a Status and optional details. The HealthEndpoint combines them using a StatusAggregator, where the default order is DOWN, OUT_OF_SERVICE, UP, UNKNOWN: one failing indicator makes the whole application DOWN.
To add your own check, implement org.springframework.boot.actuate.health.HealthIndicator and register it as a bean. The common mistake is looking for an annotation. The mechanism is the interface plus Spring's component scanning, not an annotation named @HealthIndicator.
Add the dependency, and Spring Boot configures the endpoints.
Then expose the health endpoint over HTTP and decide how much detail to show:
By default only health is exposed over the web, and details are hidden (never). Use when-authorized or always only when the endpoint is protected.
The simplest approach is to implement HealthIndicator and annotate the class with @Component.
The bean name decides the key in the response: Spring strips the HealthIndicator suffix and uses the rest, so this one appears as paymentGateway. A sample response with details enabled looks like this:
If a check is slow or can throw, extend AbstractHealthIndicator and override doHealthCheck(Health.Builder builder). It catches exceptions and turns them into DOWN for you.
For reactive applications, implement ReactiveHealthIndicator and return a Mono<Health>.
| Status | HTTP code (default) | Meaning |
|---|---|---|
UP | 200 | The component works. |
DOWN | 503 | The component failed. |
OUT_OF_SERVICE | 503 | Deliberately unavailable, for example during maintenance. |
UNKNOWN | 200 | State cannot be determined. |
You can map custom statuses and change the aggregation order with the management.endpoint.health.status.* properties.
In Spring Boot 3, applications running on Kubernetes get liveness and readiness probes when they are detected, or when enabled:
This adds /actuator/health/liveness and /actuator/health/readiness. Liveness reports whether the process is broken and should be restarted, and readiness reports whether it can accept traffic. A key rule: do not put external dependencies such as the database in liveness, because a database outage would restart every pod without fixing anything.
You can also define your own groups:
management.server.port if you want them off the public network.health() and asserting the status.@HealthIndicator annotation?No. Implement the HealthIndicator interface and register the class as a bean, usually with @Component.
Set management.health.<name>.enabled=false, for example management.health.redis.enabled=false.
/actuator/health return 503?At least one indicator reports DOWN. Enable details temporarily, or check management.endpoint.health.show-details, to see which one.
Yes. Give the bean a name, for example @Component("payments"), and that name becomes the key. Otherwise the key is the bean name without the HealthIndicator suffix.
HealthIndicator is an interface, not an annotation. Implement it as a bean to add custom checks to Actuator's /actuator/health, return Health.up() or Health.down() with details, restrict who sees those details, and use readiness and liveness groups on Kubernetes.