svalouch / rctmon

Pulls data from RCT Power GmbH devices for use with monitoring systems.
https://rctmon.readthedocs.io
GNU General Public License v3.0
17 stars 8 forks source link

Energy per Day / flux query question #23

Closed MichaelMMS closed 12 months ago

MichaelMMS commented 2 years ago

Hello,

I want to use the new implemented enery total data in flux with grafana. So i can see the energy per day in a bar chart. My query works but I have the use the flux group function. This group command returns a lot of columns, so the labels in grafana do not work anymore (see picture)

Bildschirmfoto 2022-06-29 um 19 00 01

I need to get two columns with the properties in one column within a array.

My query:

import "timezone"
option location = timezone.location(name: "Europe/Berlin")

from(bucket: "rct")
|> range(start: -4d, stop: 0d)
|> filter(fn: (r) => r["_measurement"] == "raw_data" and r["_field"] == "value_float")
|> filter(fn: (r) => r["name"] == "energy.e_dc_total[0]")
|> window(every: 1d)
|> last()
|> group()
|> difference()
Bildschirmfoto 2022-06-29 um 19 00 37

You can't use the aggregateWindow (which keeps lables working) because you will get the last day doubled and date shifted. Any idea to use the group command and get the lables working?

MichaelMMS commented 12 months ago

So, I use prometheus and it works like that:

Query A in Grafana: delta(rctmon_energy_solar_generator_sum[1d] offset -1d)

Query B in Grafana: delta(rctmon_energy_household_sum[1d] offset -1d) Screenshot 2023-10-04 155746 Screenshot 2023-10-04 155958