SuperAPI AI 工具集

spring-boot-actuator

部署与运维

查看项目

更新于 10-15 21:53

技能介绍

用途:为 Spring Boot 服务提供生产级可观测性,涵盖 Actuator 端点、健康探针与 Micrometer 集成,标准化健康、指标和诊断配置,支持安全运维、SLO 报告与故障诊断。

主要能力:暴露并管理 Actuator 端点;通过 Spring Security 保护管理流量;配置 readiness/liveness 健康探针;将指标导出到 Prometheus、OTLP、Wavefront、StatsD 等;启用 /actuator/startup、/actuator/conditions、/actuator/httpexchanges 等诊断工具;自定义 HealthIndicator。

使用方式:在 Maven 或 Gradle 中加入 spring-boot-starter-actuator 依赖;用 management.endpoints.web.exposure.include 控制暴露端点,可调整 base-path;用 management.endpoint.health.probes.enabled=true 启用探针;用 management.metrics.export.* 激活导出器;用 EndpointRequest.toAnyEndpoint() 配置独立 SecurityFilterChain。验证命令如 curl http://localhost:8080/actuator/health。

适用场景:新服务或既有服务接入 Actuator、保护管理端口、为编排器定义健康探针、导出 Prometheus 指标、排查端点缺失或启动缓慢。

限制:避免在公网暴露 /actuator/env、/actuator/configprops、/actuator/logfile、/actuator/heapdump;生产环境端点必须认证;健康指示器不应阻塞事件循环线程或超过 250ms;需兼容 Spring Boot 3.5.x,旧版本可能缺少探针与 observation 特性;/actuator/beans 与 /actuator/mappings 会暴露内部结构,需谨慎。