Template with Adhoc Filter and Datasource does not work - ElasticSearch

Possible bug:

  • ElasticSearch 5.4
  • Grafana v4.3.2 (commit: ed4d170)

Building a simple dashboard, utilizing Templates. Create a Type:Datasource template, then create an Type:Ad hoc filter, with $DataSource as the data source.

In Dashboard view, select Datasource, then Select various fields from Ad hoc Filter to filter by. Type ahead of Ad hoc filter shows Field Names properly.

However, the search that is sent by Grafana does not include the terms selected. In fact, it includes none of the Ad hoc data at all. As a result, the results return everything (as no terms are sent).A look at Chrome Debug shows:

– DataSource Selected
– Adhoc (configured with $DataSource) with field=message value=dwaters
Chrome Debug:

Creating the same Dashboard, with only the Adhoc Filter in the template (and the Datasource hardcoded), it works properly:

– Adhoc with field=message value=dwaters
Chrome Debug:


This scenario is not supported right now. I think you might be the first person to ask for it - I cannot find an issue or feature request for it.

I believe I may have run into the same or a similar issue. Templated data sources work fine, but for the ad hoc filter to affect panels querying the template variable requires hard coding the ad hoc data source instead of using $datasource.