Elasticsearch dashboard variable not honouring sort order

Hello Grafana experts,

Data is being streamed to our elasticsearch cluster in batches, with each batch having a unique, incrementing ID. I want to show only data from the most recent batch on a dashboard, which will be a wallboard TV in our NOC with auto-refresh enabled. I have created a dashboard variable (set to refresh on time range change) called batch_id with the below query:


The problem is the batch_id that gets returned is the oldest, not the newest (based on the time range of the dashboard). It’s like the sort part of the query is being stripped out before being sent to elasticsearch.

Is this a known issue and/or is there another way to achieve this? Using the sort option within the variable sadly doesn’t help as Grafana doesn’t automatically select the topmost option when auto-refreshing.

Many thanks for any advice

1 Like