Variables in dashboard is showing only the last value

I tried adding variables to dashboard. The query i use returns only the last entry, instead of all the entries for that field.
This is the query:

{"find" : "terms","field":"fmVer"}.

This always returns the last fmVer in the db. Not all the versions. Am I missing anything in the query? How to get all the fm Version list.

The query looks correct as far as I can see.

From the docs: http://docs.grafana.org/features/datasources/elasticsearch/#templating

Query will user current dashboard time range as time range for query.

So if you just choose a larger time range, do you get more values?

I tried larger time range as well. Still it shows only the last entry.

Are you sure that there are more entries? If you do a normal query, do you see more values for the fmVer field in your chosen time range?

Yes. There are more values in elasticDB. I use another variable fmBuild which has the following query.
{“find” : “terms”, “field”:“fmBuild”, “query”:“fmVer:$fmVer”}
There too i have more fmBuild value per fmVer. But I see only last value of fmBuild.

Can you check what the query looks like on the network tab in Chrome devtools:

What does the request payload look like for you?

The example above is from our play site: https://play.grafana.org/d/000000015/elasticsearch-templated?editview=templating&orgId=1

Sorry for the delay in response as I was out of station. From the time filter it is using, it seems to take only last 6 hours data. I dont see anywhere this time range is mentioned.

Here is the payload of request
{“search_type”:“query_then_fetch”,“ignore_unavailable”:true,“index”:“testresult”,“max_concurrent_shard_requests”:256}
{“size”:0,“query”:{“bool”:{“filter”:[{“range”:{“updatedOn”:{“gte”:“1552696310330”,“lte”:“1552717910330”,“format”:“epoch_millis”}}},{“query_string”:{“analyze_wildcard”:true,“query”:"*"}}]}},“aggs”:{“1”:{“terms”:{“field”:“fmVer”,“size”:500,“order”:{"_key":“asc”}}}}}

{“search_type”:“query_then_fetch”,“ignore_unavailable”:true,“index”:“testresult”,“max_concurrent_shard_requests”:256}
{“size”:0,“query”:{“bool”:{“filter”:[{“range”:{“updatedOn”:{“gte”:“1552696310593”,“lte”:“1552717910594”,“format”:“epoch_millis”}}},{“query_string”:{“analyze_wildcard”:true,“query”:“fmVer:5.6”}}]}},“aggs”:{“1”:{“terms”:{“field”:“fmBuild”,“size”:500,“order”:{"_key":“asc”}}}}}

I figured out the problem. My Variable setting has refresh set to “Never”. So i guess it didnt consider changes in the time range. After I changed the refresh setting to “On time range change” I can see multiple values for the variable.

@daniellee @sridharg2009 Hello, I just need a small help in a similar situation.
Here my question is otherwise, I want the Variables in dashboard to show only the last value, not all the values.


As you can see in the image, there are 2 values being displayed, but I just want to know only the last value.
It would be great help if any of you can help me solve this. Thanks in advance.