Calculate enery consumption based on power

I have a shelly pro 3em and get data via MQTT to mosquitto → telegraf → influxdb. I want to get the energy consumption per day and over the time for 24hrs.

I struggle with the query.

The query returns the kW but no kWh. I do not know how to calculate the energy consumption in kWh and display ist as graph, shown in the image. Additionally I want to get a bar chart which shows the consumption day per day.

How do I need to adapt the queries accordingly?