Spring-Boot--Actuator

The above is the official website's explanation of Actuator, which roughly means:

Spring Boot includes some additional features to help you monitor and manage your application when using Actuator. You can choose HTTP endpoint or JMX to manage and monitor your application. Auditing, health, and metrics can be automatically applied to your program.

The official announcement: Actuator manages and monitors your application, and it is very convenient to use because it can be automatically applied to your program.

Actuator use

Actuator is very easy to use, just add actuator dependencies to the pom.xml file:

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

When we manage and monitor our application, we need to use the endpoint provided by Actuator to access: http://{IP}:{port}/actuator/ {endpoint}

The above is just an example of a health endpoint, and you may find the following results when you use it for the first time:

The reason for this is because the default details of heanlth in 2.x will not be displayed. We need to configure in the configuration file yml:

management:
    endpoint:
      health:
        show-details: always

The above is just an example to introduce how to use Actuator. All endpoints of Actuator are listed below:

Among these endpoints, SpringBoot only exposes the health and info endpoints for us. If you want to use other endpoints, you need to configure them in the configuration file:

management:
    endpoints:
        web:
          exposure:
            include:  "*"

My configuration like this exposes all endpoints. For details, please refer to the official document https://docs.spring.io/spring-boot/docs/2.0.5.RELEASE/reference/htmlsingle/#production-ready

One thing to note is the shutdown endpoint, which is used to stop the program gracefully. This endpoint is not available or exposed by default, we need to enable and expose it through the configuration file:

management:
    endpoints:
        web:
          exposure:
            include:  "*"
    endpoint:
      shutdown:
        enabled: true

Graceful downtime using post requests

 

There are still differences between SpringBoot1.x and SpringBoot2.x. You need to check the official documents for details, so I won’t make a statement here.

 

Guess you like

Origin blog.csdn.net/u010994966/article/details/83061408