Divide node_exporter loadavg by CPU count doesn't show anything

15 views
Skip to first unread message

Ray Wu

unread,
Jun 13, 2020, 5:09:31 PM6/13/20
to Prometheus Users
I want to divide node_loadN by number of CPUs.

Both queries 

  node_load1{instance="hostname"}

and 

  count(node_cpu_seconds_total{instance="hostname",mode="idle"})

Returns expected results. But for query

  node_load1{instance="hostname"} / count(node_cpu_seconds_total{instance="hostname",mode="idle"})

,the returned result is empty. What did I do wrong?

Ray Wu

unread,
Jun 13, 2020, 7:16:42 PM6/13/20
to Prometheus Users
While reading other document, I found that both time series need to have matching labels. 
I have an extra label "region" for all metrics.

Aggregate on denominator "mode" doesn't make it work

  node_load5{instance="host"} / 
  sum without (mode) (count(node_cpu_seconds_total{instance="host",mode="idle"}))

The following query works thought

  sum without (instance, job, region) (node_load1{instance="host"}) / 
  sum without (mode) (count(node_cpu_seconds_total{instance="host",mode="idle"}))

but I really don't understand why

Ben Kochie

unread,
Jun 14, 2020, 3:54:33 AM6/14/20
to Ray Wu, Prometheus Users
You need to remove both cpu and mode for the labels to match:

node_load1 / count without (cpu,mode) (node_cpu_seconds_total{mode="idle"})

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/de03c9fa-4d5a-46ff-8b9c-76abeb1e5e5bo%40googlegroups.com.

Ray Wu

unread,
Jun 14, 2020, 3:01:30 PM6/14/20
to Prometheus Users
I see, thanks!


On Sunday, June 14, 2020 at 12:54:33 AM UTC-7, Ben Kochie wrote:
You need to remove both cpu and mode for the labels to match:

node_load1 / count without (cpu,mode) (node_cpu_seconds_total{mode="idle"})

On Sun, Jun 14, 2020 at 1:16 AM Ray Wu <ray...@gmail.com> wrote:
While reading other document, I found that both time series need to have matching labels. 
I have an extra label "region" for all metrics.

Aggregate on denominator "mode" doesn't make it work

  node_load5{instance="host"} / 
  sum without (mode) (count(node_cpu_seconds_total{instance="host",mode="idle"}))

The following query works thought

  sum without (instance, job, region) (node_load1{instance="host"}) / 
  sum without (mode) (count(node_cpu_seconds_total{instance="host",mode="idle"}))

but I really don't understand why


On Saturday, June 13, 2020 at 2:09:31 PM UTC-7, Ray Wu wrote:
I want to divide node_loadN by number of CPUs.

Both queries 

  node_load1{instance="hostname"}

and 

  count(node_cpu_seconds_total{instance="hostname",mode="idle"})

Returns expected results. But for query

  node_load1{instance="hostname"} / count(node_cpu_seconds_total{instance="hostname",mode="idle"})

,the returned result is empty. What did I do wrong?

--
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 promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages