Ivan Savcic
Ivan Savcic

Reputation: 314

Prometheus average over a time period into Grafana table

I can't seem to figure out the Prometheus query to calculate the single value of, say, average CPU usage per instance over a time period and create the Grafana table out of it:

Period: last 3h
Instance A: CPU usage A
Instance B: CPU usage B

Simply put, I want to:

  1. select a time period in Grafana
  2. have Prometheus average the values per instance within that period to a single value
  3. use that data to populate a Grafana table

Any hints?

Thanks!

Upvotes: 3

Views: 5346

Answers (2)

So for example if I would like to get the CPU utilisation , does it mean that this promql will work well?

(((count(count(node_cpu_seconds_total{job="vi-prod-node-exporter-ec2-vsat2-spen"}) by (cpu))) - avg(sum by (mode)(rate(node_cpu_seconds_total{mode='idle',job="vi-prod-node-exporter-ec2-vsat2-spen"}[$__rate_interval])))) * 100) / count(count(node_cpu_seconds_total{job="vi-prod-node-exporter-ec2-vsat2-spen"}) by (cpu))

Upvotes: 1

Ivan Savcic
Ivan Savcic

Reputation: 314

To answer myself:

avg_over_time(instance:cpu_usage:irate[$__range])

Upvotes: 3

Related Questions