Actuators in Spring boot

Introduction:

Springboot actuator is a sub project of springboot framework. It uses built in Http endpoints to expose operational information about any production ready application.

Main benefit of the library is we can get metrics information and monitor the health of production support application. we can easily know the status of the database whether it is up or down.

Java Dependency:

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

By default /health and /info endpoints are enabled in latest version of the library. and other endpoints are not advisable to expose in production environment without security.

we can check available actuator links by using localhost:8080/actuator endpoint. will get available actuator links in json format.

{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"health": {
"href": "http://localhost:8080/actuator/health",
"templated": false
},
"health-path": {
"href": "http://localhost:8080/actuator/health/{*path}",
"templated": true
},
"info": {
"href": "http://localhost:8080/actuator/info",
"templated": false
}
}
}

we can check health condition of the application by using localhost:8080/actuator/health endpoint. it will give status of the database server and any other server which is used in application while developing like Messaging queue server (RabbitMQ, ActiveMQ etc..)

templated field defines about default value of the actuator endpoint

{
"status": "UP",
"components": {
"diskSpace": {
"status": "UP",
"details": {
"total": 250438021120,
"free": 196929343488,
"threshold": 10485760,
"exists": true
}
},
"mongo": {
"status": "UP",
"details": {
"version": "4.4.9"
}
},
"ping": {
"status": "UP"
},
"rabbit": {
"status": "UP",
"details": {
"version": "3.8.2"
}
}
}
}

here we can know complete info about deployed application server capability and database version and status. see this application developed using rabbitmq dependencies so that server details also provided by /health endpoint.

How to expose all endpoints:

management.endpoints.web.exposure.include=*

In application.properties file we can expose all actuator endpoints by using above property.

How to expose specific endpoints:

management.endpoints.web.exposure.include=beans, mappings, info

by comma separate we can expose specific actuator endpoints.

How to exclude specific endpoints:

management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=sessions

There are other endpoints like /env, /trace, /shutdown, /metrics, mappings, /loggers etc.