Is it possible to definie variable template with regex?

yes, it is possible using the Regex field under Query options. The trick is to using a capturing group:

/(..).*/

for a query that would be something like this in your case:

SHOW TAG VALUES WITH KEY = "host"

This would capture the first two characters for every value and match on everything. You can be much more specific if you want to filter out values. The above regex for your host list would return: fr, us, uk

You can then use the above template variable in your query:

select * from data where host =~ /$tempvar.*/ limit 5;

Read more about templating with InfluxDB here: http://docs.grafana.org/features/datasources/influxdb/#templating

2 Likes