I am trying to graph certain values from my InfluxDB v2 with other values recorded exactly one year ago. For this I would like to use the variables v.timeRangeStart and v.timeRangeStop. My idea was to create two individual queries. The first query fetches the current data and the second query fetches data between v.timeRangeStart - 1y and v.timeRangeStop - 1y. Since subtraction of Duration and Time data types can’t be computed natively, I wanted to use experimental.subDuration() to adjust the limits for the range() function. However, when I try to run the experimental.subDuration(d: 1y, from: v.timeRangeStart)
function, I get an error saying “expected time but found duration (argument from)”. After some research I came across this issue: v.timeRangeStart should be a timestamp like v.timeRangeStop · Issue #18402 · influxdata/influxdb · GitHub It says that this problem has already been solved by adding a kind constraint “Timeable” (Zenhub | Productivity Management for Software Teams). Unfortunately, I’m not sure how exactly this information helps me, as the addDuration and subDuration functions still throw errors.
I noticed I can workaround this issue by using exact timestamps as v.timeRangeStart and v.timeRangeStop instead of relative durations. But this is still a fairly bad workaround, since not being able to choose relative durations is a bad user experience.
I am using InfluxDB v 2.0.8, which corresponds to Flux version 0.124.0.