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
The condition which triggers the rule. It can be created by 'az monitor metrics alert condition create' command.
Usage: --condition {avg,min,max,total,count} [NAMESPACE.]METRIC [{=,!=,>,>=,<,<=} THRESHOLD] [{<,>,><} dynamic SENSITIVITY VIOLATIONS of EVALUATIONS [since DATETIME]] [where DIMENSION {includes,excludes} VALUE [or VALUE ...] [and DIMENSION {includes,excludes} VALUE [or VALUE ...] ...]] [with skipmetricvalidation]
Sensitivity can be 'low', 'medium', 'high'.
Violations can be the number of violations to trigger an alert. It should be smaller or equal to evaluation.
Evaluations can be the number of evaluation periods for dynamic threshold.
Datetime can be the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format).
Dimensions can be queried by adding the 'where' keyword and multiple dimensions can be queried by combining them with the 'and' keyword.
Values for METRIC, DIMENSION and appropriate THRESHOLD values can be obtained from az monitor metrics list-definitions
command.
Due to server limitation, when an alert rule contains multiple criterias, the use of dimensions is limited to one value per dimension within each criterion.
Multiple conditions can be specified by using more than one --condition
argument.
Name of the alert rule.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
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
Add an action group and optional webhook properties to fire when the alert is triggered.
Usage: --action ACTION_GROUP_NAME_OR_ID [KEY=VAL [KEY=VAL ...]]
Multiple action groups can be specified by using more than one --action
argument.
Automatically resolve the alert.
Free-text description of the rule.
Create the rule in a disabled state.
Frequency with which to evaluate the rule in "##h##m##s" format.
The region of the target resource(s) in scopes. This must be provided when scopes is resource group or subscription.
Severity of the alert from 0 (critical) to 4 (verbose).
Space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.
The resource type of the target resource(s) in scopes. This must be provided when scopes is resource group or subscription.
Time over which to aggregate metrics in "##h##m##s" format.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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.
az monitor metrics alert delete --name MyAlertRule --resource-group MyResourceGroup
Optional Parameters
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 of the alert rule.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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.
az monitor metrics alert list --resource-group MyResourceGroup
Optional Parameters
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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.
az --name MyAlertRule --resource-group MyResourceGroup
Optional Parameters
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 of the alert rule.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
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 {0, 1, f, false, n, no, t, true, y, yes}]
[--description]
[--enabled {0, 1, f, false, n, no, t, true, y, yes}]
[--evaluation-frequency]
[--force-string {0, 1, f, false, n, no, t, true, y, yes}]
[--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 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 an action group and optional webhook properties to fire when the alert is triggered.
Usage: --add-action ACTION_GROUP_NAME_OR_ID [KEY=VAL [KEY=VAL ...]]
Multiple action groups can be specified by using more than one --add-action
argument. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.
Add a condition which triggers the rule.
Usage: --add-condition {avg,min,max,total,count} [NAMESPACE.]METRIC [{=,!=,>,>=,<,<=} THRESHOLD] [{<,>,><} dynamic SENSITIVITY VIOLATIONS of EVALUATIONS [since DATETIME]] [where DIMENSION {includes,excludes} VALUE [or VALUE ...] [and DIMENSION {includes,excludes} VALUE [or VALUE ...] ...]]
Sensitivity can be 'low', 'medium', 'high'.
Violations can be the number of violations to trigger an alert. It should be smaller or equal to evaluation.
Evaluations can be the number of evaluation periods for dynamic threshold.
Datetime can be the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format).
Dimensions can be queried by adding the 'where' keyword and multiple dimensions can be queried by combining them with the 'and' keyword.
Values for METRIC, DIMENSION and appropriate THRESHOLD values can be obtained from az monitor metrics list-definitions
command.
Due to server limitation, when an alert rule contains multiple criterias, the use of dimensions is limited to one value per dimension within each criterion.
Multiple conditions can be specified by using more than one --add-condition
argument. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.
Automatically resolve the alert.
Free-text description of the rule.
Whether the metric alert rule is enabled.
Frequency with which to evaluate the rule in ##h##m##s
format.
When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.
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 of the alert rule.
Remove a property or an element from a list. Example: --remove property.list <indexToRemove>
OR --remove propertyToRemove
.
Space-separated list of action group names to remove. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.
Space-separated list of condition names to remove. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.
Name of resource group. You can configure the default group using az configure --defaults group=<name>
.
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. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.
Update an object by specifying a property path and value to set. Example: --set property1.property2=<value>
.
Severity of the alert from 0 (critical) to 4 (verbose).
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Space-separated tags: key[=value] [key[=value] ...]. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.
Time over which to aggregate metrics in ##h##m##s
format.
Global Parameters
Increase logging verbosity to show all debug logs.
Show this help message and exit.
Only show errors, suppressing warnings.
Output format.
JMESPath query string. See http://jmespath.org/ for more information and examples.
Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID
.
Increase logging verbosity. Use --debug for full debug logs.
Azure CLI