我通过Terraform的Helm设置了Prometheus,它被配置为连接到我的库伯内特斯集群。我打开我的Prometheus,但我不确定从列表中选择哪个指标才能查看运行pod/作业的CPU/MEM。以下是使用该命令运行的所有pod(test1是库贝命名空间):
kubectl -n test1 get pods
吊舱运行
当我在Prometheus上时,我看到许多与CPU相关的指标,但不确定该选择哪一个:
促销1
我试图选择一个,但是命名空间 = 普罗米修斯,它使用 prometheus-node-exporter
,我在这里的任何地方都看不到我的集群或我的命名空间 test1
。
促销2
请你帮帮我好吗?非常感谢。
我刚才再次尝试重新运行作业(模拟作业),并尝试在作业仍处于运行模式时执行prometheus查询,但没有得到任何结果:-(这里可以看到我的作业正在运行。
node_cpu_seconds_total
是节点导出器
中的一个度量,该导出器带来机器统计信息,其度量前缀为node_
。您需要来自cAdvisor
的度量,该度量生成与容器相关的度量,并且前缀为container_
:
container_cpu_usage_seconds_total
container_cpu_load_average_10s
container_memory_usage_bytes
container_memory_rss
这里有一些基本的查询供您开始使用。准备好它们可能需要调整(您可能有不同的标签名称):
sum(irate(container_cpu_usage_seconds_total{container!="POD", container=~".+"}[2m])) by (pod)
sum(container_memory_usage_bytes{container!="POD", container=~".+"}) by (pod)
请注意,具有主机
网络模式(非隔离)的 Pod 会显示整个节点的流量速率。* 8
是为了方便起见,将字节转换为位(MBit/s、GBit/s 等)。
# incoming
sum(irate(container_network_receive_bytes_total[2m])) by (pod) * 8
# outgoing
sum(irate(container_network_transmit_bytes_total[2m])) by (pod) * 8