actuator–基础–02–endpoints
1、介绍
- Spring Boot 提供了所谓的 endpoints (端点)给外部,来访问应用程序。
- 举例:
- /health 端点 提供了关于应用健康情况的一些基础信息。
- metrics 端点 提供了一些有用的应用程序指标(JVM 内存使用、系统CPU使用等)。
- 举例:
- 原生端点
- Actuator 模块本来就有的端点称为原生端点
1.1、Actuator 模块分为三大类
1.1.1、应用配置类
获取应用程序中加载的应用配置、环境变量、自动化配置报告等与Spring Boot应用密切相关的配置类信息。
1.1.2、度量指标类
获取应用程序运行过程中用于监控的度量指标,比如:内存信息、线程池信息、HTTP请求统计等。
1.1.3、操作控制类
提供了对应用的关闭等操作类功能。
1.2、注意
- 每一个端点都可以通过配置来单独禁用或者启动
- Actuator 2.x 中的默认端点 增加了 /actuator前缀。
- Actuator 2.x 默认暴露的两个端点
- /actuator/health
- /actuator/info
- Actuator 2.x 除了默认暴露的两个端点,其余端点默认被禁掉。
2、Actuator 提供的所有endpoint
2.1、/actuator
- HTTP方法:GET
- 查看有哪些 Actuator endpoint 是开放的
2.2、/actuator/auditevent
- HTTP方法:GET
- 查看 audit 的事件,例如认证进入、订单失败,需要搭配 Spring security 使用
2.3、/actuator/beans
- HTTP方法:GET
- 查看运行当下里面全部的 bean,以及他们的关係
2.4、/actuator/conditions
- HTTP方法:GET
- 查看自动配置的結果,记录哪些自动配置条件通过了,哪些沒通过
2.5、/actuator/configprops
- HTTP方法:GET
- 查看注入带有 @ConfigurationProperties 类的 properties 值为何(包含默认值)
2.6、/actuator/env(常用)
- HTTP方法:GET
- 查看全部环境属性
- 可以看到 SpringBoot 载入了哪些 properties,以及这些 properties 的值
- 但是会自动*掉带有 key、password、secret 等关键字的 properties 的值,保护信息安全
2.7、/actuator/flyway
- HTTP方法:GET
- 查看 flyway DB 的 migration 信息
2.8、/actuator/health (常用)
- HTTP方法:GET
- 查看当前 SpringBoot 运行的健康指标,值由 HealthIndicator 的实现类提供(所以可以自定义一些健康指标资讯,加到这里面)
2.9、/actuator/heapdump
- HTTP方法:GET
- 取得 JVM 当下的 heap dump,会下载一个文档
2.10、/actuator/info
- HTTP方法:GET
- 查看 properties 中 info 开头的属性的值,没什么用
2.11、/actuator/mappings
- HTTP方法:GET
- 查看全部的 endpoint(包含 Actuator 的),以及他们和 Controller 的关係
2.12、/actuator/metrics(常用)
- HTTP方法:GET
- 查看有哪些指标可以看
- 举例:
- jvm.memory.max
- system.cpu.usage)
- 要使用/actuator/metrics/{metric.name}分別查看各指标的详细信息
- 举例:
2.13、/actuator/scheduledtasks
- HTTP方法:GET
- 查看定时任务的信息
2.14、/actuator/shutdown
- HTTP方法:POST
- 唯一一个需要 POST 請求的 endpoint,关闭这个 Springboot
2.15、/actuator/caches
- HTTP方法:GET
- 暴露可用的缓存。
2.16、/actuator/loggers
- HTTP方法:GET
- 显示和修改应用程序中日志的配置。。
2.17、/actuator/threaddump
- HTTP方法:GET
- 执行线程转储。