Manage your alert rules

Manage your alert rules in the Azure portal, or using the CLI or PowerShell.

Manage alert rules in the Azure portal

  1. In the portal, select Monitor, then Alerts.
  2. From the top command bar, select Alert rules. You'll see all of your alert rules across subscriptions. You can filter the list of rules using the available filters: Resource group, Resource type, Resource and Signal type.
  3. Select the alert rule that you want to edit. You can select multiple alert rules and enable or disable them. Multi-selecting rules can be useful when you want to perform maintenance on specific resources.
  4. Edit any of the fields in the following sections. You can't edit the Alert Rule Name, or the Signal type of an existing alert rule.
    • Scope. You can edit the scope for all alert rules other than:
      • Log alert rules
      • Metric alert rules that monitor a custom metric
      • Smart detection alert rules
    • Condition. Learn more about conditions for metric alert rules, log alert rules, and activity log alert rules
    • Actions
    • Alert rule details
  5. Select Save on the top command bar.

Note

This section describes how to manage alert rules created in the latest UI or using an API version later than 2018-04-16. See View and manage log alert rules created in previous versions for information about how to view and manage log alert rules created in the previous UI.

If you don't have alert rules defined for the selected resource, either individually or as part of a resource group or subscription, you can create a new alert rule, or enable recommended out-of-the-box alert rules in the Azure portal.

The system compiles a list of recommended alert rules based on:

  • The resource provider’s knowledge of important signals and thresholds for monitoring the resource.
  • Telemetry that tells us what customers commonly alert on for this resource.

Note

The alert rule recommendations feature is currently in preview and is only enabled for:

  • Virtual machines
  • AKS resources
  • Log Analytics workspaces

Screenshot of alerts page with link to recommended alert rules.

To enable recommended alert rules:

  1. On the Alerts page, select Enable recommended alert rules. The Enable recommended alert rules pane opens with a list of recommended alert rules based on your type of resource.
  2. In the Alert me if section, select all of the rules you want to enable. The rules are populated with the default values for the rule condition, such as the percentage of CPU usage that you want to trigger an alert. You can change the default values if you would like.
  3. In the Notify me by section, select the way you want to be notified if an alert is fired.
  4. Select Enable.

Screenshot of recommended alert rules pane.

Manage metric alert rules with the Azure CLI

This section describes how to manage metric alert rules using the cross-platform Azure CLI. The following examples use Azure Cloud Shell.

  1. In the portal, select Cloud Shell.

  2. Use these options of the az monitor metrics alert CLI command in this table:

    What you want to do CLI command
    View all the metric alerts in a resource group az monitor metrics alert list -g {ResourceGroup}
    See the details of a metric alert rule az monitor metrics alert show -g {ResourceGroup} -n {AlertRuleName}
    az monitor metrics alert show --ids {RuleResourceId}
    Disable a metric alert rule az monitor metrics alert update -g {ResourceGroup} -n {AlertRuleName} --enabled false
    Delete a metric alert rule az monitor metrics alert delete -g {ResourceGroup} -n {AlertRuleName}
    Learn more about the command az monitor metrics alert --help

Manage metric alert rules with PowerShell

Metric alert rules have these dedicated PowerShell cmdlets:

Manage metric alert rules with REST API

Manage log alert rules using the CLI

This section describes how to manage log alerts using the cross-platform Azure CLI. The following examples use Azure Cloud Shell.

Note

Azure CLI support is only available for the scheduledQueryRules API version 2021-08-01 and later. Previous API versions can use the Azure Resource Manager CLI with templates as described below. If you use the legacy Log Analytics Alert API, you will need to switch to use CLI. Learn more about switching.

  1. In the portal, select Cloud Shell.

  2. Use these options of the az monitor scheduled-query alert CLI command in this table:

    What you want to do CLI command
    View all the log alert rules in a resource group az monitor scheduled-query list -g {ResourceGroup}
    See the details of a log alert rule az monitor scheduled-query show -g {ResourceGroup} -n {AlertRuleName}
    az monitor scheduled-query show --ids {RuleResourceId}
    Disable a log alert rule az monitor scheduled-query update -g {ResourceGroup} -n {AlertRuleName} --disabled true
    Delete a log alert rule az monitor scheduled-query delete -g {ResourceGroup} -n {AlertRuleName}
    Learn more about the command az monitor scheduled-query --help

Manage log alert rules using the Azure Resource Manager CLI with templates

az login
az deployment group create \
    --name AlertDeployment \
    --resource-group ResourceGroupofTargetResource \
    --template-file mylogalerttemplate.json \
    --parameters @mylogalerttemplate.parameters.json

A 201 response is returned on successful creation. 200 is returned on successful updates.

Manage log alert rules with PowerShell

Log alert rules have this dedicated PowerShell cmdlet:

Manage activity log alert rules using PowerShell

Activity log alerts have these dedicated PowerShell cmdlets:

Next steps