英文:
How to measure the total time of an asynchronous process using micrometer and prometheus (PromQL)?
问题
我有以下微服务场景
微服务 1
1 - 收集 System.getCurrentTimeMillis
2 - 在数据库中的操作后生成一个id
3 - 这个步骤应该将ID和操作的初始时间发送到 Prometheus
微服务 7
1 - 使用在第一个微服务中生成的ID完成处理信息
2 - 收集 System.getCurrentTimeMillis
3 - 这个步骤应该将ID和操作的结束时间发送到 Prometheus
我应该如何实现第3步,然后使用 PromQL 来测量总事务时间?
如果可能的话,数据可以像显示 HTTP 请求的显示方式一样,在 Prometheus 中显示为一个直方图。
英文:
I have the following microservices scenario
Microservice 1
1 - Collect a System.getCurrentTimeMillis
2 - Generate an id after an operation in the DB
3 - This step should send the ID and the initial time of the operation to Prometheus
Microservice 7
1 - Finish processing the message with the ID generated in the first microservice
2 - Collect a System.getCurrentTimeMillis
3 - This step should send the ID and the final time of the operation to Prometheus
How can I implement step 3 and then use PromQL to measure the total transaction time?
The data can be displayed in prometheus as a histogram as in the display of http requests if possible.
答案1
得分: 1
你所描述的方法实际上并不是 Prometheus 的预期用法。你正在描述日志记录或跟踪。(参见Zipkin,Jaeger等)
发送到 Prometheus 的指标是聚合的。因此,你通常无法将个别调用分开。(任何用于使其工作的黑客方法都无法很好地扩展)
Micrometer/Prometheus 最适合用来跟踪处理过程中各个步骤的聚合持续时间。
英文:
The method you've described isn't really how Prometheus is intended to be used. You are describing logging or tracing. (See Zipkin, Jaeger, etc)
Metrics sent to Prometheus are in aggregate. So you won't (typically) be able to tease out individual calls. (Any hacks used to make it work won't scale very far)
Micrometer/Prometheus would be best used to track the aggregate durations the individual steps of your processing are taking.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论