Add Actuator to a spring boot application
Actuator is a spring boot module that allows to monitor and manage application usages in a production environment, without coding and configuration for any of them.
There are three main features of the Spring Boot Actuator:
- Endpoints
The actuator endpoints allow us to monitor and interact with the application. Spring Boot provides a number of built-in endpoints. We can also create our own endpoint. For example, the /health endpoint provides the basic health information of an application. - Metrics
It provides dimensional metrics by integrating with the micrometer. Micrometer is the instrumentation library powering the delivery of application metrics from Spring. It provides vendor-neutral interfaces for timers, gauges, counters, distribution summaries, and long task timers with a dimensional data model. - Audit
Spring Boot provides a flexible audit framework that publishes events to an AuditEventRepository. It automatically publishes the authentication events if spring-security is in execution.
Enabling Spring Boot Actuator
- Add the dependency to pom.xml file
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2. Add configuration to the application.properties file
##Different port for management APIs
management.server.port=8081##Different basepath for management APIs
management.endpoints.web.base-path=/management##Include all the endpoint APIs
management.endpoints.web.exposure.include=*##To expose only selected endpoints
#management.endpoints.jmx.exposure.include=health,info,env,beans,logfiles,loggers,prometheus,threaddump##Roles used to determine whether or not a user is authorized to be shown details.
#management.endpoint.health.roles="ROLE_ADMIN"
That's it. you can see your endpoints at base url /management

Detailed usage of Metrics and Audits are not covered in this article.
Resources:
https://www.javatpoint.com/spring-boot-actuator
https://howtodoinjava.com/spring-boot/actuator-endpoints-example/