How to use offset in flux tasks

In my downsampling job I want to use offset that takes data from interval from: now() -11m, to: now() - 1m, but when I try to running the query below I get the following error:

“Failed to run task: failed to force run: error exhausting result iterator: type error @4:18-4:43: duration is not Addable”

Query:

option task = {name: "Downsampling", every: 10m, offset: 1m}

data = from(bucket: "my_bucket")
	|> range(start: -(task.every + task.offset), stop: -task.offset)
	... rest of the query

What is the proper way to use offset in flux if I cannot add durations?

NOTE:
I asked this question before, but it was unclear and I cannot edit it anymore, so I added a new one.

Hello @Mikolaj_G,
try using the experimental.addDuration() function instead:

|> range(start: -(experimental.addDuration(d: task.offset, to: task.every))

Hello @Anaisdg,

Thank you very much for your answer, but your solution does not work. I get an error:

 expected time but found duration (argument to)

But based on this influx documentation:

offset delays execution of actual task and all times are relative to now() - offset, so I don’t have to subtract task.offset, it is already done and tests that I have run confirm that :slight_smile:.

1 Like

Hey, both start and stop time are relative to now() - offset or is it only stop time.