我们在生产中有一个弹簧应用程序。它不是 Spring-boot。我发现这篇关于如何在非弹簧引导应用程序中使用弹簧引导执行器的帖子。
但是,我们的要求是聚合来自 /metrics 端点的数据并对其进行一些分析并报告状态指示器。
例如,我们可能会使用堆参数
{"heap.committed":480768,"heap.init":262144,"heap.used":294461,"heap":3728384,"threads.peak":37}
来指示应用程序的状态 - FATAL、WARN 或 HEALTHY。
这只是一个例子。我们的要求更复杂。事实上,我们已经有了一个status endpoint
想要添加更多信息的地方(基于来自 的数据/metrics
和/health
端点spring-boot-actuator
)。
我正在考虑实现这一点的一种方法是在应用程序中/metrics
和内部进行 REST 调用/health
,收集数据,聚合它们并返回响应。我不认为这是推荐的方式。
如果有一个 bean 可以直接提取这些参数,我会自动装配它并在需要时动态计算它们。(事实上,我会安排定期计算)。
我对从/metrics
. 同时我也对以下内容感兴趣/health
。
{"diskSpace":{"status":"UP","free":386186194944,"threshold":10485760}}
我应该自动装配什么豆子并免费获得这些属性!
谢谢
编辑
这个帖子有@Autowired MetricRepository
。但由于某种原因,它只返回自定义计数器属性。它不返回堆、内存信息等例如:
Reporting metric counter.calls.get_greeting=4
Reporting metric counter.calls.get_greeting.1=1
Reporting metric counter.calls.get_greeting.2=1
Reporting metric counter.calls.get_greeting.3=1
Reporting metric counter.calls.get_greeting.4=1
Reporting metric counter.status.200.greeting.number=4
Reporting metric counter.status.404.star-star=1