Actuator Health Check Endpoint - VittorioDeMarzi/hero-beans GitHub Wiki
Actuator Health Check Endpoint
Spring Boot provides the Actuator Health Endpoint (/actuator/health
) to monitor the status of an application. It is commonly used in production environments to check if the application is running and ready to serve requests.
Purpose
The health check endpoint exposes information about the application’s overall status and its individual components (e.g., database, message broker, disk space). This is useful for:
- Load balancers / Kubernetes probes: deciding whether an instance is healthy and can receive traffic.
- Monitoring systems: integrating with tools like Prometheus, Grafana, or AWS CloudWatch.
- Debugging: quickly verifying the health of critical dependencies.
Usage
-
Default endpoint:
GET /actuator/health
-
Default response (simplified):
{ "status": "UP" }
Configuration
-
By default, only the overall status (
UP
,DOWN
,OUT_OF_SERVICE
,UNKNOWN
) is exposed. -
To see detailed component information, configure:
management.endpoint.health.show-details=always management.endpoints.web.exposure.include=health
Example with Details
{
"status": "DOWN",
"components": {
"db": {
"status": "DOWN",
"details": {
"error": "org.postgresql.util.PSQLException: Connection refused"
}
},
"diskSpace": {
"status": "UP",
"details": {
"total": 499963174912,
"free": 324000000000,
"threshold": 10485760,
"exists": true
}
}
}
}
Key Points
- Simple
UP
/DOWN
status by default. - Extendable with custom health indicators (e.g., checking a remote API).
- Critical for production monitoring, scaling, and reliability.