Hello!
I’ve been struggling with Grafana and influxDB trying to do a query from yesterday midnight to today midnight (I wanted different time ranges on the same dashboard).
I’ve found a workaround that might be useful for more than this particular query since you can select a time range different from the Grafana timepicker.
To begin with, I made a query to get the current date from Influxdb, it looks like this:
The regex allows us to get the date in this format “yyyy-mm-dd”
You can get the current hours too, but it will be useless since you can use “now()” in your Influx query.
You can then use this variable to do semi-relative query like this: (hit the “Toggle edit mode” of the query")
You can specify the precise hours and you can do an operation on the date of the query with the time operations.
List of operations can be found here
If no hours are specified, Influxdb will assume that it is midnight (00:00:00), but i prefer to specify it.
Hope it will be useful for generations to come
Happy hacking!