我有一个基本的直方图,可以测量一些虚拟持续时间:
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());
我的 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
我明白为什么我所有的桶值都增加了,但我不明白两件事:
- 我希望值是 1,我在源代码中做错了什么?为什么所有值都是 2?
- 如何将存储桶设置为使用范围,而不是 <=?
我看到了这个答案,但我不明白解决方案
提前致谢!