Dec 09 2018
03:34 AM
- last edited on
Apr 07 2022
05:33 PM
by
TechCommunityAP
Dec 09 2018
03:34 AM
- last edited on
Apr 07 2022
05:33 PM
by
TechCommunityAP
Hi All,
I want to create alert using PowerShell and could certainly do this however I have three questions: -
1- When I am using "Add-AzureRmMetricAlertRule" CMDlet to create alerts they are coming under classic alerts. Why? . And how I could create new alert using PowerShell not the classic ones.
The script what I am using is as follows: -
Add-AzureRmMetricAlertRule -Location "Canada East" -MetricName "Percentage CPU" -Name "GouravRHEL CPU" -Operator GreaterThan -Threshold 90 -ResourceGroup "GouravRHEL" -TargetResourceId "/subscriptions/XXXXXXXXXXXXXXXXXXXXX/resourceGroups/GouravRHEL/providers/Microsoft.Compute/virtualMachines/GouravRHEL" -TimeAggregationOperator Average -WindowSize "02:00:00" -Action $action -Description "This rule sends alert of CPU"
2- In action I am adding mail ids, so the second question is related to this only. How I could add action group during alert creation using powershell.
3- My third and last question is there any possible way to use KQL in place of metric name. As we have some custom alert that are use KQL query to check condition in place of metric name.
Dec 09 2018 04:40 AM
Dec 09 2018 08:42 AM
Dec 10 2018 03:17 AM
SolutionHi Gourav,
The cmdlet you are using is for classic metric alerts in Azure Monitor. Classic metric alerts didn't support action groups and used a custom notification mechanism.
We don't yet have PowerShell cmdlets for newer metric alerts. We are actively working on those and will provide an announcement once they are ready.
In the meanwhile, if you are trying to create metric alerts, you can use Azure CLI to automate creating alerts. You can also create action groups through CLI as well.
If you trying to create log alerts based on Kusto queries, today the only way to automate it is through ARM templates. The PS cmdlets and CLI are being worked on, but are not available yet.
Regards,
Snehith
Dec 10 2018 06:45 AM
Thanks for the response, I am working with ARM now.
Feb 20 2019 01:35 AM
Feb 20 2019 08:44 AM
Hi @sarbis,
We expect PowerShell cmdlets for newer metric alerts to be available by end of March.
Please subscribe to https://azure.microsoft.com/en-us/updates/?updatetype=management or keep an eye out on What's new tab in Azure Monitor to get notified when we release this.
Regards,
Snehith
Apr 02 2019 05:45 AM
Hi there!
I just checked the site you recommended and still no news about PowerShell commands to support the new V2 alerts..
But yes, on the 28th of March there was the "New tool available to migrate from classic monitoring alerts" announce.
Just waiting for this, to update my monitoring scripts.
Regards, Pedro.
Apr 25 2019 06:38 AM
@Pedro35 , @sarbis Cmdlets for new metric alerts are now available. Please see https://docs.microsoft.com/en-us/powershell/azure/release-notes-azureps?view=azps-1.8.0#azmonitor and https://docs.microsoft.com/en-us/powershell/module/az.monitor/add-azmetricalertrulev2?view=azps-1.8....
Regards,
Snehith
Apr 26 2019 10:47 AM
@snehith Thanks for the update, Good to hear this