This article describes how to use HTTP to access Spring Boot (1.x and 2.x\color{red}{1.x and 2.x}1.x and 2.x) actuators

How does Spring Boot enable the Actuator Web Endpoints

Importing Actuator dependence

If springboot projects inherit spring-boot-starter-parent and use the starter dependencies, the dependencies can be added without the dependency version number

compile "org.springframework.boot:spring-boot-starter-actuator"
Copy the code

Otherwise, you need to add the dependent version number (consistent with the Spring Boot version number).

The compile "org. Springframework. The boot: spring - the boot - starter - physical: 2.0.7. RELEASE"Copy the code

Enabling a Web Endpoint

spring boot 1.x

In Spring Boot 1.x, all endpoints of Web are enabled by default and can be used directly

spring boot 2.x

In Spring Boot 2.x, only/Health and /info are enabled by default. If you want to access other endpoints, you need to enable them in the application.properties configuration file

Select several endpoints to open ⬇️

management.endpoints.web.exposure.include=["auditevents","health","info"]
Copy the code

Enable all endpoints ⬇️

management.endpoints.web.exposure.include=*
Copy the code
  • The yamL file belongs to the keyword, so it needs to be quoted ⬇️
management:
  endpoints:
    web:
      exposure:
        include: "*"   
Copy the code

If you want to enable /shutdown the endpoint ⬇️

management.endpoint.shutdown.enabled=true
Copy the code

If you want to expose all enabled Web endpoints except env⬇️

management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env
Copy the code

Begin to use

spring boot 1.x

Spring Boot 1.x accesses http://ip:port/ endpoint path \color{red}{http://ip:port/ endpoint path}http://ip:port/ endpoint path through postman get To directly access a running Spring Boot project

Path Example ⬇️

http://127.0.0.1:8121/health
Copy the code

spring boot 2.x

In spring boot 2.x, the /actuator\color{red}{/actuator}/actuator path is added in front of the endpoint path

Path Example ⬇️

http://127.0.0.1:8121/actuator/health
Copy the code

The common endpoint path of Spring Boot 1.x is ⬇️

HTTP method The path describe
GET /autoconfig An auto-configuration report is provided to record which auto-configuration criteria passed and which did not
GET /configprops Describes how configuration properties (including default values) are injected into beans
GET /beans Describes all beans in the application context and their relationships
GET /dump Gets a snapshot of thread activity
GET /env Gets all environment properties
GET /env/{name} Gets a specific environment attribute value based on the name
GET /health Reports the application’s health metrics, which are provided by the HealthIndicator implementation class
GET /info Gets the customization information for the application, provided by an attribute that starts with info
GET /mappings Describes all URI paths and their mapping to controllers (including Actuator endpoints)
GET /metrics Reports various application metrics, such as memory usage and HTTP request counts
GET /metrics/{name} Reports application metrics for the specified name
POST /shutdown Close the application to endpoints. Shutdown. Enabled is set to true
GET /trace Provide basic HTTP request tracing information (timestamp, HTTP, etc.)

Spring Boot 2.x endpoint path changes as follows: ⬇️

1. X endpoint 2. X endpoints (change)
/autoconfig Rename it to /conditions
/health There is now a management. The endpoint. Health. The show – the details option never, always, the when – authenticated, Rather than relying on the Sensitive flag to determine if the health endpoint must display all the details. By default, /actuator/ Health is open and does not show details.
/trace Rename it to /httptrace