0

...或“如何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它根据范围矢量选择器而有所不同:

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

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

4

1 回答 1

1

count_over_time为每个时间序列计算范围内的样本数。像所有_over_time函数一样,它一次可以处理一个时间序列的所有样本。

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

于 2018-10-06T07:40:18.433 回答