Spring Boot Actuator 是 Spring Boot 管方提供的监控组件。我们只需要在项目中添加该依赖就可以整合 Spring Boot Actuator
| 端点(Spring Boot 2.x) | 描述 | HTTP 方法 | 是否敏感 | 端点(Spring Boot 1.x) |
|---|---|---|---|---|
| conditions | 显示自动配置的信息 | GET | 是 | autoconfig |
| beans | 显示应用程序上下文所有的 Spring bean | GET | 是 | beans |
| configprops | 显示所有 @ConfigurationProperties 的配置属性列表 | GET | 是 | configprops |
| dump | 显示线程活动的快照 | GET | 是 | dump |
| env | 显示环境变量,包括系统环境变量以及应用环境变量 | GET | 是 | env |
| health | 显示应用程序的健康指标,值由 HealthIndicator 的实现类提供;结果有 UP、 DOWN、OUT_OF_SERVICE、UNKNOWN;如需查看详情,需配置:management.endpoint.health.show-details |
GET | 否 | health |
| info | 显示应用的信息,可使用 info.* 属性自定义 info 端点公开的数据 |
GET | 否 | info |
| mappings | 显示所有的 URL 路径 | GET | 是 | mappings |
| metrics | 显示应用的度量标准信息 |
添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.4.2</version>
</dependency>
mvn spring-boot:run
C:\Users\l\javademo\microservice-provider-user>curl http://localhost:8000/actuator/health
{"status":"UP"}
配置文件
management:
endpoint:
health:
# 是否展示健康检查详情
show-details: always
mvn spring-boot:run
sers\l\javademo\microservice-provider-user>curl http://localhost:8000/actuator/health {"status":"UP","components":{"db":{"status":"UP","details":{"database":"H2","validationQuery":"isValid()"}},"diskSpace":{"status":"UP","details":{"total":127357939712,"free":29238120 448,"threshold":10485760,"exists":true}},"ping":{"status":"UP"}}}
如果想暴露所有监控点
management:
endpoints:
web:
exposure:
include: ‘*‘
health:
# 是否展示健康检查详情
show-details: always
C:\Users\l\javademo\microservice-provider-user>curl http://localhost:8000/actuator/health
{"status":"UP"}
springcloud-整合 Spring Boot Actuator
原文:https://www.cnblogs.com/lzjloveit/p/14415421.html