How can I get a Variable from the middle of a metric path?

I’m wondering that how can I match several variable options from the middle of a metric path.
For example, I have a graphite metric path “demo.server”, and certain servers in them has a metric named “connection”, and others do not. I want to make a Variable which has all the name of servers that have “connection” metric, so how to make the query?
I’ve tried querying “demo.server*.connection” but Grafana only returned “connection” instead of names of servers, looks that it didn’t work as expected.