I have a query that returns the running time of each K6 test (parameters: scenario, _start and _stop):
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "checks")
|> filter(fn: (r) => r["scenario"] =~ /^${scenario:regex}$/)
|> group(columns: ["scenario"])
|> reduce(identity: {_start: time(v: "2099-01-01T00:00:00Z"), _stop: time(v: 0)}, fn: (r, accumulator) => ({
_start: if r._time < accumulator._start then r._time else accumulator._start,
_stop: if r._time > accumulator._stop then r._time else accumulator._stop
}))
|> group()
|> yield()
And there is a query that returns the number of threads (parameters: _time and vus (_value)):
from(bucket: v.defaultBucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "vus")
|> yield()
The problem is that the second query builds a graph for all scenarios, because in the vus metric there is no division into scenarios, so I want to get this division through filtering by time (I know that it will not be entirely correct, but this is enough for me).
How to combine these 2 data tables so that the _time of the second query is in the range _start - _stop from the first query?