如何从查询中访问查询编辑器中选择的时间范围? [英] How to access the time range selected in query editor from within a query?

查看:55
本文介绍了如何从查询中访问查询编辑器中选择的时间范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


是否可以从查询中访问查询编辑器中选择的时间范围?


背景:我不想在查询本身中定义时间范围,而是希望它可以从查询编辑器中选择。但是,我查询的部分内容取决于所选的时间戳,例如当按时间戳
进行汇总时(例如,当选择的时间范围<1h时我想要1m粒度的箱子,如果它是1d我想要箱子时的箱子大小) 15米粒度,等等) 


请参阅Twitter上的问题:

https://twitter.com/tknerr_de/status/1093812068980084737


我已经发现`bin_auto(timestamp)`看起来很有希望,但是我仍然需要明确地设置query_bin_auto_size = 1m`(即再次将查询中的bin大小硬编码为固定值,这完全不是我想要的。)


如何在查询编辑器UI中根据选定的时间范围动态计算bin大小?


干杯,$
Torben


解决方案

你好,Torben!



即时答案在上面描述的场景中,设计是使用timegenerated> before()更改查询,如下所示:



< pre class ="prettyprint lang-sql"> |何时生成>之前(1d)


话虽如此,我们确实看到您概述的功能在哪里有用,我们很乐意你有没有提交这个想法:



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



我会很开心如果您愿意,代表您提交想法,但自己提交可以更容易地关注更新等。 如果您确实提交了这个想法,请在此处发布链接,以便我和其他人可以对其进行投票!


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

解决方案

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!


这篇关于如何从查询中访问查询编辑器中选择的时间范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆