为什么`count_over_time`在不匹配原始数据的情况下增加?

时间:2018-10-05 22:18:32

标签: prometheus promql

...或“ 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="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

计算整个向量将返回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随范围矢量选择器而不同:

1m:

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
  • 1h返回120
  • 24小时返回2880

随着时间的推移到底是什么?

1 个答案:

答案 0 :(得分:1)

count_over_time对每个时间序列计算范围内的样本数。像所有_over_time函数一样,它一次可跨一个时间序列的所有样本工作。

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