springboot monitoring

1. What is spring-boot-starter-actuator

How does the springboot project check the configuration and running status? The official provides some interfaces to view the operation of the springboot project, just import spring-boot-starter-actuator, project integration:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2. Monitoring API

/autoconfig : View automatic configuration

 /beans : view beans

For security reasons, the monitored ports and access addresses can be set separately:

management.port=9000 # Access via port 9000

management.address=127.0.0.1 # Only allow local access

 /shotdown : close

Turn on the shutdown function:

endpoints: 
shutdown:
enabled: true #enable shutdown
sensitive: false #disable password authentication

After the execution is complete, the started project has been terminated.

Security settings, set the account password, only those who have the account password can shutdown

 1. Citing security

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
</dependency>

2. Enable security verification

endpoints:
  shutdown:
    enabled: true       #启用shutdown
    sensitive: true      #Enable shutdown security verification
    path: / testshutdown #Specify the path of the shutdown endpoint

management:
  port: 9000 #Specify the         management port
  address: 127.0.0.1 #Specify the    management IP
  security:
    role: SUPERUSER #role

security:
  user:
    name: admin #Authentication username
    password: 123 #Verify password

3. Postman requests shutdown 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325128639&siteId=291194637