目前我正通过Prometheus.io监控码头集装箱。我的问题是我只是得到“cpu_user_seconds_total”或“cpu_system_seconds_total”。我的问题是如何将这个不断增加的值转换为CPU百分比?
目前我在查询:
rate(container_cpu_user_seconds_total[30s])
但我不认为它是正确的(与顶部相比)。
如何将cpu_user_seconds_total转换为CPU百分比? (就像在顶部)
Rate返回每秒的值,因此乘以100将得出一个百分比:
rate(container_cpu_user_seconds_total[30s]) * 100
我还发现这种方式可以使CPU使用率准确:
100 - (avg by (instance) (irate(node_cpu_seconds_total{job="node",mode="idle"}[5m])) * 100)
来自:http://www.robustperception.io/understanding-machine-cpu-usage/