Prometheus - 将cpu_user_seconds转换为CPU使用率%?

问题描述 投票:12回答:2

目前我正通过Prometheus.io监控码头集装箱。我的问题是我只是得到“cpu_user_seconds_total”或“c​​pu_system_seconds_total”。我的问题是如何将这个不断增加的值转换为CPU百分比?

目前我在查询:

rate(container_cpu_user_seconds_total[30s])

但我不认为它是正确的(与顶部相比)。

如何将cpu_user_seconds_total转换为CPU百分比? (就像在顶部)

performance performance-testing cpu-usage prometheus
2个回答
15
投票

Rate返回每秒的值,因此乘以100将得出一个百分比:

rate(container_cpu_user_seconds_total[30s]) * 100


8
投票

我还发现这种方式可以使CPU使用率准确:

100 - (avg by (instance) (irate(node_cpu_seconds_total{job="node",mode="idle"}[5m])) * 100)

来自:http://www.robustperception.io/understanding-machine-cpu-usage/

© www.soinside.com 2019 - 2024. All rights reserved.