How to access the time range selected in query editor from within a query?


  • Hi everybody,

    is it possible to access the time range selected in the query editor from within the query?

    Background: I don't want to define the time range in the query itself, but rather want it to be selectable from the query editor. However, parts of my query are dependent on the selected timestamp, such as the bin size when summarizing binned by timestamp (e.g. when selected time range is < 1h I want bins of 1m granularity, if it's 1d I want bins of 15m granularity, etc) 

    See also my question on twitter here:

    I already found `bin_auto(timestamp)` which looked promising, however I still need to explicitly `set query_bin_auto_size=1m` (i.e. again hardcode the bin size in the query to a fixed value, which is exactly not what I want).

    Any ideas how to compute the bin size dynamically based selected time range in query editor UI?


    Friday, February 8, 2019 2:27 PM

All replies

  • Hello, Torben!

    The immediate answer here is that in the scenario you described above, the design was to change the query with a where timegenerated >ago() like the following:

    | where timegenerated > ago(1d) 

    Having said that, we do see where the functionality you outlined would be useful and we'd love to have you submit the idea:

    I'd be happy to submit the idea on your behalf, if you prefer, but submitting it yourself makes it easier to keep tabs on updates and the like.  If you do submit the idea, please post the link here so that myself and others can vote on it!

    Thursday, February 14, 2019 12:39 AM