从 Azure Log Analytics 查询 VM 最大 cpu 利用率

Query VM maximum cpu utilization from Azure Log Analytics

我正在 运行 查询过去 30 天的虚拟机 cpu 平均值。

InsightsMetrics
| where Namespace == "Processor" and Name == "UtilizationPercentage"
| where _ResourceId contains "resourcegroups"
| summarize AggregatedValue = avg(Val) by Computer

现在我有兴趣查询最大 cpu 利用率而不是平均值,因为工作负载可能在短时间内需要大量资源并导致平均值较低。平均数也是偷偷摸摸的,隐藏了不良行为。

我想到了这两个,但不知道它们是否正确完成或是否正确显示数据。

InsightsMetrics
| where Namespace == "Processor" and Name == "UtilizationPercentage"
| where _ResourceId contains "resourcegroups"
| summarize percentiles(Val, 99) by Computer

InsightsMetrics
| where Namespace == "Processor" and Name == "UtilizationPercentage"
| where _ResourceId contains "resourcegroups"
| summarize AggregatedValue = max(Val) by Computer

这样做的目的是调整虚拟机的大小。我有什么实现目标的秘诀吗?

您的两个查询都是正确的(KQL 方面):一个 return 第 99 个百分位数,一个 return 最大值。至于哪一款更适合您的需求,您自己说了算。