az monitor metrics alert

Manage near-realtime metric alert rules.

Commands

az monitor metrics alert create Create a metric-based alert rule.
az monitor metrics alert delete Delete a metrics-based alert rule.
az monitor metrics alert list List metric-based alert rules.
az monitor metrics alert show Show a metrics-based alert rule.
az monitor metrics alert update Update a metric-based alert rule.

az monitor metrics alert create

Create a metric-based alert rule.

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

Examples

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

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 {actionGroupId} 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 or PutBlob"

Required Parameters

--condition

The condition which triggers the rule.

--description

Free-text description of the rule.

--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.

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
--disabled

Create the rule in a disabled state.

accepted values: false, true
--evaluation-frequency

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

default value: 1m
--severity

Severity of the alert from 0 (low) to 4 (high).

default value: 2
--subscription

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

--tags

Space-separated tags in 'key[=value]' format. Use "" to clear existing tags.

--window-size

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

default value: 5m

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). If provided, no other 'Resource Id' arguments should be specified.

--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.

az monitor metrics alert list

List metric-based alert rules.

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

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>.

--subscription

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

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). If provided, no other 'Resource Id' arguments should be specified.

--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.

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

Update a metric-based alert rule. (autogenerated)

az monitor metrics alert update --enabled true --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>.

--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.

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--name -n

Name of the alert rule.

--remove

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

--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.

--set

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

--severity

Severity of the alert from 0 (low) to 4 (high).

--subscription

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

--tags

Space-separated tags in 'key[=value]' format. Use "" to clear existing tags.

--window-size

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