Forum Discussion

Ahmed Atef's avatar
Ahmed Atef
Brass Contributor
Feb 20, 2018
Solved

create a search query for the Average of CPU over 15 mins .. and set alert to it

Hi all    I am trying to create some monitoring based on OMS Queries one of the them is creating an alert if the average CPU Utilization over 15 mins was more than 90% ..    when i use this q...
  • Hi

    Yes with this query you are getting the results for all results that are above 90 which is not the thing you want to achieve.

     

    The correct way to get the computers with above 90 % is this:

    Perf
    | where TimeGenerated > ago(15m) 
    | where ( ObjectName == "Processor Information" ) and CounterName == "% Processor Time" and InstanceName == "_Total"
    | summarize AggregatedValue = avg(CounterValue) by Computer
    | where AggregatedValue > 90
    | render table

    Because you will be using this in alert there are a few things you want to change.

    First you will remove the filter on TimeGenerated. When creating alert you can specify the period (time frame) of the alert. There you will specify 15 mins. Second you do not need to filter on Aggregated Value from alerts by choosing this to be metric alert there you can configure the threshold. You also do not need render as alerts do not use it. At last you will have to add bin() function that will match the period (time frame) in your case 15 mins. The end result is this query that you can use to create alert:

    Perf
    | where  ObjectName == "Processor Information" and CounterName == "% Processor Time" and InstanceName == "_Total"
    | summarize AggregatedValue = avg(CounterValue) by Computer, bin(TimeGenerated, 15m)

Resources