management.endpoint.health.group.readiness.include=* 错误 - Spring 引导执行器

management.endpoint.health.group.readiness.include=* bug - Spring Boot Actuator

A bug in Spring Boot Actuator exists 如果使用某些属性,management.endpoint.health.probes.add-additional-paths=true 将无法在 /readyz 处公开就绪端点和 /livez 处的活动端点。您会收到一个白标错误页面。

This application has no explicit mapping for /error, so you are seeing this as a fallback.

这些属性包括:

management.endpoint.health.group.readiness.include=
management.endpoint.health.group.liveness.include=
management.endpoint.health.group.liveness.show-details=
management.endpoint.health.group.readiness.show-details=

我需要默认使用管理端口,这样才能使用/actuator/metrics进行监控。因此,为了进行可靠的健康检查,我需要在 main/application 端口上公开 liveness 和 readiness 端点,这就是 management.endpoint.health.probes.add-additional-paths=true 的目的。

如果我由于这个错误而无法在我的就绪状态检查中包含额外的检查,Spring Boot Actuator 将无法使用。是否有一种解决方法可以允许包含额外的检查,同时仍然允许在 main/application 端口上成功公开就绪性和活性端点?

我已经尝试使用 management.endpoint.health.group.readiness.additional-path=server:/readyz。这不起作用。

我正在使用 Spring 引导版本 2.6.5。

您可以使用以下配置分别在 :8080/livez:8080/readyz 提供 liveness 和 readiness 健康组,并提供完整的详细信息:

management.endpoint.health.group.liveness.additional-path=server:/livez
management.endpoint.health.group.liveness.show-details=always
management.endpoint.health.group.readiness.additional-path=server:/readyz
management.endpoint.health.group.readiness.show-details=always
$ curl localhost:8080/livez
{"status":"UP","components":{"diskSpace":{"status":"UP","details":{"total":1000240963584,"free":468848824320,"threshold":10485760,"exists":true}},"livenessState":{"status":"UP"},"ping":{"status":"UP"},"readinessState":{"status":"UP"}}}

这显示与管理端口上的 liveness 健康组相同的信息:

$ curl localhost:8088/actuator/health/liveness
{"status":"UP","components":{"diskSpace":{"status":"UP","details":{"total":1000240963584,"free":468845608960,"threshold":10485760,"exists":true}},"livenessState":{"status":"UP"},"ping":{"status":"UP"},"readinessState":{"status":"UP"}}}

根据您在问题中的配置,用于此的完整配置如下:

management.server.port=8088

management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
management.endpoint.health.probes.enabled=true
management.endpoint.health.group.liveness.additional-path=server:/livez
management.endpoint.health.group.readiness.additional-path=server:/readyz
management.endpoint.health.group.readiness.show-details=always
management.endpoint.health.group.liveness.show-details=always