通过查询将promql组的汇总分组为nulls

发布于 2025-02-03 09:25:03 字数 379 浏览 3 评论 0原文

目前,我正在计算minimum_over_time在1天长的间隔​​中,该查询已获得占位符选择器名称。当我计算结果时,一些组中有空。目前,我的查询具有以下结构:

(
  min_over_time(
    min 
      without(instance) 
      (app_traffic_usage{
            job=~"mobile|desktop",
            environment="production"})[1d:5m])
  or by (job) vector(0)
)

理想情况下,我希望或陈述分别为每个工作算,但是由于向量没有标签,因此它不起作用。感谢有关此事的任何帮助。先感谢您!

Right now I am computing the minimum_over_time for 1 day long intervals of a query that has been given placeholder selector names. When I compute the result, there are nulls in some of the groups. Currently, my query has the following structure:

(
  min_over_time(
    min 
      without(instance) 
      (app_traffic_usage{
            job=~"mobile|desktop",
            environment="production"})[1d:5m])
  or by (job) vector(0)
)

Ideally, I would like the OR statement to impute for each job individually, but because vector has no label, it does not work. Would appreciate any help on the matter. Thank you in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宁愿没拥抱 2025-02-10 09:25:03

尝试用min_over_time

min(
  min_over_time(app_traffic_usage{
    job=~"mobile|desktop",
    environment="production"}[1d]
  )
) without (instance)

以下方式交换min使用min_over_time

  1. 它在最后一天找到每个匹配系列的最小原始样本值。

  2. 然后,它从所有标签分组的步骤1中找到每组串联的最小值,除instance标签。

该查询与问题与原始查询之间的区别在于,原始查询使用。尽管此功能功能强大,但很难理解和正确使用:(看起来它在此处使用不当。

对于在任意时间序列中填充零的通用方法,或vector(0)< /code>在这些情况下,成语无法按预期工作。 rel =“ nofollow noreferrer”> Metricsql 如果您使用Victoriametrics而不是Prometheus,这是我使用的类似Prometheus的系统。

Try swapping min with min_over_time:

min(
  min_over_time(app_traffic_usage{
    job=~"mobile|desktop",
    environment="production"}[1d]
  )
) without (instance)

This query works in the following way:

  1. It finds the minimum raw sample values per each matching series during the last day.

  2. Then it finds the minimum values per each group of series from the step 1 grouped by all the labels except instance label.

The difference between this query and the original query from the question is that the original query uses Prometheus subquery feature. While this feature is powerful, it is hard to understand and use properly :( It looks like it was improperly used here.

As for the universal way for filling gaps with zeroes in arbitrary time series, the or vector(0) idiom doesn't work as expected in complex cases. In these cases you can use default 0 idiom from MetricsQL if you use VictoriaMetrics instead of Prometheus. This is Prometheus-like system I work on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文