为什么 `count_over_time` 没有匹配原始数据就增加了?

Why does `count_over_time` increase without matching raw data?

... 或 "How does count_over_time work?"

给定以下向量和值:

kube_job_created{
  app="prometheus",
  chart="prometheus-7.1.0",
  component="kube-state-metrics",
  heritage="Tiller",
  instance="100.96.2.23:8080",
  job="kubernetes-service-endpoints",
  job_name="foobar-24150",
  kubernetes_name="prometheus-kube-state-metrics",
  kubernetes_namespace="devops",
  namespace="devops",
  nodename="ip-1-1-1-1.ap-southeast-2.compute.internal",
  release="prometheus"
} 1538008393

计算整个向量 returns 1:

count(kube_job_created{app="prometheus",chart="prometheus-7.1.0",component="kube-state-metrics",heritage="Tiller",instance="100.96.2.23:8080",job="kubernetes-service-endpoints",job_name="braze-user-attribute-sync-24150",kubernetes_name="prometheus-kube-state-metrics",kubernetes_namespace="devops",namespace="devops",nodename="ip-10-10-4-112.ap-southeast-2.compute.internal",release="prometheus"})

结果:

{} 1

现在,count_over_time 取决于范围向量选择器:

1米:

count_over_time(kube_job_created{app="prometheus",chart="prometheus-7.1.0",component="kube-state-metrics",heritage="Tiller",instance="100.96.2.23:8080",job="kubernetes-service-endpoints",job_name="braze-user-attribute-sync-24150",kubernetes_name="prometheus-kube-state-metrics",kubernetes_namespace="devops",namespace="devops",nodename="ip-10-10-4-112.ap-southeast-2.compute.internal",release="prometheus"}[1m])

结果为“2”:

{app="prometheus",chart="prometheus-7.1.0",component="kube-state-metrics",heritage="Tiller",instance="100.96.2.23:8080",job="kubernetes-service-endpoints",job_name="braze-user-attribute-sync-24150",kubernetes_name="prometheus-kube-state-metrics",kubernetes_namespace="devops",namespace="devops",nodename="ip-10-10-4-112.ap-southeast-2.compute.internal",release="prometheus"} 2

随着时间的推移,它到底在计算什么?

count_over_time 计算每个时间序列范围内的样本数。与所有 _over_time 函数一样,它一次适用于一个时间序列的所有样本。

如果您想要即时向量中的时间序列数量,那么 count 聚合器会告诉您。