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

    Question

  • 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:
    https://twitter.com/tknerr_de/status/1093812068980084737

    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?

    Cheers,
    Torben

    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:

    https://feedback.azure.com/forums/357324-application-insights

    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
    Moderator