Javarevisited
Published in

Javarevisited

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

  1. 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

base path /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/

--

--

--

A humble place to learn Java and Programming better.

Recommended from Medium

SKB — Scala Try

Password Generator with Python

Rethinking the spreadsheet: data entry

Spring Auto REST Docs 2017 Recap

Creating a 99% Invisible Reading List

Effective Beginner-Friendly Messaging for Dweb

How to make Dweb accessible to beginners? (Image source: element5digital on unsplash)

I found this great app called coincircle that gives you free money for simple tasks and the…

TryHackMe | Walking An Application Walkthrough

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Himanshu Pratap

Himanshu Pratap

System Administrator and Full stack web developer.

More from Medium

How To Build, Run and Test a Simple SpringBoot App in Docker — Lab Test Style

Contract Test — Spring Cloud Contract vs PACT

REST API Load performance testing with Apache JMeter

Multiple JDK / Java env setup on Mac