Bombbe
Bombbe

Reputation: 165

Azure VM avage cpu usage past 30 days

I'm trying to write down an Azure Log analytics query that would show me the average CPU usage in the past 30 days for my Azure virtual machines.

With the following query I have some results, but not really what I'm looking for:

Perf
| where ObjectName == 'Processor' and CounterName == '% Processor Time' and InstanceName == '_Total' 
| summarize CPUAvarage = avg(CounterValue) by Computer, bin(TimeGenerated, 1h)

Result:

enter image description here

The result are are in the correct form, but the TimeGenerated should be last 30 days and "CPUAvarage" should display 1 number for past 30 days (30 days average cpu). If I'm correct query should add all values together past 30 days and then divide it by count but my with my current Kusto skills I'm not able to do this.

Upvotes: 0

Views: 1806

Answers (1)

Slavik N
Slavik N

Reputation: 5328

I don't fully understand what you're trying to achieve, so here are your options:

  1. If you want the result to be per day, and not per hour, then you should replace bin(TimeGenerated, 1h) with bin(TimeGenerated, 1d), because 1h is an hour, and 1d is a day.

  2. If you want the average CPU per computer over the whole month, then replace your summarize line with | summarize CPUAvarage = avg(CounterValue) (note that I removed the bin part).

  3. If you want the average CPU per day for all your computers (rather than per computer), then replace your summarize line with | summarize CPUAvarage = avg(CounterValue) by bin(TimeGenerated, 1d).

Upvotes: 0

Related Questions