bra*_*orm 11 spring-boot spring-boot-actuator
我们在生产中有弹簧应用.它不是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).
我正在考虑实现这一点的一种方法是在应用程序中调用REST /metrics并/health使用它,收集数据,聚合它们并返回响应.我不认为这是推荐的方式.
如果有一个bean我可以直接提取这些参数,我会自动将其自动计算并在需要时即时计算它们.(事实上,我会安排定期计算).
我对从中返回的所有属性感兴趣/metrics.而我也对以下内容感兴趣/health.
{"diskSpace":{"status":"UP","free":386186194944,"threshold":10485760}}
Run Code Online (Sandbox Code Playgroud)
我应该自动装配什么豆并免费获得这些属性!
谢谢
编辑
这篇文章有@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
And*_*son 26
从输出/metrics被产生MetricsEndpoint.它可以作为你可以拥有的豆子@Autowired.调用invoke它应该为您提供所需的数据.
您可以做同样的/health使用HealthEndpoint.
| 归档时间: |
|
| 查看次数: |
7190 次 |
| 最近记录: |