How to use multi-select variable in Elasticsearch query?

I want to populate a variable from a list of client hostnames, using Elasticsearch. This works. However, I would like to template my dashboard so that it only shows the results from the selected clients in the panels.

I have my variable $client set up and populated correctly:

I need an All option to select all by default.

However, I don’t know how to actually use the value of that variable when querying Elasticsearch to return only the results I want.

In particular, the literal value of $client = All is not useful for using in an ES query, is it?

How would I go about using the variable then?

(Using Grafana 9.2.0-beta1)

The solution is quite straightforward. In your query, you can use (assuming that the field is called client.label):

client.label.keyword:$client

Grafana will automatically expand the variable to the correct value, even when All is selected.