基于Prometheus中的速率了解histogram_quantile [英] Understanding histogram_quantile based on rate in Prometheus

查看:1371
本文介绍了基于Prometheus中的速率了解histogram_quantile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Prometheus文档,为了使用直方图指标获得第95个百分位数,我可以使用以下查询:

According to Prometheus documentation in order to have a 95th percentile using histogram metric I can use following query:

histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))

来源: https://prometheus.io/docs/practices/histograms/#quantiles

由于每个直方图桶都是一个计数器,我们可以将每个桶的速率计算为:

Since each bucket of histogram is a counter we can calculate rate each of the buckets as:

范围向量中时间序列的每秒平均平均增长率.

per-second average rate of increase of the time series in the range vector.

请参阅: https://prometheus.io/docs/prometheus/latest/querying/functions/#rate

例如,如果存储桶值[t-5m] = 100且存储桶值[t] = 200,则存储桶率[t] =(200-100)/(10 * 60)= 0.167

So, for instance, if bucket value[t-5m] = 100 and bucket value[t] = 200 then bucket rate[t] = (200-100)/(10*60) = 0.167

最后,最令人困惑的部分是,对于已知度量标准的所有存储桶速率,直方图量化函数如何找到给定度量的第95个百分位数?

And finally, the most confusing part is how can histogram_quantile function find 95th percentile for given metric knowing all the bucket rates?

有什么代码或算法可以让我更好地理解吗?

Is there any code or algorithm I can take a look to better understand it?

推荐答案

我相信做类似的事情(却没有/更简单).

I believe this is the code for it in prometheus
The general idea is that you use the data in the buckets to extrapolate / approximate the quantiles Elasticsearch also does something similar (yet different/much simpler) in their rollup capabilities

这篇关于基于Prometheus中的速率了解histogram_quantile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆