Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

additional range parameters #69

Open
errantspark opened this issue Jan 28, 2020 · 2 comments
Open

additional range parameters #69

errantspark opened this issue Jan 28, 2020 · 2 comments

Comments

@errantspark
Copy link

the $range parameter (as i understand it, i don't fully grok the code) is expanded in datasource.ts to start and stop values, it would be very useful to be able to split this out into two parameters such as $start and $stop as then you could(?) perform math on the start and end positions greatly simplifying and speeding up time-shifted queries

what i'm envisioning is something like

from(bucket: "telegraf/autogen")
  |> range(start:$start-1d, stop:$stop-1d)

to perform a timeshifted query to make it easy to compare from one day to the next

@MarcoPignati
Copy link

I have found this workaround. I hope it is helpful.

starttime =  time(v: $__from * 1000000) //transform to ns. 
stoptime  = time(v: $__to * 1000000)

from(bucket: "telegraf/autogen")
  |> range(start: starttime, stop: stoptime)

time() is a flux function to transform a number in ns to RFC3339

@gaurav-fk
Copy link

gaurav-fk commented May 4, 2020

Thanks @MzazM it works. I used it as follows for comparing data in a given time range to timeshifted data 1hr back in Grafana.

starttime =  time(v: ($__from - (1* 3600 * 1000)) * 1000000) 
stoptime  = time(v: ($__to - (1 * 3600 * 1000)) * 1000000)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants