一、SpringBoot Actuator
1.1、简介
未来每一个微服务在云上部署以后,我们都需要对其进行监控、追踪、审计、控制等。SpringBoot就抽取了Actuator场景,使得我们每个微服务快速引用即可获得生产级别的应用监控、审计等功能。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
1.2、1.x与2.x的不同
1.3、如何使用
- 引入场景
- 访问 http://localhost:8080/actuator/**
- 暴露所有监控信息为HTTP
management:
endpoints:
enabled-by-default: true #暴露所有端点信息
web:
exposure:
include: '*' #以web方式暴露
endpoint: #开启某个端点的具体配置
health:
show-details: always
测试:
http://localhost:8080/actuator/beans
http://localhost:8080/actuator/configprops
http://localhost:8080/actuator/metrics
http://localhost:8080/actuator/metrics/jvm.gc.pause
http://localhost:8080/actuator/endpointName/detailPath
1.4、可视化
GitHub - codecentric/spring-boot-admin: Admin UI for administration of spring boot applications
二、Actuator Endpoint
2.1、最常使用的端点
ID |
描述 |
|
暴露当前应用程序的审核事件信息。需要一个 |
|
显示应用程序中所有Spring Bean的完整列表。 |
|
暴露可用的缓存。 |
|
显示自动配置的所有条件信息,包括匹配或不匹配的原因。 |
|
显示所有 |
|
暴露Spring的属性 |
|
显示已应用的所有Flyway数据库迁移。 |
|