【发布时间】:2020-08-01 07:40:43
【问题描述】:
想象一下这是我的http://localhost:8080/actuator ouotput:
{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"health": {
"href": "http://localhost:8080/actuator/health",
"templated": false
},
"prometheus": {
"href": "http://localhost:8080/actuator/prometheus",
"templated": false
},
"httptrace": {
"href": "http://localhost:8080/actuator/httptrace",
"templated": false
}
}
}
现在我已经将我的 prometheus 环境连接到 /actuator/prometheus 并且工作正常。我还希望 prometheus 读取我的 httptrace,所以我还在我的 prometheus 配置中添加了 /actuator/httptrace。但是,这不起作用。 httptrace端点is in json上的格式和prometheusis in yaml中的格式,我想我需要prometheus yaml中的httptrace。 Prometheus 吃 yaml 就好了,json 没那么多。
如何将我的 httptrace 从我的 Spring Boot 项目传递给 actuator/prometheus?最后,我的目标是获取 grafana 中每个请求的 timeTaken 值。
【问题讨论】:
-
Prometheus 正在摄取 open metrics 格式,yaml 和 json 都不起作用。此外,Prometheus 是一个时间序列数据库,它并非旨在跟踪每个请求,而是通过使用直方图或摘要来获得一些指标。
-
是的,我是这么想的,谢谢迈克尔。我希望有一些简单的方法可以将 json 数据转换为开放指标格式,但我认为这是不可能的。至于 B 计划,我将使用 micrometer 创建我自己的自定义指标,这些指标将添加到 prometheus 端点。使用 AOP @Around 注释,我可以对控制器函数计时,以了解它花了多长时间。这将是更多的工作,但它是可行的。
-
@scre_www 你有什么方法可以在 grafana 中为 httptrace 绘制图表吗?
标签: spring-boot prometheus micrometer actuator http-trace