Think about how we used to monitor the monitoring status of a Java application. In general, we use commands on Linux servers such as jstat to count heap memory usage/garbage collection, JStack to analyze Java thread status, etc. So for SpringBoot, in the monitoring of application health, provides a better, easier and visual tools to use, this article will share this knowledge ~
Monitoring plug-in: Actuator
Importing the Actuator plugin is very simple, you only need to rely on it in the project (note that the version must be the same as springBoot, otherwise errors may be reported) :
Compile group: ‘org.springFramework. boot’, name: ‘spring-boot-starter-actuator’, version: ‘1.5.15.RELEASE’
Then add the configuration to application.properties (no authentication required) :
management.security.enabled=false
After adding dependencies, let’s launch the project to see what happens:
Monitor the address
Monitors the overall application status and disk status
Describe environment variables as JSON strings
Thread dump file
Spring Boot Admin: visual background management system
The biggest disadvantage of Spring Actuator is that it is displayed in THE form of JSON. In order to better monitor and display, we introduce a more convenient tool: Springbootadmin.
The architecture diagram for monitoring with springbootadmin is as follows:
Springbootadmin monitoring
In common terms, if we have n Springboot service systems to monitor, then we need an additional Springbootadmin application to monitor these clients, client and server need to do a little configuration.
Let’s start with the Sever side, springBootAdminServer configuration:
Join the rely on
Compile group: ‘de.codecentric’, name: ‘spring-boot-admin-server’, version: ‘1.5.5’
Compile group: ‘de.codecentric’, name: ‘spring-boot-admin-server-UI ‘, version: ‘1.5.5’
@ EnableAdminServer annotations
@EnableAdminServer
To start the SpringBootadmin application:
Currently, the client monitoring information is empty
Next, configure client:
Join the rely on
Compilegroup: ‘DE. Codecentric, name:’ spring – the boot – admin – starter – client ‘, version: ‘1.5.5’
Join the configuration
Specifies the springbootadminserver configuration
After starting the client and entering the springbootadminserver monitoring screen, you will find:
Monitoring Screen List
Client Monitoring
On the monitor screen, you can visualize: environment variables, thread status information, class loading information (including dependent third-party jars), HTTP request statistics (number and time), GC count and time statistics, heap/non-heap memory usage, and more.
conclusion
In this article, you should know that SpringBoot has a monitoring solution for developers that makes monitoring easy with visual tools