Spring boot internally provides a spring-boot-actuator module for monitoring and managing spring boot applications.
How do I use the Spring-boot-actuator module?
Maven adds Spring-boot-actuator's start POMs
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</ Dependencies>
Then start the project, access the address http://localhost:8080/health, and see the following page:
{
status: ' Up ',
diskspace: {
status: ' Up ',
total:249779191808,
free:22231089152,
threshold:10485760
},
db: {
status: "Up",
database: "H2",
hello:1
}
}
This/health endpoint shows some of the health conditions that are currently applied.
Which dimensions of Spring boot are monitored from.
Spring provides a number of endpoints (endpoint) to monitor different dimensions, with some common endpoints listed below
/beans See what beans are in the spring factory
/dump all thread states in an application
/env information about the application environment
/mappings SPRINGMVC's request mapping mapping information
/configprops Spring configuration information such as data source spring configuration information
/metrics Metric Information
/health access to various health conditions
/info Display current app information
For details, refer to the documentation for the spring boot document
These are the native endpoints of Spring boot actuator
How do I turn off endpoints and set endpoints?
Custom endpoints are set by the endpoints+ end name + attribute names, separated by each segment.
1. You can modify the endpoint ID
Endpoints.beans.id=mybeans
The access address becomes http://localhost:8080/mybeans.
2. Turn on the endpoint
Endpoints.shutdown.enabled=true
3. Close the Endpoint
Close the Beans Endpoint
Endpoints.beans.enabled=false
4. Open only the desired endpoint
If only the desired endpoint is turned on, we can do so by closing all the endpoints and then opening the desired endpoint, for example
Endpoints.enabled=false
Endpoints.beans.enabled=true
Note: Sometimes the management port is protected by the firewall, will be reported 401 no access, this time can be configured
Management.security.enabled=false
To disable security management