【发布时间】:2017-06-15 08:21:02
【问题描述】:
我想推送指标,例如通过 Spring Boot 应用程序中的 Pushgateway 向 Prometheus 发送 HTTP 请求或当前堆大小的处理时间。
我正在苦苦挣扎,因为有很多来自 Spring Metrics 或 Prometheus 的文档,但它们都没有解决我的具体问题。
最简单的方法是在 RestController 类上使用 @Timed 注释,如下所述:http://projects.spring.io/spring-metrics/
但是,我看不到,我可以在哪里为 pushgateway 配置 URL,并问自己 @Timed 注释是否只是将指标导出到应该从中提取它们的 /prometheus 端点。
然而,Prometheus 指南告诉我使用 simpleclient_pushgateway 库:https://github.com/prometheus/client_java#exporting-to-a-pushgateway
最后,还有一个名为simpleclient_spring_boot 的简单客户端,这是将Prometheus 集成到Spring Boot 中的第三种方式。
你能告诉我,我可以如何完成
A) 从基于注解的 HTTP 请求方法推送指标
B) 每 x 秒 JVM 指标的某种方法
C) 到可配置的(在application.yml 文件中)推送网关
非常感谢
【问题讨论】:
标签: spring-boot prometheus prometheus-pushgateway