Create, view, and manage metric alerts using Azure Monitor

  1. Home
  2. Create, view, and manage metric alerts using Azure Monitor

Go back to DP-200 Tutorials

In this we will learn about how to create, view, and manage metric alert rules through Azure portal and Azure CLI. You can also create metric alert rules using Azure Resource Manager templates, which are described in a separate article. However, Metric alerts in Azure Monitor provide a way to get notified when one of your metrics crosses a threshold. Metric alerts work on a range of multi-dimensional platform metrics, custom metrics, Application Insights standard and custom metrics.

Create with Azure portal

The following procedure describes how to create a metric alert rule in Azure portal:

  • Firstly, in Azure portal, click on Monitor. The Monitor blade consolidates all your monitoring settings and data in one view.
  • Secondly, click Alerts then click + New alert rule.
  • Thirdly, click Select target, in the context pane that loads, select a target resource that you want to alert on. Use Subscription and Resource type drop-downs to find the resource you want to monitor.
  • Then, if the selected resource has metrics you can create alerts on, Available signals on the bottom right will include metrics.
  • And, once you have selected a target resource, click on Add condition.
  • Next, you will see a list of signals supported for the resource, select the metric you want to create an alert on. Then, you will see a chart for the metric for the last six hours. Use the Chart period dropdown to select to see longer history for the metric.
  • If the metric has dimensions, you will see a dimensions table presented. Select one or more values per dimension.
  • After that, select the Threshold type, Operator, and Aggregation type. This will determine the logic that the metric alert rule will evaluate. Optionally, refine the condition by adjusting Aggregation granularity and Frequency of evaluation. And, click Done.
  • Optionally, add another criteria if you want to monitor a complex alert rule. Currently users can have alert rules with Dynamic Thresholds criteria as a single criterion.
  • Then, fill in Alert details like Alert rule name, Description, and Severity.
  • Lastly, add an action group to the alert either by selecting an existing action group or creating a new action group. And, click Done to save the metric alert rule.

View and manage with Azure portal

You can view and manage metric alert rules using the Manage Rules blade under Alerts. The procedure below shows you how to view your metric alert rules and edit one of them.

  • Firstly, in Azure portal, navigate to Monitor
  • Secondly, click on Alerts and Manage rules
  • Thirdly, in the Manage rules blade, you can view all your alert rules across subscriptions. You can further filter the rules using Resource group, Resource type, and Resource. Further, if you want to see only metric alerts, select Signal type as Metrics.
  • Then, click on the name of the metric alert rule you want to edit
  • Next, in the Edit Rule, click on the Alert criteria you want to edit. You can change the metric, threshold condition and other fields as required
  • Lastly, click Done to save your edits.
DP-200 practice tests

With Azure CLI

The previous sections described how to create, view, and manage metric alert rules using Azure portal. This section will describe how to do the same using cross-platform Azure CLI. However, quickest way to start using Azure CLI is through Azure Cloud Shell.

  • Firstly, go to Azure portal, click on Cloud Shell.
  • Secondly, at the prompt, you can use commands with –help option to learn more about the command and how to use it. For example, the following command shows you the list of commands available for creating, viewing, and managing metric alerts

Azure CLI
az monitor metrics alert –help

  • Now, you can create a simple metric alert rule that monitors if average Percentage CPU on a VM is greater than 90

Azure CLI
az monitor metrics alert create -n {nameofthealert} -g {ResourceGroup} –scopes {VirtualMachineResourceID} –condition “avg Percentage CPU > 90” –description {descriptionofthealert}

  • Next, you can view all the metric alerts in a resource group using the following command

Azure CLI
az monitor metrics alert list -g {ResourceGroup}

  • Next, you can see the details of a particular metric alert rule using the name or the resource ID of the rule.

Azure CLI
az monitor metrics alert show -g {ResourceGroup} -n {AlertRuleName}

Azure CLI
az monitor metrics alert show –ids {RuleResourceId}

  • With this command, you can disable a metric alert rule.

Azure CLI
az monitor metrics alert update -g {ResourceGroup} -n {AlertRuleName} –enabled false

  • You can delete a metric alert rule using the following command.

Azure CLI
az monitor metrics alert delete -g {ResourceGroup} -n {AlertRuleName}

Create, view, and manage metric alerts using Azure Monitor DP-200 Online course

Reference: Microsoft Documentation

Go back to DP-200 Tutorials

Menu