Spring Boot Actuator:缓存 /actuator/health/readiness 和 /actuator/health/custom 健康检查结果
因此,我已将 Spring Boot Actuator 添加到我的应用程序中,并在 application.properties
属性 management.endpoint.health.cache.time-to-live=120s
中指定缓存健康检查结果。因此,当我调用 /actuator/health
时,结果会被缓存并且效果很好。
当我调用 /actuator/health/readiness
或自定义创建的组 /actuator/health/deep
时,问题就开始了,此请求结果不会被缓存。我浏览了 Spring Docs< /a> 只找到主要健康终点的信息,没有找到特定群体的信息。
所以我的问题是:我错过了什么吗?或者如何为特定的 Spring Boot 执行器端点实现缓存?
谢谢
So I have added the Spring Boot Actuator to my application and I specified in the application.properties
property management.endpoint.health.cache.time-to-live=120s
to cache health check results. So when I call /actuator/health
, the result is cached and it's good.
The problem starts when I call /actuator/health/readiness
or custom created group /actuator/health/deep
this request results are not cached. I went through Spring Docs and found only information for the main health endpoint, nothing for specific groups.
So my question is: did I miss sth? Or how can I implement caching for specific spring boot actuator endpoints?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我没有找到开箱即用的解决方案,所以决定采用 AOP 方法。
我找到了管理健康休息端点的
HealthEndpointWebExtension
类。该类有两个健康方法,其中一个调用公共
/health
端点,第二个调用health/
。因此,我围绕第二种方法创建了 Aspect,它允许我为我需要的端点添加缓存。
最后
application.properties
看起来像这样:So I didn't find out of a box solution, so decided to go with the AOP approach.
I found
HealthEndpointWebExtension
class that manages health rest endpoints.This class has two health methods, one one of them called for common
/health
endpoint and second when we callhealth/<group name>
.So I created Aspect around the second method, which allowed me to add cache for endpoints I need.
At the end
application.properties
looks like this: