简体   繁体   中英

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!

回答我自己:

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

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM