How do I use the new $__to and $__from variables (influxdb)?

I have built a graph that I intend to track cumulative_sum() from the beginning of time, not just the $timeFilter. In 5.x, I solved this by editing the influxdb query and changing $timeFilter to time <= now(). The downside to this now is I lose the query picker.

I understand in grafana 6+ there are new __to and __from variables, but have yet to run across any documentation on how to use them. Any words of wisdom? Thanks!

If you’re using it in the query builder, it is an interpolated field, so it just replaces the variable. So, you would add a constraint AND | time | >= | $__from and it correctly parses it and sends it to influx.

However, InfluxDB expects nanoseconds, so when in text edit mode, you have to specify milliseconds in your query. For example,

SELECT mean("some_field") FROM "whatever" WHERE time >= ${__from}ms and time < ${__to}ms

I’m not sure why it does it correctly in query builder and incorrectly in text edit mode…

How can I add -1d, -2d in the query below?

SELECT mean("some_field") FROM "whatever" WHERE time >= ${__from}ms and time < ${__to}ms

I tried ${__from}ms-1d but it did not work

@aiuser I don’t think Influx supports “time math” like that. But maybe you can get what you need by using the time period overrides in a panel’s query options in Grafana: Queries | Grafana Labs