I have a few sensors that reset the value every 1st day of the month. I have been using the last value with success but didn’t find a way to get the max/last value in a given calendar month. For each calendar month, for each sensor, I mean. I am a beginner working with flux.Preferably removing grouping it by month, and sensor (removing day, hour, and second after finding the max value for that month)
I tried the aggregate with one month, but it looks like it is not going to the last day of each month, and I wanted to have it for each month for each sensor.
This is my query, which returns the last value for each of the 20 sensors:
from(bucket: "home")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["friendly_name"] =~ /1MON$/ and r["friendly_name"] !~ /^Main/)
|> filter(fn: (r) => r["_field"] == "value")
|> filter(fn: (r) => r["_measurement"] == "kWh")
|> filter(fn: (r) => r["entity_id"] !~ /2$/)