In Spring Boot, Actuator allows you to monitor your application, by just adding a dependency in you pom.xml. By adding this dependency we can able to track health check of the application. This will help on production environment, to check the application is running or not?.
Let see how to implement this,
Create a spring boot application using Spring initializr . To test actuator we need to select spring-boot-starter-actuator along with spring-boot-starter-web(without this we cannot start the server).
Here my project specification, Using java 8, Maven Project .
To Start application we need to do mvn clean install. Once that done we are good to start the server.
While starting the server we will see following log that confirm that we are enabling the actuator.
Here are three default actuator to check and monitor the application.(health, info and actuator). Here my server started on port 8081. Let me hit my server using http://localhost:8081/actuator. See the below JSON format available monitoring methods. Remember we need to call get method not post.
Add below code in your application.properties to expose all the monitoring method.
management.endpoints.web.exposure.include=*
Here let check server log after exposing all the monitoring methods,
We can see 14 endpoints exposed. Here output is like below,
I captured part of the output.
This will enable expose all the method available in spring boot monitoring.
Or we can add specific property by using below,
management.endpoint.health.enabled=true
management.endpoint.loggers.enabled=true
And let see what we can see by calling endpoint actuator/health
by calling http://localhost:8081/actuator/beans we can see what are the bean
initialized on server start of the this application.
No comments:
Post a Comment