繁体   English   中英

Prometheus 长周期费率查询

[英]Prometheus rate query over a long period

当长时间使用rate function (例如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 在 memory 中可以处理的样本数量有限。

我用Prometheus 2.7 添加的子查询解决了这个问题。 这允许您单独查询较小的时间间隔,然后将它们聚合在一起。

例如,我将查询更改为多个 24 小时子查询,然后将其平均在一起

histogram_quantile(0.90, avg_over_time(rate(http_request_in_seconds_bucket[24h])[7d:12h]))

还有其他解决方案:

  1. 通过更改标志query.max-samples来增加它可以处理的样本数量(不推荐)
  2. 使用记录规则- 建议在子查询上使用,因为它减少了 prometheus 服务器上的负载,但需要更多的努力来设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM