Grafana - Promql cumulative graph

Viewed 153

this seems like a pretty easy thing to do. Yet I cannot wrap my head around it.

I make some calculations depending on the average CPU Utilization for the last 15s and get a value based of that calculation. No I want a graph in Grafana which shows the cumulative result. E.g.

Time passed Current result Cumulative result
15s 5 5
30s 7 12
45s 6 18

At the moment my query looks something like:

sum (((1 - (avg by (cpu, instance) (rate(node_cpu_seconds_total{mode="idle"}[15s])))) * 2 + 4

This results in a graph plotting the current results. But I want a query plotting the cumulative results. When I try to wrap the whole query with a sum_over_time, I get the following exception: "expected type matrix in call to function "sum_over_time", got vector"

Thank you for your help

1 Answers

PromQL in Prometheus doesn't support functions for cumulative calculations. If you need cumulative calculations, then try VictoriaMetrics instead - its query language - MetricsQL - provides running_sum() function.

P.s.: I'm the author of VictoriaMetrics.

Related