How to create variable for current date with Elasticsearch ds?

Hi, I’m using Grafana v7.4.3 which gets from Elasticsearch datasource and creating a table panel which shows how long ago a particular database table was last analyzed. I’m trying to calculate the amount of time elapsed since last analyzed time so that if (current date - last analyzed time) > n days, the cell will be highlighted. How do I create a variable for the current date?

Hi @nnoop ,

Have you tried implementing any of the strategies outlined in the Templates and Variables section in our documentation?

Hi, thanks for reply. I tried out grafana variables before for getting the hostname and also for interval resolution. But when it comes to capturing the current date when dashboard reloads so that it can be used to calculate a time difference, I’m not too sure if it’s possible to do that since the elastic datasource holds server metrics, not exactly the current system time. So it will be nice if grafana could actually support returning the current time value for elastic datasource. I think PostgreSQL supported by grafana does provide the current datetime, but it’s just not an option to query sql in my case.

1 Like

I’m trying the same. Did you got a acceptable result? If yes, what you did?