Average over time

Hi.

I’m having a value
sum(power_watts{job="powerdc"})
which gives me a power usage of some devices.

What I want is the an average per calender month (e.g. 1.10. - 31.10.).
I’ve experimented with
sum(avg_over_time(power_watts{job="powerdc"}[4w]))
and I get values, but the make no sense. Can somebody help to build my monthly buckets?

1 Like

Your query looks perfectly fine to me, but what may be puzzling you is the fact that Grafana will ask Prometheus to run this same query at every interval point of the chart, so you get a sliding 4w average. If you want to slice the calendar into months and have single average monthly value displayed per month, you need to set the interval value in the query option (bottom row) to 4w.

1 Like

Sadly thats not what I’m looking for, since I want to have multiple averages from different month in one table/graph. E.g. power consumption from each month.

Could you sketch the table?

Did we find solution for this ?

1 Like

@schmil
If you add the month as a dimension to your data, the task becomes trivial.

@sskrlj thanks for mentioning the interval :slight_smile: