简体   繁体   English

如何在Prometheus中绘制各个Summary指标实例的图?

[英]How to graph individual Summary metric instances in Prometheus?

I'm using Prometheus' Summary metric to collect the latency of an API call. 我正在使用Prometheus的“ Summary指标来收集API调用的延迟。 Instead of making an actual API call, I'm simply calling Thread.sleep(1000) to simulate a 1 second api-call latency value -- this makes the Summary hold a value of .01 (for 1 second of latency). 而不是进行实际的API调用,我只是调用Thread.sleep(1000)以模拟一个1秒钟的api调用等待时间值-这使Summary的值保持为0.01(对于1秒钟的等待时间)。 But if, for example, I invoke Thread.sleep(1000) twice in the same minute, the Summary metric ends up with a value of .02 (for 2 seconds of latency), instead of two individual instances of .01 latency that just happened to occur within the same minute. 但是,例如,如果我在同一分钟内两次调用Thread.sleep(1000) ,则“ Summary指标的最终值为.02(对于2秒钟的延迟),而不是两个单独的.01延迟实例恰巧发生在同一分钟内。 My problem is the Prometheus query. 我的问题是Prometheus查询。 The Prometheus query I am currently using is: rate(my_custom_summary_sum[1m]) . 我当前使用的Prometheus查询是: rate(my_custom_summary_sum[1m])

What should my Prometheus query be, such that I can see the latency of each individual Thread.sleep(1000) invocation . 我的Prometheus查询应该是什么,这样我就可以看到每个单独Thread.sleep(1000)调用的延迟。 As of right now, the Summary metric collects and displays the total latency sum per minute. 截至目前,“ Summary度量标准收集并显示每分钟的总延迟总和。 How can I display the latency of each individual call to Thread.sleep(1000) (ie the API request)? 如何显示对Thread.sleep(1000) (即API请求)的每个单独调用的延迟?

private static final Summary mySummary = Summary.build()
                                        .name("my_custom_summary")
                                        .help("This is a custom summary that keeps track of latency")
                                        .register();

Summary.Timer requestTimer = mySummary.startTimer(); //starting timer for mySummary 'Summary' metric
        Thread.sleep(1000); //sleep for one second
        requestTimer.observeDuration(); //record the time elapsed

This is the graph that results from this query: Prometheus graph 这是该查询产生的Prometheus图

Prometheus is a metrics-based monitoring system, it cares about overall performance and behaviour - not individual requests. Prometheus是基于指标的监视系统,它关心整体性能和行为-而不是单个请求。

What you are looking for is a logs-based system, such as Graylog or the ELK stack. 您正在寻找的是基于日志的系统,例如Graylog或ELK堆栈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM