Create, view, and manage classic metric alerts using Azure Monitor
This article describes how to create older classic metric alerts. Azure Monitor now supports newer near-real time metric alerts and a new alerts experience. Classic alerts are retired for public cloud users. Classic alerts for Azure Government cloud and Azure China 21Vianet will retire on 29 February 2024.
Classic metric alerts in Azure Monitor provide a way to get notified when one of your metrics crosses a threshold. Classic metric alerts is an older functionality that allows for alerting only on non-dimensional metrics. There is an existing newer functionality called Metric alerts, which has improved functionality over classic metric alerts. You can learn more about the new metric alerts functionality in metric alerts overview. In this article, we will describe how to create, view and manage classic metric alert rules through Azure portal and PowerShell.
With Azure portal
In the portal, locate the resource that you want to monitor, and then select it.
In the MONITORING section, select Alerts (Classic). The text and icon might vary slightly for different resources. If you don't find Alerts (Classic) here, you might find it in Alerts or Alert Rules.
Select the Add metric alert (classic) command, and then fill in the fields.
Name your alert rule. Then choose a Description, which also appears in notification emails.
Select the Metric that you want to monitor. Then choose a Condition and Threshold value for the metric. Also choose the Period of time that the metric rule must be satisfied before the alert triggers. For example, if you use the period "Over the last 5 minutes" and your alert looks for a CPU above 80%, the alert triggers when the CPU has been consistently above 80% for 5 minutes. After the first trigger occurs, it triggers again when the CPU stays below 80% for 5 minutes. The CPU metric measurement happens every minute.
Select Email owners... if you want administrators and co-administrators to receive email notifications when the alert fires.
If you want to send notifications to additional email addresses when the alert fires, add them in the Additional Administrator email(s) field. Separate multiple emails with semicolons, in the following format: firstname.lastname@example.org;email@example.com
Put in a valid URI in the Webhook field if you want it to be called when the alert fires.
If you use Azure Automation, you can select a runbook to be run when the alert fires.
Select OK to create the alert.
Within a few minutes, the alert is active and triggers as previously described.
After you create an alert, you can select it and do one of the following tasks:
- View a graph that shows the metric threshold and the actual values from the previous day.
- Edit or delete it.
- Disable or Enable it if you want to temporarily stop or resume receiving notifications for that alert.
We recommend that you use the Azure Az PowerShell module to interact with Azure. See Install Azure PowerShell to get started. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.
This sections shows how to use PowerShell commands create, view and manage classic metric alerts.The examples in the article illustrate how you can use Azure Monitor cmdlets for classic metric alerts.
If you haven't already, set up PowerShell to run on your computer. For more information, see How to Install and Configure PowerShell. You can also review the entire list of Azure Monitor PowerShell cmdlets at Azure Monitor (Insights) Cmdlets.
First, log in to your Azure subscription.
You'll see a sign in screen. Once you sign in your Account, TenantID, and default Subscription ID are displayed. All the Azure cmdlets work in the context of your default subscription. To view the list of subscriptions you have access to, use the following command:
To change your working context to a different subscription, use the following command:
Set-AzContext -SubscriptionId <subscriptionid>
You can retrieve all classic metric alert rules on a resource group:
Get-AzAlertRule -ResourceGroup montest
You can view details of a classic metric alert rule
Get-AzAlertRule -Name simpletestCPU -ResourceGroup montest -DetailedOutput
You can retrieve all alert rules set for a target resource. For example, all alert rules set on a VM.
Get-AzAlertRule -ResourceGroup montest -TargetResourceId /subscriptions/s1/resourceGroups/montest/providers/Microsoft.Compute/virtualMachines/testconfig
Classic alert rules can no longer be created via PowerShell. Use the new 'Add-AzMetricAlertRuleV2' command to create a metric alert rule instead.
Submit and view feedback for