Hi @delapuentem , I have another problem with multiple variables. My measurement looks like below:
name1=animal,name2=tiger count=20
name1=animal,name2=lion count=25
name1=fruit,name2=apple count=10
name1=fruit,name2=banana count=15
name1
and name2
are my tags and count
is my field.
In influxdb2.0.6, I create 2 variable:
variable name1:
import “influxdata/influxdb/schema”
schema.tagValues(bucket:“mybucket”, tag:“name1”)
variable name2:
import “influxdata/influxdb/schema”
schema.tagValues(bucket:“mybucket”, tag:“name2”)
In grafana 7.5.7(also tried 8.0.0-beta2) , I create 2 variables named query1 and query2:
query1(enable multi-value):
import “influxdata/influxdb/v1”
v1.tagValues(
buket: v.bucket,
tag: “name1”,
predicate: (r) => true,
start: -1d
)
query2(enable multi-value):
import “influxdata/influxdb/v1”
v1.tagValues(
buket: v.bucket,
tag: “name2”,
predicate: (r) => r.name1 == “${query1}”,
start: -1d
)
What I want is that the item of query2 should be based on the selection of query1.
eg. If I only select animal
, the item list of query2 should only include animal item like tiger and lion but not banana. And if I select both animal
and fruit
in query1, the item list of query2 should display all animals and fruits(in my example above they are tiger/lion/apply/banana).
My query in grafana looks like below:
from(bucket: “mybucket”)
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn:(r) => r._measurement == “mymeasurement” and r._field == “count”
and contains(value: r.name2, set:${query2:json}))
In my grafana dashboard, when I select only one item of query1 let’s say animal, I can see tiger and lion in query2 drop-down items. And it works well if i select one or more item in query2.
The problem is that if I select more than one item in query1, I see nothing in query2 drop-down item.
I know that the problem is happened in my query command of query2 or name2. But I don’t know how to fix it out.
Many thanks.