Spring Boot Actuator中存在一个错误,如果使用某些属性,则management.endpoint.health.probes.add-additional-paths=true
无法在/readyz
处暴露就绪端点,在/livez
处暴露活跃端点。你会得到一个白标签错误页面。
此应用程序没有/error的显式映射,因此您将此视为一种退路。
这些属性包括:
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
进行监控。因此,为了进行可靠的健康检查,我需要在主/应用程序端口上公开活动性和就绪性端点,这就是management.endpoint.health.probes.add-additional-paths=true
的目的
如果由于此错误,我无法在准备状态健康检查中包括额外的检查,则Spring Boot Actuator对我来说将不可用。是否有一种变通方法可以允许包括额外检查,同时仍允许在主/应用程序端口上成功暴露准备状态和活跃度端点?
我已经尝试过使用management.endpoint.health.group.readiness.additional-path=server:/readyz
。这不起作用。
我使用的是SpringBoot2.6.5版本。
您可以使用以下配置分别在:8080/livez
和:8080/readyz
上提供活力和准备状态健康组,并提供完整的详细信息:
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"}}}
这显示了与管理端口上的活跃度健康组相同的信息:
$ 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