...或“ 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
随着时间的推移到底是什么?
答案 0 :(得分:1)
count_over_time
对每个时间序列计算范围内的样本数。像所有_over_time
函数一样,它一次可跨一个时间序列的所有样本工作。
如果您想要即时矢量中的时间序列数,则count
聚合器会告诉您。