Prometheus node_exporter promql query to get aggregated daily peak (max) and avg CPU utilisation per node

75 Views Asked by At

What I need to obtain is a daily aggregation of the avg and max (peak) CPU utilisation per node/instance. So, the metric in question is:

node_cpu_seconds_total{mode!="idle"}

Exposed by node_exporter.

It's worth noting that I took a look at Promql difference between max and max_over_time but this seems to relate to getting the max and avg across multiple time series, whereas I only need it on one.

My ultimate goal is to export the data as CSV from Grafana (Inspect->Data->Download CSV), however, if there's an easier way by using the Prometheus API directly, I'm happy to do that instead.

In case you're familiar with Oracle Enterprise Manager, the query made to generate the report there is:

select target_name, sum(average) CPU_AVE, sum(maximum) CPU_MAX, to_char(ROLLUP_TIMESTAMP,'YYYY-MM-DD HH24:MI') TS_ROLLUP
      FROM SYSMAN.MGMT$METRIC_DAILY
      WHERE ROLLUP_TIMESTAMP > (sysdate -30) and target_name like 'servername'
        and (
                upper(COLUMN_LABEL) like upper('%CPU in User Mode%') or
                upper(COLUMN_LABEL) like upper('%CPU in System Mode %')
            )
    group by target_name,to_char(ROLLUP_TIMESTAMP,'YYYY-MM-DD HH24:MI')
   order by  TS_ROLLUP
;

Thanks in advance for any advice,

0

There are 0 best solutions below