当前位置: 首页 > 知识库问答 >
问题:

management.endpoint.health.group.readiness.include=*bug-Spring启动执行器

曹浩
2023-03-14

Spring Boot Actuator中存在一个错误,如果使用了某些属性,management.endpoint.health.probes.add-addresal-path=true在暴露/readyz处的就绪endpoint和/livez处的活动endpoint时不起作用。您会得到一个白标签错误页面。

此应用程序没有显式的/错误映射,因此您将其视为回退。

这些属性包括:

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=

默认情况下,我需要使用管理端口,以便可以使用执行器/指标进行监控。因此,为了进行可靠的健康检查,我需要在主/应用程序端口上公开活动性和就绪性endpoint,这就是management.endpoint.health.probe的目的。添加其他路径=true。

如果由于此错误而无法在准备状态健康检查中包含其他检查,Spring Boot Actuator对我来说将变得不可用。是否有一种解决方法可以允许包含其他检查,同时仍然允许在主/应用程序端口上成功公开准备状态和活动endpoint?

我已经尝试使用管理、endpoint、健康、组、就绪。其他路径=服务器:/readyz。这不起作用。

我使用的是Spring Boot版本2.6.5。

共有1个答案

淳于烈
2023-03-14

您可以使用以下配置分别在: 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
 类似资料:
  • 问题内容: 我一直在研究Spring / Spring MVC应用程序,并且希望添加性能指标。我遇到过Spring Boot Actuator,它看起来是一个不错的解决方案。但是我的应用程序不是Spring Boot应用程序。我的应用程序在传统容器Tomcat 8中运行。 我添加了以下依赖 我创建了以下配置类。 我什至可以按照StackOverflow另一篇文章的建议在每个配置类上添加 问题答案:

  • 我用的是Spring靴。为了监视JVM内存,我正在使用Spring Boot Actuator的/metricsendpoint。 我无法理解键实际上代表什么: 有人能告诉我它们到底是什么吗? CMS(并发标记扫描)和MarkSweepCompact相同吗?我应该使用CMS(并发标记扫描)吗?或者我应该使用哪种GC算法?

  • 我决定回到我的想法,将Kafka指标与Spring Boot Actuator集成,我在这里已经提到: https://github.com/spring-projects/spring-boot/issues/6227 到目前为止,我有一个单独的“沙盒”项目和工作代码,我想将其合并到Spring Boot中。现在我有点困惑了。我的部分测试需要powermock来模拟Kafka的“超级安全”类:

  • 我有一个带有Spring Security微服务的Spring Boot 2,我已使用米计/Spring Actuator配置了该微服务。当我在antMatcher("/驱动器/**")endpoint上permitAll()时,一切都很好。我能够通过正确配置的Prometheus yaml文件检索Prometheus指标。 但是,我的微服务不在防火墙后面,因此对世界开放。我只希望普罗米修斯能够访

  • 我正在我的项目中使用模块,该模块公开了要监视的RESTendpointURL 默认情况下,仅公开 和 终结点。 根据我的使用案例,我正在通过< code > application . properties 文件自定义endpoint。 我想了解,Spring启动究竟在哪里为和创建实际的endpoint,以及它如何通过HTTP公开它们?

  • 在我的Spring Boot应用程序(2.0.0.M7)中。我设置的属性 然而,当我击中 我得到404。 解决办法是什么?