Hi,
Please have a look at the following dashboard: http://play.grafana.org/dashboard/db/influxdb-templated-queries?orgId=1
Checkout cog wheel -> Templating and have a look at how the different template variables have been defined. You have an example of hostname there.
Then edit the panel and see how the template variables are used in the query.
Please let me know if this helps
Marcus