I - Introduction
As you may know the main problem with the production environment is how to access to log files, how to check configured properties ...
This Blog will introduce how to monitor a spring boot application deployed in production environment using spring boot actuator and spring boot admin UI.
Spring Actuator : is mainly used to expose operational information about the running application β health, metrics, info, dump, env, etc. It uses HTTP endpoints or JMX beans to allow us to interact with it.
Spring Boot Admin (SBA): Spring Boot Admin is a web application, used for managing and monitoring Spring Boot applications. Each application is considered as a client and registers to the admin server. Behind the scenes, the magic is given by the Spring Boot Actuator endpoints.
II - Quick Setup
First of all : configure Spring Boot Admin Server.
Add dependecies
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.1.1</version>
</dependency>
Enable Admin Server, (supposing that is running on 8080)
@EnableAdminServer
@SpringBootApplication
public class SpringBootAdminServerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootAdminServerApplication.class, args);
}
}
Second step : The spring boot application should expose actuator endpoints.
To enable actuator and mark the spring boot application as client for SBA Server, add the following dependencies to your application pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.1.1</version> <!-- depends on spring boot parent version used -->
</dependency>
on application yml or properties add this lines to disable security and to expose all endpoints (by default only /info and /health are enabled, the others are secured)
management.security.enabled=false
management.endpoints.web.exposure.include=*
spring.boot.admin.url=http://localhost:8080
III - References
For more detailed configuration and explanation, visit :
Spring Actuator Tutorial