Forum Discussion
Automation to start/stop on conditions
- Jan 25, 2018
Ok so for the time I understand i should use TimeGenerated ago(120m)
So the two queries should look like:
Perf | where (CounterName == "% Committed Bytes In Use" or CounterName == "% Used Memory")
| where CounterName == "% Committed Bytes In Use" and TimeGenerated =< ago(120m)
| summarize AverageRAM = avg(CounterValue) by Computer
| where AverageRAM > 85
Perf
| where CounterName == "% Processor Time" and TimeGenerated =< ago(120m)
| summarize AverageRAM = avg(CounterValue) by Computer
| where AverageRAM > 70Am i correct?
Ok so for the time I understand i should use TimeGenerated ago(120m)
So the two queries should look like:
Perf | where (CounterName == "% Committed Bytes In Use" or CounterName == "% Used Memory")
| where CounterName == "% Committed Bytes In Use" and TimeGenerated =< ago(120m)
| summarize AverageRAM = avg(CounterValue) by Computer
| where AverageRAM > 85
Perf
| where CounterName == "% Processor Time" and TimeGenerated =< ago(120m)
| summarize AverageRAM = avg(CounterValue) by Computer
| where AverageRAM > 70
Am i correct?
- Dante Nahuel CiaiJan 26, 2018Brass Contributor
Ok I think I made really good progress
So the start up OMS query should be like this:Two queries because both are not dependent on each other, one for CPU and one for RAM
Perf
| where CounterName == "% Committed Bytes In Use" and TimeGenerated > ago(2h)
| where ( Computer == "xxxx" or Computer == "xxxx" )
| summarize average_committed_bytes_percent = avg(CounterValue) by Computer
| where average_committed_bytes_percent > 85
That will trigger an alarm when more than 0 results are present
and that will trigger the automation account runbook with a simple start vms powershell script.Now the difficult part for me was the Stop VMs part because the request was to only activate it at 11:00 PM
So what i did was use a where at the end of the query getting hourofday(now()) == 23
and I think that did it.
Am I correct?Let me here some opinions.
Best regards