How to default variable (list of dates) to current date?

Viewed 637

For some dashboards we have a date variable to pick a date from a list of dates. The dates are queried from an elasticsearch datasource.

In our case it would be great if we could somehow set the default value to the current date.

We are using Grafana 7.1.1. I am not sure if it can be achieved at all - Currently I am thinking about extending the elasticsearch-query to put the current date on top but I don't think Grafana can set the default value based on the index.

Another idea is to use a "global" date variable for the current date which I can search for in the variable selection field and then save the dashhboard.

Any hints (including feasibility) are appreciated.

1 Answers

Correct, make current date first in that variable list and never Save current variables -> Grafana will preselect first value from the variable list in this case.

If you already have some saved current variables, then you need to edit dashboard model manually (export dashboard json/edit json - variable definition/import dashboard json).

Related