Bombbe
Bombbe

Reputation: 165

Query VM maximum cpu utilization from Azure Log Analytics

I'm running following query to get vm cpu average from past 30 days.

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

Now I would be interested in querying maximum cpu utilization instead of average because workloads might need a lot of resources for a short time and result into a low average. Averages are also sneaky and hide undesirable behavior.

I have came up with these two but don't know if they are done right or are they showing data right.

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

and

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

Purpose of doing this is for re-sizing vms. Any tips how I could achieve my goals?

Upvotes: 0

Views: 1243

Answers (1)

Slavik N
Slavik N

Reputation: 5328

Both of your queries are correct (KQL-wise): one will return the 99th percentile, and one will return the max. As for which one better suits your needs - only you can tell.

Upvotes: 1

Related Questions