Spring boot Spring启动执行器-多个运行状况端点

Spring boot Spring启动执行器-多个运行状况端点,spring-boot,amazon-elb,spring-boot-actuator,Spring Boot,Amazon Elb,Spring Boot Actuator,有没有办法在Spring引导应用程序上支持多个健康端点 原因如下:标准执行器健康检查很好,内置检查很好,定制选项很好-对于单个用例:报告一般应用程序健康 但我想从AWS弹性负载平衡器/自动缩放组中调用一些东西。默认情况下,如果某个实例未通过运行状况检查,ELB/ASG将终止该实例并用新实例替换它。问题是,如果数据库关闭,一些运行状况检查(如DataSourceHealthIndicator)将报告关闭,但我的应用程序实例在其他方面完全正常。如果我使用默认行为,AWS将抛出完全健康的实例,直到数据

有没有办法在Spring引导应用程序上支持多个健康端点

原因如下:标准执行器健康检查很好,内置检查很好,定制选项很好-对于单个用例:报告一般应用程序健康

但我想从AWS弹性负载平衡器/自动缩放组中调用一些东西。默认情况下,如果某个实例未通过运行状况检查,ELB/ASG将终止该实例并用新实例替换它。问题是,如果数据库关闭,一些运行状况检查(如DataSourceHealthIndicator)将报告关闭,但我的应用程序实例在其他方面完全正常。如果我使用默认行为,AWS将抛出完全健康的实例,直到数据库恢复,这将增加我的账单

我可以去掉DataSourceHealthIndicator,但我喜欢将其用于一般的健康检查目的。所以我真正想要的是两个独立的端点,用于两个不同的目的,例如:

/健康-一般应用健康 /ec2Health—忽略与EC2实例无关的方面,例如数据库中断


希望这是有意义的。

Spring Boot Actuator有一个名为的功能,允许您配置多个运行状况指示器

在application.properties中,配置所需的组:

management.endpoints.web.path-mapping.health=probes

management.endpoint.health.group.health.include=*
management.endpoint.health.group.health.show-details=never

management.endpoint.health.group.detail.include=*
management.endpoint.health.group.detail.show-details=always

management.endpoint.health.group.other.include=diskSpace,ping
management.endpoint.health.group.other.show-details=always
输出:

$ curl http://localhost:8080/actuator/probes
{"status":"UP","groups":["detail","health","other"]}

$ curl http://localhost:8080/actuator/probes/health
{"status":"UP"}

$ curl http://localhost:8080/actuator/probes/detail
{"status":"UP","components":{"diskSpace":{"status":"UP","details":{"total":0,"free":0,"threshold":0,"exists":true}},"ping":{"status":"UP"},"rabbit":{"status":"UP","details":{"version":"3.6.16"}}}}

$ curl http://localhost:8080/actuator/probes/other
{"status":"UP","components":{"diskSpace":{"status":"UP","details":{"total":0,"free":0,"threshold":0,"exists":true}},"ping":{"status":"UP"}}}

您使用的是哪个版本的spring boot?如果您只想检查应用程序是否能够响应HTTP请求,并且其外部资源没有中断,那么编写自己的健康检查就相当简单。根据所包含的内容,我会得到不同的向上/向下结果吗?这看起来像一个基本的查询/过滤机制,而不是以不同的方式评估运行状况的机制。是的,根据您选择的内容,您会得到不同的结果。我认为您选择的所有内容都需要健康,以便聚合指示器返回
“UP”
。例如,由于数据库中断,
运行状况
可以是
“下降”
,但是
其他
(来自我的示例)仍然可以返回
“上升”
,如果您的本地磁盘空间没有问题。