Hello all,
I am migrating form InfluxDB 1.8 to InfluxDB 2.5 so far the experience has been good.
The one thing I am struggeling with is the conversion of some Grafana Dashboard variable InfluQL queries to Flux.
The InfluxQL query takes a second to complete, the Flux query I came up with takes around 30 seconds to complete.
Is there a smarter and/or faster way to translate the InfluxQL example to Flux?
InfluxQL examples (just take a split second to complete)
show tag values with key = cluster where project =~ /^$project$/
show tag values with key = system where platform =~ /^$platform$/ AND cluster =~ /^$cluster$/
show tag values from /^$source$/ with key = "idx" where controller = '0' AND system =~ /^$system$/
Flux query - as I would like it to run - takes 30 seconds to complete:
from(bucket: "${bucket}")
|> range(start: -1)
|> filter(fn: (r) => r["site"] == "${site}")
|> filter(fn: (r) => r["project"] == "${project}")
|> keyValues(keyColumns: ["cluster"])
|> keep(columns: ["cluster"])
|> distinct(column: "cluster")
|> group()
|> yield()
Flux with an additional filter on e.g. “controller” takes about 5 seconds to complete (since I can’t rely on any other tag to filter on, this is not my preference - still 5 seconds is long compared to the InfluxQL examples):
from(bucket: "${bucket}")
|> range(start: -1)
|> filter(fn: (r) => r["controller"] == "0")
|> filter(fn: (r) => r["site"] == "${site}")
|> filter(fn: (r) => r["project"] == "${project}")
|> keyValues(keyColumns: ["cluster"])
|> keep(columns: ["cluster"])
|> distinct(column: "cluster")
|> group()
|> yield()
The scheme looks like this:
{
"measurement": STR,
"tags": {
"site": STR,
"project": STR,
"cluster": STR,
"system": STR,
"platform": STR,
"alias": STR,
"system_ip": STR,
"metric": "rate",
"controller": "0",
"idx": STR,
},
"fields": {
"IOs/sec": FLOAT,
"KiB/sec": FLOAT,
"KiB/IO": FLOAT,
"Fwd IO/s": FLOAT,
"Fwd KiB/s": FLOAT,
"R KiB/s": FLOAT,
"W KiB/s": FLOAT,
"Unmap KiB/s": FLOAT,
"deltaSec": FLOAT
},
"time": DATETIME,
},
{
"measurement": STR,
"tags": {
"site": STR,
"project": STR,
"cluster": STR,
"system": STR,
"platform": STR,
"alias": STR,
"system_ip": STR,
"metric": "rate",
"controller": "1",
"idx": STR,
},
"fields": {
"IOs/sec": FLOAT,
"KiB/sec": FLOAT,
"KiB/IO": FLOAT,
"Fwd IO/s": FLOAT,
"Fwd KiB/s": FLOAT,
"R KiB/s": FLOAT,
"W KiB/s": FLOAT,
"Unmap KiB/s": FLOAT,
"deltaSec": FLOAT
},
"time": DATETIME,
}