Actuator in Spring Boot MicroServices

Actuator in Spring Boot MicroServices

We always need some tool that is used for monitoring our application. Spring boot provides Actuator for monitoring the application. It tells us the complete status of our application like status of our application, Information about our application, Beans detail of application and many more. We can see the actuator endPoint using hit the below URL

http://localhost:8080/actuator

For using this actuator endPoint you have to add the below dependency in your pom.xml file.

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

Now run your application and hit the above given URL you will get the response like below:

By default only health and info end point are available using HTTP if you want to show all the endPoint using HTTP, you have to add below property in your application.properties file.

management.endpoint.shutdown.enabled=true
management.endpoints.web.exposure.include=health,info,metrics,env,mappings,beans,shutdown

No hit the URL again now you will get the response like below:

By default if you hit the health or info URL it will give only specific information like below:

But if you want to see the complete health status and give information about your application using info endPoint you have to add the below property in your application.properties file.

management.endpoint.health.show-details=always

info.appInformation.name=Spring Actuator Example
info.appInformation.description=This is First Spring Boot Actuator Application Example
info.appInformation.version=1.1.1

Now hit the /health and /info URL again you will get the response like below:

Spring boot Actuator provide /shutdown endPoint using which we can shutdown our application. This is a post request if you hit the /shutdown URL with POST method your application will shutdown and you will get the response like below:

We know by default all the actuator endPoints are available on /actuator endPoint but if we want to change this URL and port we have to add the below property in application.properties file:

management.endpoints.web.base-path=/vasu
management.server.port=9009

Now our actuator endPoints are available on below URL:

http://localhost:9009/vasu/

Complete Code on GitHub: Actuator SpringBoot

Help Others, Please Share

Leave a Reply

Your email address will not be published. Required fields are marked *

x