Writing custom endpoints in Spring Actuator
Hello! recently I had to write some custom endpoints using Spring Actuator in a little Spring Boot application, in this short but pragmatic post I will show two ways of writing custom endpoints.
Requirements / Configuration
First of all you need to make sure you have the following dependency in your pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Now we require some slight changes to our application.properties or application.yml, depends on what you are using.
I want to expose all the endpoints, for that I will the following configuration:
management.endpoints.web.exposure.include=*
But you can also expose individual beans:
management.endpoints.web.exposure.include=env,beans,metrics
With the above configuration, you should be able to see something like this if you go to your browser and check localhost:8080/actuator