i have debug dash board, where i use variables to see my
actual buckets
all measurements for each bucket
sample data for each measurement
one of my measurement is conversion table between machine_id to human_readable. as this i only import once it can be very old. so i am looking for function where i detect such a measurement and then want to shift v.timeRangeStart to -1y
time_range = (measurement) =>
measurement
//|> filter(fn: (r) => if measurement == “ttn_2_machines” then string(v: duration(v: -1y))
//else string(v: duration(v: v.timeRangeStart))) //v.timeRangeStart
|> filter(fn: (r) => if measurement == “ttn_2_machines” then -1y
else v.timeRangeStart)
v.timeRangeStart
Functions to manipulate timestamps: Time series data is difficult to work with. Flux includes several functions to work with time. However, a couple of these functions are spread out between various community package contributions and Flux packages within the documentation. A consolidated list of all of these functions provide you with a deeper understanding of how you can use Flux to work with time. The following functions allow you to manipulate your timestamps and execute a variety of time series transformations. Including:
hourSelection(): select data between specific parts of the day.
duration(): convert a timestamp to a duration in terms of seconds, minutes, hours, etc.
hallo @Anaisdg , thank you for your answer. i will try to describe again and better:
what i really like with FLUX is, that we can achieve same goal via multiple ways:
the goal here is to use condition/function to detect static table / measurement: “ttn_2_machines” and if True then overcharge the v.timeRangeStart with -3y
the reason for this is to limit range for sensor data to work with let’s say only -24h or -4d and not -3y
i have succeed with two tables and union
//static table which can be 2year old
ttn_table =
from(bucket: v.bucket)
|> range(start: -1y)
|> filter(fn: (r) => r["_measurement"] == v.measurement)
|> filter(fn: (r) => v.measurement == “ttn_2_machines”)
|> map(fn: (r) => ({ r with value: r._value}))
|> drop(columns:["_start", “_stop”, “host”, “_field”, “_measurement”])
|> sort(columns: ["_time"], desc:true)
|> limit(n:10)
|> group()
//dynamic table incremented every 1m with lot’s of sensor data
all_data_tables =
from(bucket: v.bucket)
|> range(start: -1y)
|> filter(fn: (r) => r["_measurement"] == v.measurement)
|> filter(fn: (r) => v.measurement != “ttn_2_machines”)
|> range(start: v.timeRangeStart)
|> map(fn: (r) => ({ r with value: r._value}))
|> drop(columns:["_start", “_stop”, “host”]) // “_measurement”])
|> sort(columns: ["_time"], desc:true)
|> limit(n:10)
union(tables: [ttn_table, all_data_tables])
but i believe there will be more efficient way and also interested if i can use IF to shift duration for RANGE like described in initial question