How can I get top 10 cpu usage processes ? The instance_cpu_time_ns metric missed

6,064 views
Skip to first unread message

itpr...@gmail.com

unread,
Apr 25, 2017, 4:33:25 AM4/25/17
to Prometheus Users
Hi

I would like gather data about top 10 cpu usage processes on the Linux host.

I read in a documentation https://prometheus.io/docs/querying/examples/ that it's possible using the instance_cpu_time_ns metric.

But when I try find what collector, in the node_exporter component, exposes that metric  I see that it's not implemented (?).

Do you have any suggestion how can I achieve it? Thank you!

Wojciech

Ben Kochie

unread,
Apr 25, 2017, 4:58:10 AM4/25/17
to itpr...@gmail.com, Prometheus Users
This is not something we recommend tracking with Prometheus.

The problem is that tracking individual processes is going to be an infinite namespace.  You would need to have a label for the PID, and the process name, in order to maintain uniqueness.  Some systems can generate thousands of processes per second, which is far too much cardinality churn for Prometheus.

If you use a supervisor like systemd or docker, you can use cAdvisor to expose container CPU usage metrics.  This would reduce the cardinality to container names, which would be much more possible to track.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/c56c557a-a9d5-419c-acc9-71945615200f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dhiren...@gmail.com

unread,
Jan 20, 2019, 1:28:32 PM1/20/19
to Prometheus Users
Hi

I am looking into similar check of top 3 cpu and memory and not using docker /containerization. Just would like to know how you implemented these checks ?

deependra...@paytm.com

unread,
Jan 25, 2019, 7:16:45 AM1/25/19
to Prometheus Users
yes, you can do it using process exporter and the use aggregation to plot your graphs in grafana. 

Refer below link to set up process exporter.

then use aggregation like, topk(3,cpu_system_seconds_total counter)

this query will give you top 3 cpu consuming processes.

dvme...@gmail.com

unread,
Jan 25, 2019, 4:09:23 PM1/25/19
to Prometheus Users
Thank you, Deependra. I will try it out.
Reply all
Reply to author
Forward
0 new messages