如何将基于聚合的常量参考线引入 Kusto 时间表?

How can I introduce a constant reference line based on an aggregation to a Kusto timechart?

我有一个简单的 KQL 查询,它绘制了 90 天内所有异常的(日志)计数:

exceptions
| where timestamp > ago(90d)
| summarize log(count()) by bin(timestamp, 1d)
| render timechart

我想做的是在生成的时间表中添加一些参考线。基于 the docs,这非常简单:

| extend ReferenceLine = 8

复杂的因素是我希望这些参考线基于我正在绘制的值的聚合。例如,我想要一条最小值、平均值和第三四分位值的参考线。

关注其中的第一个(最小值),事实证明您不能在 summarize() 之外使用 min()。但是我可以在 extend().

中使用它

我被 min_of() 吸引了,但这需要一个参数列表而不是一列。我在想我可能会将该列扩展为一系列值,但这感觉很老套,并且会超出一定数量的值。

执行此操作的惯用方法是什么?

您可以尝试以下操作:

exceptions
| where timestamp > ago(90d)
| summarize c = log(count()) by bin(timestamp, 1d)
| as hint.materialized=true T
| extend _min = toscalar(T | summarize min(c)),
         _perc_50 = toscalar(T | summarize percentile(c, 50))
| render timechart