Spring Boot Actuators – Customizing Actuator Endpoint

Spring Boot Actuators – Customizing Actuator Endpoint

SpringBoot – Actuators (Example here)
Spring Boot Actuator brings in several production grade services to your application. Spring Boot Actuators has various number of built-in endpoints.

Actuators helps us monitor and interact with your application. Spring Boot also lets us to create our own endpoints too. These end points can be both enabled or disabled.

We have already seen in-build actuator endpoints here – Spring Boot Actuators – in-built EndPoint.

Let us see how to customize the already existing endpoint. Let us override the /actuator/health endpoint.

To override the health endpoint we will be extending a class – AbstractHealthIndicator

AbstractHealthIndicator:
Class which has base health indicator implementations and encapsulates creation of health and error handling. This will override the method – protected abstract void doHealthCheck(Health.Builder builder) throws Exception.

Let us see an example,

pom.xml

application.properties

ControllerSample.java

App.java

Now without customizing endpoint, if we run the application

Now let us override the health endpoint,

Output after overriding the healthIndicator,


Download this example here

 

 

 

Leave a Reply

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