Hi,
i’m Dario from Bochum, Germany and new to Influx 2.x (migrating from Influx 1).
I store data in a bucket and now, i want to aggregate that data using a task, which will called once every day.
To test it, i have raw data from one year in the test-bucket “sensors”
and i want to aggregate them in a bucket with infinite retention called “forever”.
This works as expected for
- mean values (4h window)
- min and max values (12h window)
with this queries:
from(bucket: "sensors")
|> range(start: -365d)
|> filter(fn: (r) => r["_measurement"] == "Weather")
|> filter(fn: (r) => r["_field"] == "SolarRadiation")
|> aggregateWindow(every: 4h, fn: mean)
|> set(key: "_field", value: "SolarRadiation_mean")
|> to(bucket: "forever")
from(bucket: "sensors")
|> range(start: -365d)
|> filter(fn: (r) => r["_measurement"] == "Weather")
|> filter(fn: (r) => r["_field"] == "SolarRadiation")
|> aggregateWindow(every: 12h, fn: max)
|> set(key: "_field", value: "SolarRadiation_max")
|> to(bucket: "forever")
from(bucket: "sensors")
|> range(start: -365d)
|> filter(fn: (r) => r["_measurement"] == "Weather")
|> filter(fn: (r) => r["_field"] == "SolarRadiation")
|> aggregateWindow(every: 12h, fn: min)
|> set(key: "_field", value: "SolarRadiation_min")
|> to(bucket: "forever")
For tasks i would change “range(start: -365d)” to “range(start: -task.every)”
But when i want do this for much more fields, like:
- Temperature
- Humidity
- Pressure
- WindSpeed
- WindDirection
- GustSpeed
- Rainrate
- GoldcapVoltage
- RainClicks
an only max-values for - RainToday
- Longest Blackout
- Packets received
- CRC-Errors
- BattWarning
I will end up in 3*10 + 5 = 35 Querries = 35 Tasks.
I was wondering if there is an elegant method to archive this goal.
Hoping to hear an elegant solution
Greetings from Bochum.