Think about it, how did we monitor the monitoring status of a Java application before? Generally speaking, we will pass some commands on the Linux server, such as using jstat to count heap memory usage/garbage collection, and analyzing Java thread status through jstack. So for SpringBoot, in monitoring the health of the application, it provides a better simple and visual tool for us to use. This article will share this knowledge with you~
Monitoring plug-in: actuator
The introduction of the actuator plug-in is very simple, you only need to rely on the project (note that the version of the springboot must be consistent, otherwise an error may be reported):
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '1.5.15.RELEASE'
Then add configuration in application.properties (no authentication required):
management.security.enabled=false
After adding the dependency, we start the next project to see what changes:
Monitoring address
Monitor the overall status of the application and disk status
Describe environment variables in the form of json string
Thread dump file
Spring Boot Admin: Visual background management system
For spring actuator, the biggest disadvantage is that it is displayed in json format. In order to better monitor and display, we will introduce a more convenient tool: springbootadmin.
The architecture diagram of monitoring using springbootadmin is as follows:
springbootadmin monitoring
In layman's terms, if we have n springboot business systems that need to be monitored, then we need an additional springbootadmin application to monitor these clients, and a little configuration is needed between the client and the server.
Let's take a look at the sever side, the configuration of springbootadminserver:
Add dependency
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 annotation
@EnableAdminServer
Start the springbootadmin application:
The current client monitoring information is empty
Next, configure the client :
Add dependency
compilegroup:'de.codecentric',name:'spring-boot-admin-starter-client',version:'1.5.5'
Join configuration
Specify springbootadminserver configuration
After starting the client, enter the springbootadminserver monitoring interface, you will find:
Monitoring interface list
Client monitoring
On the monitoring interface, you will visually understand: environment variables, thread status information, class loading information (including dependent third-party jars), http request statistics (number and time), gc times and time statistics , Heap/non-heap memory usage, etc.
to sum up
Through this article, you should be able to understand that springboot has prepared a set of solutions for developers in monitoring, and through visual tools, monitoring becomes easy~