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

KQL查询如何按集群分组统计Azure AKS集群的总节点数量

修改后的完整KQL语句

resources 
| join kind=leftouter (ResourceContainers 
| where type=='microsoft.resources/subscriptions' 
| project SubscriptionName=name, subscriptionId) on subscriptionId 
| where type =='microsoft.containerservice/managedclusters' 
| extend properties.agentPoolProfiles
| project id, SubscriptionName,location, name,pool = (properties.agentPoolProfiles)  
| mv-expand pool 
| project id, SubscriptionName,cluster = name, size = pool.vmSize, nodes = pool.['count']
// 新增以下分组求和语句即可得到目标结果
| summarize nodes = sum(nodes) by cluster

修改说明

你现有查询返回多行重复集群记录的原因是:mv-expand操作会把每个集群的多个节点池拆分为独立行。新增的summarize语句会按cluster字段分组,对同一集群所有节点池的节点数求和,最终输出的列名和结构完全符合你要求的格式。
如果需要同时保留订阅名称、集群ID等其他原有字段,只需把对应字段添加到by参数后即可,示例:

| summarize nodes = sum(nodes) by cluster, SubscriptionName, id

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 20:30:01