Spring Actuator /actuator/health返回DOWN但所有健康组均为UP
Spring Boot Actuator 健康检查异常问题排查
现象描述
调用/actuator/health接口返回状态为DOWN,但单独检查liveness、readiness健康组时均返回UP,执行curl命令结果如下:
$ curl localhost:10010/actuator/health {"status":"DOWN","groups":["liveness","readiness"]} $ curl localhost:10010/actuator/health/liveness {"status":"UP"} $ curl localhost:10010/actuator/health/readiness {"status":"UP"}
同时发现/actuator/health/probes或/actuator/health/ping接口返回空响应。
可能的原因
- 健康组聚合规则配置异常:Spring Boot 2.4+引入健康组机制后,默认的
/actuator/health端点会聚合所有健康指示器的状态,而非仅liveness和readiness组内的内容。如果存在未被纳入这两个组的健康指示器(比如自定义的第三方组件健康检查)返回DOWN,就会导致主端点状态为DOWN,但组端点仅检查组内配置的指示器,因此返回UP。 - 端点启用与映射配置错误:
/actuator/health/probes和ping端点未在配置中正确启用,比如management.endpoints.web.exposure.include属性未包含probes或ping;或者存在自定义的路径映射规则,导致请求无法正确路由到对应的端点处理逻辑,最终返回空响应。 - 版本兼容问题:Spring Boot与Spring Boot Actuator版本不匹配,或者引入的第三方健康检查依赖(如Spring Cloud生态组件)存在版本冲突,导致健康状态聚合逻辑异常,主端点状态计算错误,同时部分特殊端点无法正常生成响应内容。
- 自定义健康逻辑干扰:项目中自定义的
HealthIndicator或HealthEndpoint扩展类存在逻辑错误,比如在全局聚合时错误判定状态为DOWN,但在组检查时未触发该错误逻辑;或者自定义的端点处理器导致probes/ping端点无法正常输出响应内容。
内容的提问来源于stack exchange,提问作者Ignasi
相关产品推荐
相关产品推荐

