我发现对于某些图表,我从 Prometheus 获得双精度值,其中应该只是一个:
我使用的查询:
increase(signups_count[4m])
刮擦间隔设置为建议最大 https://stackoverflow.com/questions/40230057/what-is-the-maximum-scrape-interval-in-prometheus2分钟。
如果我查询实际存储的数据:
curl -gs 'localhost:9090/api/v1/query?query=(signups_count[1h])'
"values":[
[1515721365.194, "579"],
[1515721485.194, "579"],
[1515721605.194, "580"],
[1515721725.194, "580"],
[1515721845.194, "580"],
[1515721965.194, "580"],
[1515722085.194, "580"],
[1515722205.194, "581"],
[1515722325.194, "581"],
[1515722445.194, "581"],
[1515722565.194, "581"]
],
我看到只有两次增加。事实上,如果我查询这些时间,我会看到预期的结果:
curl -gs 'localhost:9090/api/v1/query_range?step=4m&query=increase(signups_count[4m])&start=1515721965.194&end=1515722565.194'
"values": [
[1515721965.194, "0"],
[1515722205.194, "1"],
[1515722445.194, "0"]
],
但 Grafana(以及 GUI 中的 Prometheus)倾向于设置不同的step
对于一个不熟悉 Prometheus 内部工作原理的人来说,我得到了一个非常意想不到的结果。
curl -gs 'localhost:9090/api/v1/query_range?step=15&query=increase(signups_count[4m])&start=1515721965.194&end=1515722565.194'
... skip ...
[1515722190.194, "0"],
[1515722205.194, "1"],
[1515722220.194, "2"],
[1515722235.194, "2"],
... skip ...
知道increase()
只是用于特定用例的语法糖rate()功能 https://stackoverflow.com/questions/38659784/graphing-slow-counters-with-prometheus-and-grafana,我想在这种情况下它应该是这样工作的。
如何避免此类情况的发生?我如何让 Prometheus/Grafana 在大多数情况下向我显示一对一、二对二?除了增加刮擦间隔(这将是我的最后手段)。
我明白普罗米修斯,所以如果我不是在任何时候,而是在大多数时间都有一个好的数字,那对我来说很好。
我在这里还缺少什么?