创建具有多个维度和参考线的图表

Create Chart with Multiple Dimensions and a Reference Line

来自 Microsoft 的

This article 描述了创建具有多个维度的图表和添加参考线的单独说明。

我正在尝试同时进行这两项操作。我正在使用以下查询来测量跨多个环境的内存使用情况:

Perf
| where TimeGenerated > ago(1h)
| where (CounterName == "% Committed Bytes In Use")
| summarize avg(CounterValue) by Computer, bin(TimeGenerated, 15m)
| render timechart

如果我尝试添加 | extend Threshold = 50,查询仍然可以正常工作,但参考线不显示。

有谁知道当我已经在使用多个维度时是否有办法显示参考线?

编辑:

按照推荐,这是我 运行:

的完整脚本
Perf
| where TimeGenerated > ago(1h)
| where (CounterName == "% Committed Bytes In Use")
| summarize avg(CounterValue) by Computer, bin(TimeGenerated, 15m)
| extend Threshold = 50
| render timechart

这里是缺少参考线的结果:

尝试使用此查询,它为每个 TimeGenerated 行添加额外的行,Threshold 的固定值为 50

By inserting additional row for each TimeGenerated, it makes sure that the Threshold is set to a fixed value and displays line in the timechart.

let tab_Perf =
    Perf
    | where TimeGenerated > ago(1h)
    | where (CounterName == "% Committed Bytes In Use")
    | summarize avgValue = avg(CounterValue) by Computer, bin(TimeGenerated, 15m)
    ;
tab_Perf
| union
    (
        tab_Perf
        | distinct TimeGenerated
        | project TimeGenerated, Computer = "Threshold", avgValue = 50.0
    )
| render timechart

这可能不是完美的解决方案,但至少它有效:-)。