The Health class in Spring Boot Actuator is an immutable value object that holds the health result of one component or of the whole application. It combines a Status (such as UP or DOWN) with an optional map of details, and HealthIndicator implementations return it so the /actuator/health endpoint can report it as JSON.
You rarely build the overall result yourself. Spring Boot collects the Health objects from every HealthIndicator bean, merges their statuses with a StatusAggregator, and serves the combined result. Your code creates Health instances when you write a custom indicator.
org.springframework.boot.actuate.health.Health pairs a Status with a map of details. It is immutable and is created through a builder, so a health check can never be changed after it has been produced.
Each instance carries:
Status, which is the verdict for the componenterror detailHealth implements HealthComponent, the same base type used for composite results that group several indicators (for example db, diskSpace and ping). The JSON you see at /actuator/health is a composite whose children are individual Health objects.
A Status is a code plus an optional description. Spring Boot ships these constants and the default severity order used when several indicators disagree:
| Status | Meaning | Default HTTP code |
|---|---|---|
DOWN | The component has failed | 503 |
OUT_OF_SERVICE | Deliberately taken out of service | 503 |
UP | Working as expected | 200 |
UNKNOWN | State cannot be determined | 200 |
The overall status is the most severe one in that order, so one DOWN indicator makes the whole application DOWN. You can change the order with management.endpoint.health.status.order and the HTTP mapping with management.endpoint.health.status.http-mapping.<status>. Custom statuses are allowed, for example new Status("DEGRADED"), as long as you add them to the order.
The static factory methods return a Health.Builder. Chain withDetail, withException or withDetails and finish with build().
Health.up(), down(), outOfService() and unknown() cover the built-in statuses, and Health.status(...) accepts a string or a Status. Calling withException(ex) stores the exception class and message under an error key rather than the stack trace.
A custom check is a Spring bean that implements HealthIndicator and returns a Health. The bean name minus the HealthIndicator suffix becomes the key in the JSON, so the class below appears as paymentGateway.
Spring Boot calls health() when the endpoint is requested, so keep it fast and give any network call its own timeout. For checks that are expensive or reactive, extend AbstractHealthIndicator (which handles exceptions for you) or implement ReactiveHealthIndicator and return a Mono<Health>.
Only health is exposed over HTTP by default in Spring Boot 2.x and 3.x, and details are hidden unless you opt in. Details can leak internal hostnames and versions, so avoid always on a public endpoint.
A response with details looks like this:
Health groups return a subset of indicators on their own path, which is how you separate liveness from readiness. With management.endpoint.health.probes.enabled=true (enabled automatically on Kubernetes) Boot adds /actuator/health/liveness and /actuator/health/readiness. Do not put external dependencies in the liveness group, or a database outage will cause restarts that cannot fix it.
No. HealthIndicator is the interface that performs a check, and Health is the value it returns. One indicator produces one Health.
Put the indicator in a health group that your readiness probe does not use, or change management.endpoint.health.status.order so your custom status ranks below UP. Removing the indicator from the probe group is usually clearer.
Details are hidden by default. Set management.endpoint.health.show-details to when-authorized or always, and make sure the caller has the role named in management.endpoint.health.roles.
Yes. Set management.health.<name>.enabled=false, for example management.health.diskspace.enabled=false, or disable all defaults with management.health.defaults.enabled=false.
Health is the immutable result of a health check: a Status plus a details map. Build it with Health.up(), Health.down() and the other factory methods, return it from a HealthIndicator bean, and let Spring Boot aggregate the results at /actuator/health. Keep checks fast, expose details only to authorised callers, and use health groups for liveness and readiness.