Search code examples
prometheuspromql

How do I do a `count_over_time` with a `group_left` statement?


I would like to know the number of created jobs in Kubernetes based on a specific label. The following is what I came up with. Since there are gaps between certain intervals I would like to do a count over time.

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

Where do I place the range vector selector?


Solution

  • I think what you want is:

    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])
    )