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

 

 

 

Read More

Spring Boot Actuators – How to use it in application

SpringBoot – Actuators
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.

Below are some of the Spring Boot Actuator endpoints,

EndPoint Description
/actuator/health Basic health information of the application
/actuator/configprops list of all @ConfigurationProperties
/actuator/info Arbitrary Information
/actuator/auditevents audit events of the application
/actuator/httptrace HTTP trace information
/actuator/metrics Metrics information of the application
/actuator/mappings @RequestMappings in the application
/actuator/scheduledtasks Scheduled tasks in the application
/actuator/shutdown Shutdowns the application

Let us write a sample application to test the spring boot actuator end points.

pom.xml

add this property in application.properties,

application.properties

SampleController.java

App.java

Let us start the application,

 

Once the application is started, we can see the actuators are getting initialized. when we hit localhost:8080/actuator/{endpoint} we can see the information

Here are some sample endpoint outputs,

/actuator/health

/actuator/mappings

/actuator/httptrace

Download Example here

Read More