Off the top of my head it seems this should be: avg_over_time(watts[24h]) * 
24
If you tried this please say what went wrong.

An alternative would be: sum_over_time(watts[24h:1m]) / 60.
This uses a subquery to produce a value every 1 minute, adds them all up to 
give a total in Watt-minutes, then divides to get Watt-hours.

Using the counter: increase(watt_hours_total[24h]).

Set the Step in Grafana to 24h to get one point per day.
Set an "Absolute time range" with From=now-31d/d and To=now-1d/d to get 30 
days ending midnight yesterday.

Bryan

On Monday, 6 January 2025 at 09:45:21 UTC [email protected] wrote:

> Is there a way to do something like GROUP BY in PromQL?  My use case is to 
> convert Watts to Watt-Hours.  I have a gauge metric measuring instantaneous 
> power consumption every minute.  I want to calculate the daily consumption 
> to display in Grafana as a time series with one bar per day over a 30 day 
> period.
>
> I found a thread here describing how to do this with Influx, but I can't 
> figure out how to do this in Prometheus.  I've tried a bunch of variations 
> of sum_over_time and avg_over_time. 
> https://community.grafana.com/t/calculate-energy-consumsion-manually/45739/2
>
> Alternatively, my energy monitor device also records Watt-hours as a 
> counter metric which resets every day.  I'm not sure if that would make 
> this any easier...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/prometheus-users/81eca41a-38de-416c-9a00-542226b681dbn%40googlegroups.com.

Reply via email to