az monitor alert

Manage metric-based alert rules.

Commands

az monitor alert create Create a metric-based alert rule.
az monitor alert delete Delete an alert rule.
az monitor alert list List alert rules in a resource group.
az monitor alert list-incidents List all incidents for an alert rule.
az monitor alert show Show an alert rule.
az monitor alert show-incident Get the details of an alert rule incident.
az monitor alert update Update a metric-based alert rule.

az monitor alert create

Create a metric-based alert rule.

az monitor alert create --condition
--name
--resource-group
--target
[--action]
[--description]
[--disabled {false, true}]
[--email-service-owners {false, true}]
[--location]
[--tags]
[--target-namespace]
[--target-parent]
[--target-type]

Examples

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

az monitor alert create -n rule1 -g {RG} --target {VM ID} --condition "Percentage CPU > 90 avg 5m"

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

az monitor alert create -n rule1 -g {RG} --target {VM ID}     --condition "Percentage CPU > 90 avg 5m"     --action email bob@contoso.comann@contoso.com --email-service-owners     --action webhook https://www.contoso.com/alerts?type=HighCPU     --action webhook https://alerts.contoso.com apiKey={KEY} type=HighCPU

Required Parameters

--condition
The condition which triggers 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>`.
--target
Name or ID of the target resource.

Optional Parameters

--action -a
Add an action to fire when the alert is triggered.
--description
Free-text description of the rule. Defaults to the condition expression.
--disabled
Create the rule in a disabled state.
accepted values: false, true
--email-service-owners
Email the service owners if an alert is triggered.
accepted values: false, true
--location -l
Location. You can configure the default location using `az configure --defaults location=<location>`.
--tags
Space separated tags in 'key[=value]' format. Use "" to clear existing tags.
--target-namespace
Target resource provider namespace.
--target-parent
Target resource parent path, if applicable.
--target-type
Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines)').

az monitor alert delete

Delete an alert rule.

az monitor alert delete --name
--resource-group

Required Parameters

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

az monitor alert list

List alert rules in a resource group.

az monitor alert list --resource-group

Required Parameters

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

az monitor alert list-incidents

List all incidents for an alert rule.

az monitor alert list-incidents --resource-group
--rule-name

Required Parameters

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

az monitor alert show

Show an alert rule.

az monitor alert show --name
--resource-group

Required Parameters

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

az monitor alert show-incident

Get the details of an alert rule incident.

az monitor alert show-incident --name
--resource-group
--rule-name

Required Parameters

--name -n
The name of the incident to retrieve.
--resource-group -g
Name of resource group. You can configure the default group using `az configure --defaults group=<name>`.
--rule-name
Name of the alert rule.

az monitor alert update

Update a metric-based alert rule.

az monitor alert update --name
--resource-group
[--add]
[--add-action]
[--aggregation {avg, last, max, min, total}]
[--condition]
[--description]
[--email-service-owners {false, true}]
[--enabled]
[--metric]
[--operator {<,><=,>, >=}]
[--period]
[--remove]
[--remove-action]
[--set]
[--tags]
[--target]
[--target-namespace]
[--target-parent]
[--target-type]
[--threshold]

Required Parameters

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

Optional Parameters

--add
Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty .
--add-action -a
Add an action to fire when the alert is triggered.
--aggregation
Type of aggregation to apply based on --period.
accepted values: avg, last, max, min, total
--condition
The condition which triggers the rule.
--description
Description of the rule.
--email-service-owners
Email the service owners if an alert is triggered.
accepted values: false, true
--enabled
--metric
Name of the metric to base the rule on.
value from: az monitor metrics list-definitions
--operator
How to compare the metric against the threshold.
accepted values: <, <=, >, >=
--period
Time span over which to apply --aggregation, in nDnHnMnS shorthand or full ISO8601 format.
--remove
Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.
--remove-action -r
Remove one or more actions.
--set
Update an object by specifying a property path and value to set. Example: --set property1.property2=.
--tags
Space separated tags in 'key[=value]' format. Use "" to clear existing tags.
--target
ID of the resource to target for the alert rule.
--target-namespace
Target resource provider namespace.
--target-parent
Target resource parent path, if applicable.
--target-type
Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines)').
--threshold
Numeric threshold at which to trigger the alert.