In production environments, it's critical to know the health and performance of your application. Without health
and metrics
endpoints, monitoring your application's operational state would require complex custom solutions.
What is it?
The health
and metrics
endpoints are key features of Spring Boot Actuator that provide insights into the health and performance of your application.
Health Endpoint (/actuator/health
):
- What is it?
The health
endpoint reports the current health status of your application. It aggregates health information from various components like databases, messaging systems, and custom checks.
* How is it used?
You can access it by visiting:
bash
http://localhost:8080/actuator/health
It returns a simple status by default:
json
{
"status": "UP"
}
For more details, you can enable full health information in application.properties
:
properties
management.endpoint.health.show-details=always
Metrics Endpoint (/actuator/metrics
):
- What is it?
The metrics
endpoint exposes detailed metrics on your application's performance, such as memory usage, CPU utilization, and HTTP request statistics.
* How is it used?
You can access it via:
bash
http://localhost:8080/actuator/metrics
You can also query specific metrics like jvm.memory.used
:
bash
http://localhost:8080/actuator/metrics/jvm.memory.used
This will return detailed metrics related to memory usage.
Key point:
These endpoints provide critical insights that help in monitoring, diagnosing issues, and ensuring optimal performance of your Spring Boot application.