az monitor metrics alert

Manage near-realtime metric alert rules.

Commands

Name Description Type Status
az monitor metrics alert condition

Manage near-realtime metric alert rule conditions.

Core GA
az monitor metrics alert condition create

Build a metric alert rule condition.

Core Preview
az monitor metrics alert create

Create a metric-based alert rule.

Core GA
az monitor metrics alert delete

Delete a metrics-based alert rule.

Core GA
az monitor metrics alert dimension

Manage near-realtime metric alert rule dimensions.

Core GA
az monitor metrics alert dimension create

Build a metric alert rule dimension.

Core Preview
az monitor metrics alert list

List metric-based alert rules.

Core GA
az monitor metrics alert show

Show a metrics-based alert rule.

Core GA
az monitor metrics alert update

Update a metric-based alert rule.

Core GA

az monitor metrics alert create

Create a metric-based alert rule.

az monitor metrics alert create --condition
                                --name
                                --resource-group
                                --scopes
                                [--action]
                                [--auto-mitigate {false, true}]
                                [--description]
                                [--disabled {false, true}]
                                [--evaluation-frequency]
                                [--region]
                                [--severity]
                                [--tags]
                                [--target-resource-type]
                                [--window-size]

Examples

Create a high CPU usage alert on a VM with no action.

az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID} --condition "avg Percentage CPU > 90" --description "High CPU"

Create a high CPU usage alert on a VM with email and webhook actions.

az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID} \
    --condition "avg Percentage CPU > 90" --window-size 5m --evaluation-frequency 1m \
    --action "/subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Insights/actionGroups/<actionGroupName>" apiKey={APIKey} type=HighCPU \
    --description "High CPU"

Create an alert when a storage account shows a high number of slow transactions, using multi-dimensional filters.

az monitor metrics alert create -g {ResourceGroup} -n alert1 --scopes {StorageAccountId} \
    --description "Storage Slow Transactions" \
    --condition "total transactions > 5 where ResponseType includes Success" \
    --condition "avg SuccessE2ELatency > 250 where ApiName includes GetBlob"

Create a metric-based alert rule that monitors a custom metric.

az monitor metrics alert create -n "metric alert rule on a custom metric" -g "Demos" --scopes {VirtualMachineID} \
    --condition "max Azure.VM.Windows.GuestMetrics.Memory\Available Bytes > 90" \
    --window-size 5m --evaluation-frequency 1m

Create a high CPU usage alert on several VMs with no actions.

az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID1} {VirtualMachineID2} {VirtualMachineID3} \
    --condition "avg Percentage CPU > 90" --description "High CPU" --region westus

Create a dynamic CPU usage alert on several VMs with no actions.

az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID1} {VirtualMachineID2} {VirtualMachineID3} \
    --condition "avg Percentage CPU > dynamic medium 2 of 4 since 2020-10-01T10:23:00.000Z"
    --description "Dynamic CPU"
    --window-size 5m
    --region westus

Required Parameters

--condition

The condition which triggers the rule. It can be created by 'az monitor metrics alert condition create' command.

--name -n

Name of the alert rule.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--scopes

Space-separated list of scopes the rule applies to. The resources specified in this parameter must be of the same type and exist in the same location.

Optional Parameters

--action -a

Add an action group and optional webhook properties to fire when the alert is triggered.

--auto-mitigate

Automatically resolve the alert.

accepted values: false, true
--description

Free-text description of the rule.

--disabled

Create the rule in a disabled state.

accepted values: false, true
default value: False
--evaluation-frequency

Frequency with which to evaluate the rule in "##h##m##s" format.

default value: 1m
--region --target-resource-region

The region of the target resource(s) in scopes. This must be provided when scopes is resource group or subscription.

--severity

Severity of the alert from 0 (critical) to 4 (verbose).

default value: 2
--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--target-resource-type --type

The resource type of the target resource(s) in scopes. This must be provided when scopes is resource group or subscription.

--window-size

Time over which to aggregate metrics in "##h##m##s" format.

default value: 5m
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics alert delete

Delete a metrics-based alert rule.

az monitor metrics alert delete [--ids]
                                [--name]
                                [--resource-group]
                                [--subscription]

Examples

Delete a metrics-based alert rule. (autogenerated)

az monitor metrics alert delete --name MyAlertRule --resource-group MyResourceGroup

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the alert rule.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics alert list

List metric-based alert rules.

az monitor metrics alert list [--resource-group]

Examples

List metric-based alert rules. (autogenerated)

az monitor metrics alert list --resource-group MyResourceGroup

Optional Parameters

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics alert show

Show a metrics-based alert rule.

az monitor metrics alert show [--ids]
                              [--name]
                              [--resource-group]
                              [--subscription]

Examples

Show a metrics-based alert rule. (autogenerated)

az monitor metrics alert show --name MyAlertRule --resource-group MyResourceGroup

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the alert rule.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics alert update

Update a metric-based alert rule.

az monitor metrics alert update [--add]
                                [--add-action]
                                [--add-condition]
                                [--auto-mitigate {false, true}]
                                [--description]
                                [--enabled {false, true}]
                                [--evaluation-frequency]
                                [--force-string]
                                [--ids]
                                [--name]
                                [--remove]
                                [--remove-actions]
                                [--remove-conditions]
                                [--resource-group]
                                [--scopes]
                                [--set]
                                [--severity]
                                [--subscription]
                                [--tags]
                                [--window-size]

Examples

Disable/Enable a metric-based alert rule.

az monitor metrics alert update --enabled false --name MyAlertRule --resource-group MyResourceGroup

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

default value: []
--add-action

Add an action group and optional webhook properties to fire when the alert is triggered.

--add-condition

Add a condition which triggers the rule.

--auto-mitigate

Automatically resolve the alert.

accepted values: false, true
--description

Free-text description of the rule.

--enabled

Whether the metric alert rule is enabled.

accepted values: false, true
--evaluation-frequency

Frequency with which to evaluate the rule in "##h##m##s" format.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

default value: False
--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

Name of the alert rule.

--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

default value: []
--remove-actions

Space-separated list of action group names to remove.

--remove-conditions

Space-separated list of condition names to remove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--scopes

Space-separated list of scopes the rule applies to. The resources specified in this parameter must be of the same type and exist in the same location.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

default value: []
--severity

Severity of the alert from 0 (critical) to 4 (verbose).

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--tags

Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.

--window-size

Time over which to aggregate metrics in "##h##m##s" format.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.