I have two measurements:
traffic_sensors. In the
_time indicates the onset of a link, i.e., when a vehicle begins traveling on a specific road segment, and
_value is the amount of time spent on that segment (in secs). Some other tags define the link-id, vehicle-id etc. For
_field indicates the sensor-id, and
_value contains the amount of traffic at a particular
Here is my flux query to get a table of all the
_time instances of a link named ‘3523’ :
links = from(bucket: "bus-link") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r["_measurement"] == "link_duration_s") |> filter(fn: (r) => r["_field"] == "link_duration_s") |> filter(fn: (r) => r["link"] == "3523")
For each row
lr of the
links table, I want to get all the
traffic_sensors data in
range(start: r._time, stop: experimental.addDuration(d: r._value, to: r._time), i.e., the interval between the onset and offset of a link. Subsequently, I want to aggregate the
traffic_sensors rows for each such group.
I did try a
join(on:["_time"]) but ended up with only a few rows since
link_duration_s is not periodic (rather sparse), but for
traffic_sensors has a periodicity of 1m.
Essentially, I want to capture the traffic state when a link is traversed by a vehicle.