1. 前言
Spring Boot 提供了很多开箱即用的starter,其中有一款非常特别的starter——actuator 。它是用来对Spring Boot 应用进行监控、指标采集、管理,并提供一些很有用的端点(endpoint)来实现上述功能。这有助于我们对Spring Boot 应用进行监视和管理。我们本文将探讨Spring Boot 2.x下的actuator的一些知识点。
2. 集成
像其它starter一样,通过非常简单的依赖集成即可开箱即用。我们通过在项目中引入(以maven为例):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
3. endpoints
Actuator的核心是端点(endpoint),我们通过端点来获取应用的一些监控信息或者通过端点来改变系统的一些状态。Actuator中内置了非常多的端点:
id | 描述 | 默认是否启用 |
---|---|---|
auditevents | 显示当前应用程序的审计事件信息 | Yes |
beans | 显示应用Spring Beans的完整列表 | Yes |
caches | 显示可用缓存信息 | Yes |
conditions | 显示自动装配类的状态及及应用信息 | Yes |
configprops | 显示所有 @ConfigurationProperties 列表 | Yes |
env | 显示 ConfigurableEnvironment 中的属性 | Yes |
flyway | 显示 Flyway 数据库迁移信息 | Yes |
health |