I have finally migrated from 1.x to 2.x and are now updating my CQ to Tasks, but are a bit stuck with this one!
Background:
I store Energy in Wh from a sensor that continuous increase in size. I want every day store the consumption by taking last sample and calculate the difference, by that I get the consumption per day. The measurement I want to store to another bucket SensorData_2
InfluxQL Old CQ I used in 1.x environment CREATE CONTINUOUS QUERY "Energy_1d_last_diff" ON "SensorData_1" BEGIN SELECT difference(last(Wh)) as Wh INTO "SensorData_2"."autogen"."Energy_1d_last_diff" FROM "Energy" GROUP BY time(1d), END
error exhausting result iterator: error in building plan while starting program: cannot submit unbounded read to “SensorData_1”; try bounding ‘from’ with a call to ‘range’
Hi @Magnus_P,
I hope you are doing well. Great to see you have moved onto Flux. So I think you’re pretty close to achieving your goal. Here is my take based on my own data:
I still have a question though since I want to have similar measurement for month and year. I suppose I change the |> range(start: -1d), |> range(start: -1mo), |> range(start: -1y) and the corresponding option task every 1d, 1mo and 1y?
The task produce well but have a question about the timestamp on the daily sample. Each sample is on the new day e.g. 2021-12-06T00:00:00.000Z which actual is the consumption over 2021-12-05. Is there as possibility in a easy manner to set the timestamp to 2021-12-05T23:59:00.000Z. Otherwise the summary and visualizations using the data showing the wrong day!