我是 Kusto 的新手。我需要一个查询来获取所有正在运行的 Azure kubernetes 集群的当前节点数。我已经尝试过下面的方法,但对于少数集群,它给出的节点数为 0,其中模式存在于这些集群上
Resources
| where type == "microsoft.containerservice/managedclusters"
| extend nodepools = properties.agentPoolProfiles
| mv-expand nodepools
| project name, nodepools.name, nodepools.vmSize, nodepools.minCount, nodepools.maxCount, nodepools.powerState.code,nodeCount = tostring(nodepools['count'])
| sort by name
最佳答案
我尝试使用以下查询使用 Azure Resource Graph Explorer 获取 azure 中所有正在运行的 Azure Kubernetes 集群的节点数,并成功获得结果,如下图所示:
Resources
| where type == "microsoft.containerservice/managedclusters"
| extend properties.agentPoolProfiles
| project subscriptionId, name, pool = (properties.agentPoolProfiles)
| mv-expand pool
| project subscription = subscriptionId, cluster = name, size = pool.vmSize, count = pool.['count']
如果任何 Kubernetes 服务集群处于停止状态,则其节点数将显示为“0”,如下图所示:
关于azure - KQL 查询以获取在 azure 中运行的 Aks 集群的节点数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73804538/