Hi,
i`m new on Prometheus. I want to calculate the Power Consumption for the Last Day and have as Base the Total Consumption of my Powermeter.
So i have to calculate the difference between Last Value of Total Consumption and the First Value of Present Day, the difference is the Today collected Consumption.
But how to do this in Prometheus ?
you can try this to resolve your problem
Step : 1 Prepare Prometheus Metric
Have a counter metric (e.g., total_consumption_metric) that continuously increases (simulating cumulative power consumption)
Step : 2 Create New Dashboard and Panel
Select Prometheus as data source.
Step : 3 write promql
Last value in last 24h
max_over_time(total_consumption_metric[1d])
Value at today’s consumption
total_consumption_metric offset (time() - (time() % 86400))
Calculate consumption difference:
total_consumption_metric - total_consumption_metric offset 1d
This will give 150 kWh - 100 kWh = 50 kWh, which is the total consumption for the last day
Step : 4 Setup Visualization as Time Series
unit = kw
Final Output look like this
1 Like