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

获取运行中Azure Kubernetes集群节点数的KQL查询问题

解决Kusto查询AKS集群节点数返回0的问题

你遇到的问题是因为原查询用的count字段是节点池的目标配置副本数,而非实际运行的节点数,而且没过滤集群和节点池的运行状态。以下是修正后的查询:

Resources
| where type == "microsoft.containerservice/managedclusters"
| where properties.powerState.code == "Running" // 只保留运行中的集群
| extend nodepools = properties.agentPoolProfiles
| mv-expand nodepools
| where nodepools.powerState.code == "Running" // 只保留运行中的节点池
| project 
    集群名称 = name,
    节点池名称 = nodepools.name,
    VM规格 = nodepools.vmSize,
    最小节点数 = nodepools.minCount,
    最大节点数 = nodepools.maxCount,
    集群状态 = properties.powerState.code,
    节点池状态 = nodepools.powerState.code,
    当前实际节点数 = nodepools.currentCount
| sort by 集群名称

关键修正点:

  • 新增集群状态过滤:只查询运行中的AKS集群,排除已停止的集群
  • 新增节点池状态过滤:只统计运行中的节点池,避免停止的节点池干扰结果
  • 用currentCount替代count:currentCount是节点池当前实际运行的节点数量,count是配置的目标副本数,两者可能因扩容、缩容或节点池启停产生差异

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 10:25:35