แชร์ผ่าน


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.

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

Usage: --action ACTION_GROUP_NAME_OR_ID [KEY=VAL [KEY=VAL ...]]

Multiple action groups can be specified by using more than one --action argument.

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

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

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.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

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.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.

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

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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 {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

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

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-condition --add-conditions

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.

--auto-mitigate

Automatically resolve the alert.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--description

Free-text description of the rule.

--enabled

Whether the metric alert rule is enabled.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--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.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--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 <indexToRemove> OR --remove propertyToRemove.

--remove-actions

Space-separated list of action group names to remove. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

--remove-conditions

Space-separated list of condition names to remove. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

--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. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=<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] ...]. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

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

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--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.