Using variables in title with repeating panels only work for one graph

Hello,
I’m using Grafana 6.2.4 (the docker version) with influxdb database. I’m building a dynamic dashboard with repeating panels based on a variable named “slave”. The slave variable is generated from an influxdb query and generates a list of hosts that provide data: SHOW TAG VALUES from $measurement_type WITH KEY = "slave"; ($measurement_type is a similar variable, but is not multi-value in the dashboard).
My measurements have other tags as well (such as the location of the host that generates the data), which I can get with: show tag values from $measurement_type with key in ("location") where slave = '$slave';.
I have created a title such as: $measurement_type on $slave ($location). This works correctly when I select a single slave from the dropdown, but when I select multiple slaves I get:

DNS on IQ-01-lan (None)
DNS on IQ-02-lan (None)
DNS on IQ-03-lan (None)

All variables are set to refresh on dashboard load.
Ideally, instead of None I’d like to see the location of each slave.
Am I on the right track? Any ideas what I’m doing wrong?

Thanks!

Ok, I’m still struggling with this. I made some changes in order to get data from mysql, where I’m more familiar with the environment.

So - in oder to get $location, I can do this mysql query:

SELECT e.location FROM `externalProbes` e, containers c WHERE e.id = c.id_probe and e.active = 1 and c.container in ( $slave )

If I have only one $slave selected in the grafana dropdown (remember, I have Repeat set to horizontal by $slave) the variable expands to:

SELECT e.download FROM `externalProbes` e, containers c WHERE e.id = c.id_probe and e.active = 1 and c.container in ( 'IQ-01-lan')

and returns only one value, which gets displayed in the title, like I want to.
If I select multiple values (e.g. IQ-01-lan + IQ-02-lan), I get this query:

SELECT e.download FROM `externalProbes` e, containers c WHERE e.id = c.id_probe and e.active = 1 and c.container in ( 'IQ-01-lan', 'IQ-02-lan')

which executes correctly from MySQL’s point of view, but only the first value returned by MySQL (the value for IQ-01-lan) is rendered on all graph titles…

So - to rephrase my question - how can I have grafana do a query for each repeated panel and return a variable that can be used internally?

Hi,
You should use the variable in your query condition as you used for the panel repeating. Meaning, the panel repeating variable should be used in your panel query as well. Then, it will apply the variables for all the repeated panels. Hope this will help for your query.

Hello. Did you figure out a solution?

I am facing almost the exact same issue. Multiple variables are sent as a comma separated list in each query when selecting more than one variable. This results in an invalid query and no data beeing shown.

As for jagadashr’s comment; I got the same variable both in the query and the repeat panel option. (And in the panel title as well)

No, I gave up because of the lack of more advanced variable support and I’m instead programmatically generating my dashboards (and updating them when there are changes).
Not perfect, but I eliminated most of the variables and I get the dashboards I need.

Thank you for the quick reply!
Glad to hear you found a workaround, not sure if that will work for me. I guess i will do some more research. :slight_smile: