- Actuator brings production-ready features to our application
- Monitoring our app, gathering metrics, understanding traffic or the state of our database becomes trivial with it.
- Actuator is mainly used to expose operational information about the running application – health, metrics, info, dump, env, etc. It uses HTTP endpoints or JMX beans to enable us to interact with it.
- Once this dependency is on the classpath several endpoints are available for us out of the box. As with most Spring modules, we can easily configure or extend it in many ways.
To enable SpringBoot actuator we need to add below line in our build.gradle
implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.data:spring-data-rest-hal-browser:2.4.0.RELEASE'
Here are some of the most common endpoints Boot provides out of the box:
- /health – Shows application health information (a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated); it’s not sensitive by default
- /info – Displays arbitrary application info; not sensitive by default
- /metrics – Shows ‘metrics’ information for the current application; it’s also sensitive by default
- /trace – Displays trace information (by default the last few HTTP requests)
Configure existing endpoints :
Three properties are available:
- id – by which this endpoint will be accessed over HTTP
- enabled – if true then it can be accessed otherwise not
- sensitive – if true then need the authorization to show crucial information over HTTP
For example, add the following properties will customize the /bean endpoint:
endpoints.beans.id=springbeans endpoints.beans.sensitive=false endpoints.beans.enabled=true