Calculate power consumption (KWH) from prometheus wattage data

I’m currently trying to display the daily and monthly power consumption using the “estimated input power” metric retrieved from my PSU (hx1200i). I was able to get this metric into Grafana using the liquidctl-exporter. Now I’m trying to translate this into the total consumed power (kwh) per hour/day and month.

I found this forum post post in which a user tried to do this. However, I used Prometheus, and so I can not use the syntax used there.

To get a plot of the KWH per hour, I now use the following syntax:


When I try to take the sum of this to get the total power consumption, I cannot find the correct syntax.


Gives me a bad_data: 1:15: parse error: expected type range vector in call to function "sum_over_time", got instant vector error which makes sense. I therefore tried to convert my previous result into a range vector using:


But, I, however, get a bad_data: 1:73: parse error: ranges only allowed for vector selectors.

Therefore, does anybody know how to display the total power consumption on the Grafana dashboard based on Prometheus Power sensor data?

The solution turned out to be quite straight fowards:

sum_over_time(liquidctl_hidraw1_estimated_input_power[24h]) / (count_over_time(scrape_samples_scraped{job="liquidctl"}[1m]) * 60) / 1000 

In this (count_over_time(scrape_samples_scraped{job="liquidctl"}[1m]) retrieves the scrape frequency.