Dear Community,
I’m trying to use an array as variable to filter after, as follow.
The code below works but is too slow.
ldevname = from(bucket: v.bucket)
|> range(start: -365d)
|> filter(fn: (r) => r._measurement == “LDEV_CNF” )
|> filter(fn: (r) => r.poolid == “${pool}”)
|> keep(columns: [“ldevID_cnf”])
|> group()
|> distinct(column: “ldevID_cnf”)
|> findColumn(fn: (key) => true, column: “_value”)from(bucket: v.bucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “LDEV” and r._field == “LDEV_IOPS” )
|> filter(fn: (r) => contains(value: r.ldevID, set: ldevname))
ldevname is compose of following values like:
00:00:00
00:00:01
00:a0:xx
etc… in hexa
I read that i can optimize with a filter regex, i tried this code but without success:
ldevname = from(bucket: v.bucket)
|> range(start: -365d)
|> filter(fn: (r) => r._measurement == “LDEV_CNF” )
|> filter(fn: (r) => r.poolid == “${pool}”)
|> keep(columns: [“ldevID_cnf”])
|> group()
|> distinct(column: “ldevID_cnf”)
|> findColumn(fn: (key) => true, column: “_value”)from(bucket: v.bucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “LDEV” and r._field == “LDEV_IOPS” )
// |> filter(fn: (r) => contains(value: r.ldevID, set: ldevname))
|> group (columns: [“ldevID”])
filter(fn: (r) => r[“ldevID”] =~ /${ldevname}/)
I got this error:
invalid: compilation failed: error @16:35-16:48: regex parse error: ${ldevname} error: repetition quantifier expects a valid decimal
any idea, any help please ?
Many thanks,