ES Query Variable Errors: Unexpected Token

Windows Server 2016 + ES 5.6.8 + Grafana 5.0.0 Stable.
ES datasource is set to version 5.6+.

I am trying to create a query variable, using the docs as a guide.

However, no matter how I write out the query, I always get some type of error like this:

Template variables could not be initialized: Unexpected token * in JSON at position 0

That particular error came from the following query, which is from the docs:

*{“find”: “fields”, “type”: “df”}

Any tips on troubleshooting this further?

The asterisk is an error in the documentation. Remove it

However, I’ve also found that if you copy/ paste the JSON string directly from the docs, there is something wrong with the quotes or whitespace - it doesn’t match up on my computer, and causes errors. So type out the JSON object instead.

I use this a lot, and can confirm it works (Grafana 5, ES 5+ & ES 6). Example from my dashboard below. Note the “size” key is optional.

1 Like

I just re-read your post - the other issue is likely that type:“df” is not a valid Elasticsearch data type. I don’t use it myself, and don’t see it on the official documentation either for field types (df is used is as a request parameter for some queries, but is not a valid “field type”):

Thanks @davewaters, typing out the JSON object manually seems to have worked, as well as correcting the asterisk & type.