Energy Stats query


I’m trying to build an energy dashboard with Grafana, but have problems with writing the correct PromQL queries.

My energy meter reports the total used energy in kWh sensor_energy_kwh{entity=“sensor.power_consumption”} as an instant vector.

I also write the actual cost for my electricity to the prometheus DB input_number{entity=“input_number.energy_cost”} as an instant vector.

With Grafana I want to calculate the electricity cost for a certain time frame (e.g. today, based on the timeframe selected) and display it as a gauge.

From my understanding I have to calculate the delta for each value for the power consumption and multiply this with the energy cost at the corresponding time. Summing up all this values should give me the total cost for the selected time frame.
How can I achieve this?

The delta() function seems not to be the right way. I don’t understand how the values are generated.

It would be great, if someone can help me.