How to access the text value from a query variable when 'All' is selected


I have a query variable that uses the regex field to split my data so that users can filter the dashboard by their pretty names rather than their IP Addresses. So:

  • Nice Names into the group
  • Ip Addresses into the group.

This also has the ‘All’ option available and then is applied in my influx query like in the following example:

SELECT mean("value")
FROM "snmp" WHERE ("hostname" =~ /^$variableName$/)
AND $timeFilter GROUP BY time($ourinterval), "hostname"

However rather than the snmp.mean {hostname: VALUE} being the display name, I’d like to use the field from the query variable, is that possible?