Add Actuator to Spring Boot Application

Published by user on

In this article, we are going to understand how to add actuator to Spring Boot application. Actuator helps us to monitor our Spring Boot Application. Now Let’s see how to add it.

Step 1: Add Dependency to pom.xml
Step 2: Allow access to actuator endpoints
Step 3: Test if the actuator is working

Add Dependency to pom.xml

Add following dependency to your pom.xml and save it.

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Use the below link to get more information about actuator maven dependency.

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator

Allow access to actuator endpoints

Add the following entry to application.properties file to expose the actuator endpoint. You can also specify if you want to expose only few endpoints. As we are using * means we want to expose all endpoints.

management.endpoints.web.exposure.include=*

Test if the actuator is working

Hit the following URLs to test if the actuator is correctly integrated with the application.

http://localhost:8080/actuator
http://localhost:8080/actuator/metrics
http://localhost:8080/actuator/configprops

Conclusion

Integrating actuator is very important to monitor any application. Please ensure you enable security as well for the actuator endpoint.

Categories: Spring Boot