[英]Prometheus histogram buckets with ranges
I have a basic histogram that measures some dummy duration:我有一个基本的直方图,可以测量一些虚拟持续时间:
Histogram histogram = Histogram.build().name(name).help((String) metricData.get(HELP)).register(registry);
Histogram.Timer timer = histogram.startTimer();
logger.info("Sleeps for 1 milli");
Thread.sleep(1);
histogram.observe(timer.observeDuration());
My Prometheus histograms looks as follows:我的 Prometheus 直方图如下所示:
HELP myJob_histogram_no_buckets_test histogram with some info about something
TYPE myJob_histogram_no_buckets_test histogram
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.005"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.01"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.025"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.05"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.075"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.1"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.25"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.5"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="0.75"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="1"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="2.5"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="5"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="7.5"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="10"} 2
myJob_histogram_no_buckets_test_bucket{instance="",job="myJob",le="+Inf"} 2
myJob_histogram_no_buckets_test_sum{instance="",job="latrodectus"} 0.006341000000000001
myJob_histogram_no_buckets_test_count{instance="",job="latrodectus"} 2
I understand why all my buckets values Increased, but I don't understand two things:我明白为什么我所有的桶值都增加了,但我不明白两件事:
I saw this answer but I don't understand the solution我看到了这个答案,但我不明白解决方案
Thanks in advance!提前致谢!
I expected the values to be 1, what am I doing wrong in my source code?
我希望值是 1,我在源代码中做错了什么? why all values are 2?
为什么所有值都是 2?
You observed twice.你观察了两次。 If you're using
observeDuration
you don't also need observe
.如果您使用的是
observeDuration
,则您也不需要observe
。
How can I set the buckets to use ranges, instead of <=?
如何将存储桶设置为使用范围,而不是 <=?
You can't, this is how histogram_quantile
expects the buckets to be.你不能,这就是
histogram_quantile
期望桶的样子。
I think one way you can achieve this, is through regex.我认为您可以实现这一目标的一种方法是通过正则表达式。 For example,
例如,
le=~"([1-9]+)\\..*"
will give you all values that are greater than 0.9999会给你所有大于 0.9999 的值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.