How would I graph cpu usage in grafana using Prometheus and the collectd exporter?

Drew Pierce picture Drew Pierce · Aug 1, 2018 · Viewed 11.4k times · Source

New to promql and I'm trying to graph cpu usage over time and I've found the following example getting a static percent of usage but how would I convert it to a rate for grafana?

100 * (1 - sum(collectd_cpu_total{type="idle"}) by (exported_instance) / sum(collectd_cpu_total) by (exported_instance))

I got this example from https://github.com/Naugrimm/promql-examples

Answer

Hang picture Hang · Aug 2, 2018

Since you are using Prometheus already, why don't you use Prometheus' node_exporter? https://www.robustperception.io/understanding-machine-cpu-usage

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