Spring boot actuator

Spring boot actuator is part of Spring Boot from day one. Actuator helps us to Monitor application, traffic, health check-up, information related to caching. Actuators can be access via JMX or HTTP.

Below is the POM dependency helps us to include actuator in any of the application.

Below is the example to show how Spring Boot Actuator works.

Example

  1. Lets create a project using Spring Initilizr using link
  2. Fill Group and Artifact detail as com.javadoubts and practice respectively.
  3. Add dependencies as Spring Web and Spring boot actuator as mentioned in below screenshot.
  4. information as mentioned in below screenshot. Add dependencies as Spring Web and Spring boot actuator.

3. Unzip the downloaded file and import in eclipse. It will show below dependencies as part of pom.xml

4. Run application using Apache Tomcat and hit below URL will give below output as mentioned in screenshot.

http://localhost:8080/actuator

5. Below is the URL to check health of an application

Enable Actuators

Below line will help us to see application actuators apart from /shutdown. Line needs to paste inside application.properties file.

Include below line inside application.properties file to enable shutdown actuator:

management.endpoint.shutdown.enabled=true

Actuator Endpoints

Below are the various out of the box actuator endpoints used to get details related to application. We can create custom actuators also.

health: This provides health of the application.
http://localhost:8080/actuator/health

beans: This provides a list of all beans in the application.
http://localhost:8080/actuator/beans

shutdown: This will shutdown the application and by default disabled.
http://localhost:8080/actuator/shutdown

dump: Perform a thread dump.
http://localhost:8080/actuator/dump

loggers: Show and modify log configurations
http://localhost:8080/actuator/loggers

metrics: Show metrics information of the application. http://localhost:8080/actuator/metrics

mappings: Display all @RequestMapping paths of application. http://localhost:8080/actuator/mappings

env: Display all @RequestMapping paths of application. http://localhost:8080/actuator/mappings

Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.

0