查询 Prometheus 时
process_cpu_seconds_total{instance="localhost:9090"}
我看到浏览器进行了一次调用,其中查询参数time中使用了当前时间:
curl 'http://localhost:9090/api/v1/query?query=process_cpu_seconds_total%7Binstance%3D%22localhost%3A9090%22%7D&time=1700078953.325' \
--compressed
结果
{"status":"success","data":{"resultType":"vector","result":[{"metric":{"__name__":"process_cpu_seconds_total","instance":"localhost:9090","job":"prometheus"},"
value":[1700078953.325,"0.82"]}]}}%
始终与作为查询参数给出的时间戳匹配。
当我查询范围向量时,结果接近我的预期,浏览器仍然使用当前时间作为查询参数,但在结果中通常不存在这个时间,因为指标仅每 15 秒抓取一次。
curl 'http://localhost:9090/api/v1/query?query=process_cpu_seconds_total%7Binstance%3D%22localhost%3A9090%22%7D%5B1m%5D&time=1700078953.325' \
--compressed
{"status":"success","data":{"resultType":"matrix","result":[{"metric":{"__name__":"process_cpu_seconds_total","instance":"localhost:9090","job":"prometheus"},"
values":[[1700078900.426,"0.8"],[1700078915.427,"0.8"],[1700078930.388,"0.82"],[1700078945.388,"0.82"]]}]}}%
当我们请求查询即时向量时,为什么普罗米修斯总是假装知道现在的值?