Using Spring Boot Actuator and Spring Boot Admin for Application Monitoring
This article explains how to integrate Spring Boot Actuator for exposing health and metrics endpoints, configure security, disable specific endpoints, and visualize monitoring data using JConsole and Spring Boot Admin, including necessary Maven dependencies and code examples, while also noting a promotional interview‑question PDF resource.
Spring Boot is well‑suited for building quickly iterated microservices, and its Actuator module provides built‑in monitoring capabilities with minimal effort.
1. Actuator Interface Description
To add monitoring, include the <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> dependency in pom.xml . Then disable security for the Actuator endpoints by adding management.security.enabled=false to the configuration file, which allows direct access to the Actuator URLs.
Typical Actuator endpoints include:
Path
Description
/health
Shows the process health status
/beans
Lists beans created by the application
/configprops
Configuration properties and values
/env
Environment properties
/info
Application info properties
/metrics
Metrics such as JVM and HTTP request stats
/trace
Detailed HTTP request trace
/mappings
All URL mapping relationships
/dump
Thread dump information
/heapdump
Heap dump information
If you need to disable a specific endpoint, for example the health endpoint, set endpoints.health.enabled=false in the configuration.
2. Monitoring Display
2.1 JConsole
JConsole, bundled with the JDK, can be launched via the jconsole command. It connects to a running Java process and shows detailed memory, CPU, and class information.
2.2 Spring Boot Admin
Spring Boot Admin is an open‑source UI for visualizing Actuator data. Add the following dependencies to a Spring Boot Admin Server project:
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>1.5.7</version>
</dependency>Configure the server port (e.g., server.port=8090 ) and register it with Eureka. Enable the admin server in the main class with annotations:
@SpringBootApplication
@EnableDiscoveryClient
@EnableAdminServer
@EnableTurbine
public class HtsApplication {
public static void main(String[] args) {
SpringApplication.run(HtsApplication.class, args);
}
}Access the admin UI at http://localhost:8090 . To monitor other Spring Boot applications, add the client starter dependency:
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>1.5.7</version>
</dependency>After the client starts, it registers with Eureka, and its metrics become visible on the admin UI.
3. FAQ
Spring Boot Admin can be configured to send email alerts; simply add your email settings. Both the admin server and the monitored applications must be registered with Eureka.
Promotional Note: The author also offers a downloadable PDF titled “第2版:互联网大厂面试题” containing 92 interview question PDFs (over 3,600 pages) covering Java, Spring, databases, big data, and more. Readers can obtain it by scanning the provided QR code.
Architect's Tech Stack
Java backend, microservices, distributed systems, containerized programming, and more.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.