长时间Prometheus费率查询
Prometheus rate query over a long period
当长时间使用 rate
函数时(例如 7d
)我收到错误 "query processing would load too many samples into memory in query execution"
.
我的查询是
histogram_quantile(0.90, rate(http_request_in_seconds_bucket[7d]))
发生此错误是因为 Prometheus a limit of samples 可以在内存中处理。
我用 added on Prometheus 2.7 的子查询解决了这个问题。
这允许您单独查询更小的时间间隔,然后将它们聚合在一起。
例如,我将查询更改为多个 24 小时子查询,然后将其平均在一起
histogram_quantile(0.90, avg_over_time(rate(http_request_in_seconds_bucket[24h])[7d:12h]))
还有其他解决方案:
- 通过更改标志来增加它可以处理的样本数
query.max-samples
(不推荐)
- 使用 Recording Rules - 推荐使用子查询,因为它减少了 prometheus 服务器的负载,但需要更多的努力来设置。
当长时间使用 rate
函数时(例如 7d
)我收到错误 "query processing would load too many samples into memory in query execution"
.
我的查询是
histogram_quantile(0.90, rate(http_request_in_seconds_bucket[7d]))
发生此错误是因为 Prometheus a limit of samples 可以在内存中处理。
我用 added on Prometheus 2.7 的子查询解决了这个问题。 这允许您单独查询更小的时间间隔,然后将它们聚合在一起。
例如,我将查询更改为多个 24 小时子查询,然后将其平均在一起
histogram_quantile(0.90, avg_over_time(rate(http_request_in_seconds_bucket[24h])[7d:12h]))
还有其他解决方案:
- 通过更改标志来增加它可以处理的样本数
query.max-samples
(不推荐) - 使用 Recording Rules - 推荐使用子查询,因为它减少了 prometheus 服务器的负载,但需要更多的努力来设置。