如何在 Azure Monitor 中查询 Azure 配额和限制?

如何在 Azure Monitor 中查询 Azure 配额和限制?

Microsoft Azure 订阅受到各种配额和限制,例如 CPU 核心总数和某个系列的 VM 数量。

我如何查询当前配额和实际使用情况,以便在达到配额之前做出预测并创建警报?

答案1

部分信息可在Azure 监视器, 特别适用于 VM 的 Azure Resource Graph

像这样的查询应该有效:

QuotaResources
| where type =~ "microsoft.compute/locations/usages"
| mv-expand json = properties.value limit 400 
| extend usagevCPUs = json.currentValue, QuotaLimit = json['limit'], quotaName = tostring(json['name'].localizedValue)
| where usagevCPUs > 0
| extend usagePercent = toint(usagevCPUs)*100 / toint(QuotaLimit)
| project subscriptionId,quotaName,usagevCPUs,QuotaLimit,usagePercent,location,json
| order by ['usagePercent'] desc

例如,您可以在 Grafana 中使用它Azure Monitor 数据源,既可以用于可视化,也可以用于 Grafana 警报。

带有 Azure Monitor 数据源查询的 Grafana 面板

相关内容