Variables in dashboard is showing only the last value


#1

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.


#2

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?


#3

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


#4

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?


#5

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.


#6

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


#7

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”}}}}}


#8

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.