You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用KQL编写查询计算Azure虚拟机网络带宽利用率

KQL 实现单台虚拟机网络利用率计算

你可以通过pivot运算符将两行指标数据转换为同一行的两列字段,再代入公式计算即可,调整后的查询语句如下:

Perf
| where ObjectName == "Network Interface"
| where Computer startswith "T1"
| where CounterPath contains "Bytes Received" or CounterPath contains "Current Bandwidth"
| summarize AvgValue = avg(CounterValue) by Computer, CounterName
// 将CounterName的枚举值转换为列,每台计算机仅返回一行数据
| evaluate pivot(CounterName, any(AvgValue))
// 代入公式计算网络利用率,列名请和实际返回的CounterName保持一致
| extend NetworkUtilizationPct = ((['Bytes Received/sec'] * 8) / ['Current Bandwidth']) * 100
// 可按需调整输出字段
| project Computer, NetworkUtilizationPct

注意事项

  • 请确认pivot生成的列名和你环境中实际返回的CounterName完全匹配,带空格、特殊字符的列名需要用方括号['']包裹。
  • 如果需要排除带宽为0的异常数据避免计算报错,可以在extend步骤前添加| where ['Current Bandwidth'] > 0过滤。
  • 若需要统计双向总利用率,只需在筛选条件中新增CounterPath contains "Bytes Sent",pivot后将收发的字节数相加再代入公式计算即可。

内容的提问来源于stack exchange,提问作者VoD

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.08 14:48:03