- Spring Boot Actuator is a sub-project of Spring Boot that provides several production-ready features to help you monitor and manage your application.
- It provides a variety of endpoints that allow you to retrieve information about the health, performance, and configuration of your application.
Here’s a table of the most commonly used endpoints in Spring Boot Actuator, along with their usage:
Endpoint | Description |
---|---|
/actuator/health | Returns information about the health of your application. The endpoint returns a status field with a value of UP if your application is running normally, or DOWN if it’s not. |
/actuator/info | Returns general information about your application, such as its version number. |
/actuator/metrics | Returns metrics information about your application, such as the number of HTTP requests it has processed. |
/actuator/env | Returns information about your application’s environment, such as the values of its properties. |
/actuator/mappings | Returns information about the endpoint mappings in your application. |
/actuator/beans | Returns information about the beans in your application. |
/actuator/configprops | Returns information about the configuration properties in your application. |
To use Spring Boot Actuator, you simply need to add the spring-boot-starter-actuator
dependency to your pom.xml
file:
1 2 3 4 |
<dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-actuator</artifactid> </dependency> |
By default, only the /actuator/health
and /actuator/info
endpoints are enabled in a Spring Boot application. To enable other endpoints, you can add the following properties to your application.properties
or application.yml
file:
1 2 |
management.endpoints.web.exposure.include=* |
This will enable all endpoints. You can also enable specific endpoints by listing them in the include
property, separated by commas. For example:
1 2 |
management.endpoints.web.exposure.include=health,info,metrics |
Note that for security reasons, it’s recommended to limit the exposure of the endpoints to only those that you need to use.