Templating problem with graphite when variable contains multiple equal values

Using Grafana 6.3 and Graphite to display metrics generated by collectd.

My servers contain various applications, so collectd collects some common metrics like cpu, memory and some app-specific metrics.

I want to create a dashboard for just one of these apps, so don’t want to include servers without the app.
Graphite folder structure looks like this (much simplified):
collectd.server1
collectd.server1.app1.metric1
collectd.server2.app2.metric2
collectd.server3.app1.metric1

I want a panel for each instance of metric1, which is easy enough using a query variable with value “collectd..app1.”, but when I use that variable in the repeat panel field and panel title, I get two panels, each with the title metric1.

Ideally what I want is each panel to have the server name and metric name as its title, but I can’t see how to extract the server name.

I tried creating a server query variable “collectd.*” and using that to template the rows, but then I get a row for all servers, including server2, even though it doesn’t have app1.

Is there a way to ensure that the server variable only returns values if the app1 sub-folder folder exists?

Any suggestions please?
Thanks,
Andrew