【问题标题】:How do I do a `count_over_time` with a `group_left` statement?如何使用 `group_left` 语句执行 `count_over_time`?
【发布时间】:2018-10-05 13:48:16
【问题描述】:

我想知道基于特定标签在 Kubernetes 中创建的作业数量。以下是我想出的。由于某些间隔之间存在间隔,我想随着时间的推移进行计数。

kube_job_created * on(job_name)
  group_left (label_cronjob_name)
  kube_job_labels{label_cronjob_name="sf-synch-abn"}

在哪里放置范围矢量选择器?

【问题讨论】:

    标签: prometheus promql


    【解决方案1】:

    我想你想要的是:

    count(
        count_over_time(kube_job_created[1h]) 
      * on(job_name) group_left (label_cronjob_name)
        count_over_time(kube_job_labels{label_cronjob_name="sf-synch-abn"}[1h])
    )
    

    【讨论】:

    • 谢谢布赖恩。 count_over_time 不会聚合kube_job_created 并且属性job_name 会丢失吗?
    • 布赖恩,这似乎行得通。我发现这有点违反直觉。可能是因为我的知识有限。
    猜你喜欢
    • 2016-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-17
    • 1970-01-01
    • 1970-01-01
    • 2016-03-11
    • 2020-04-14
    相关资源
    最近更新 更多