az monitor metrics alert
管理准实时指标警报规则。
命令
| 名称 | 说明 | 类型 | Status |
|---|---|---|---|
| az monitor metrics alert condition |
管理准实时指标警报规则条件。 |
Core | GA |
| az monitor metrics alert condition create |
生成指标警报规则条件。 |
Core | Preview |
| az monitor metrics alert create |
创建基于指标的警报规则。 |
Core | GA |
| az monitor metrics alert delete |
删除基于指标的警报规则。 |
Core | GA |
| az monitor metrics alert dimension |
管理准实时指标警报规则维度。 |
Core | GA |
| az monitor metrics alert dimension create |
生成指标警报规则维度。 |
Core | Preview |
| az monitor metrics alert list |
列出基于指标的警报规则。 |
Core | GA |
| az monitor metrics alert show |
显示基于指标的警报规则。 |
Core | GA |
| az monitor metrics alert update |
更新基于指标的警报规则。 |
Core | GA |
az monitor metrics alert create
创建基于指标的警报规则。
az monitor metrics alert create --condition
--name
--resource-group
--scopes
[--action]
[--auto-mitigate {false, true}]
[--description]
[--disabled {false, true}]
[--evaluation-frequency]
[--region --target-resource-region]
[--severity]
[--tags]
[--target-resource-type --type]
[--window-size]
示例
在没有操作的 VM 上创建高 CPU 使用率警报。
az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID} --condition "avg Percentage CPU > 90" --description "High CPU"
使用电子邮件和 Webhook 操作在 VM 上创建高 CPU 使用率警报。
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"
使用多维筛选器在存储帐户显示大量慢速事务时创建警报。
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"
创建用于监视自定义指标的基于指标的警报规则。
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
在未执行任何操作的多个 VM 上创建高 CPU 使用率警报。
az monitor metrics alert create -n alert1 -g {ResourceGroup} --scopes {VirtualMachineID1} {VirtualMachineID2} {VirtualMachineID3} \
--condition "avg Percentage CPU > 90" --description "High CPU" --region westus
在未执行任何操作的多个 VM 上创建动态 CPU 使用率警报。
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
必需参数
触发规则的条件。 可以通过“az monitor metrics alert condition create”命令创建它。
用法:--condition {avg,min,max,total,count} [NAMESPACE.]METRIC [{=,!=,>,>=,<,<=} THRESHOLD] [{>,><,<} 动态 SENSITIVITY VIOLATIONS [自 DATETIME]] [where DIMENSION {includes,excludes} VALUE [or VALUE ...][和 DIMENSION {includes,excludes} VALUE [or VALUE ...] ][使用 skipmetricvalidation]
敏感度可以是“low”、“medium”、“high”。
冲突可以是触发警报的冲突数。 它应更小或等于计算。
评估可以是动态阈值的计算周期数。
日期时间可以是开始学习指标历史数据的日期,并计算动态阈值(ISO8601格式)。
可以通过添加“where”关键字和多个维度来查询维度,方法是将它们与“and”关键字组合在一起。
可以从 az monitor metrics list-definitions 命令获取 METRIC、DIMENSION 和适当的 THRESHOLD 值的值。
由于服务器限制,当警报规则包含多个条件时,每个条件中的维度的使用限制为每个维度的一个值。
可以使用多个 --condition 参数来指定多个条件。
警报规则的名称。
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
规则适用的范围的空间分隔列表。 此参数中指定的资源的类型必须相同,并且位于同一位置。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
添加操作组和可选的 Webhook 属性,以在触发警报时触发。
用法:--action ACTION_GROUP_NAME_OR_ID [KEY=VAL [KEY=VAL ...]]
可以使用多个 --action 参数指定多个操作组。
自动解决警报。
| 属性 | 值 |
|---|---|
| 接受的值: | false, true |
规则的自由文本说明。
创建处于禁用状态的规则。
| 属性 | 值 |
|---|---|
| 默认值: | False |
| 接受的值: | false, true |
以“##h##m##s”格式计算规则的频率。
| 属性 | 值 |
|---|---|
| 默认值: | 1m |
范围中目标资源的区域。 当范围是资源组或订阅时,必须提供此项。
警报的严重性从 0(严重)到 4(详细)。
| 属性 | 值 |
|---|---|
| 默认值: | 2 |
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
范围中目标资源的资源类型。 当范围是资源组或订阅时,必须提供此项。
聚合采用“##h##m##s”格式的指标的时间。
| 属性 | 值 |
|---|---|
| 默认值: | 5m |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az monitor metrics alert delete
删除基于指标的警报规则。
az monitor metrics alert delete [--ids]
[--name]
[--resource-group]
[--subscription]
示例
删除基于指标的警报规则。
az monitor metrics alert delete --name MyAlertRule --resource-group MyResourceGroup
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
警报规则的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az monitor metrics alert list
列出基于指标的警报规则。
az monitor metrics alert list [--resource-group]
示例
列出基于指标的警报规则。
az monitor metrics alert list --resource-group MyResourceGroup
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az monitor metrics alert show
显示基于指标的警报规则。
az monitor metrics alert show [--ids]
[--name]
[--resource-group]
[--subscription]
示例
显示基于指标的警报规则。
az --name MyAlertRule --resource-group MyResourceGroup
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
警报规则的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
az monitor metrics alert update
更新基于指标的警报规则。
az monitor metrics alert update [--add]
[--add-action --add-actions]
[--add-condition --add-conditions]
[--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]
示例
禁用/启用基于指标的警报规则。
az monitor metrics alert update --enabled false --name MyAlertRule --resource-group MyResourceGroup
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
通过指定路径和键值对将对象添加到对象列表。 示例:--add property.listProperty <key=value, string or JSON string>。
| 属性 | 值 |
|---|---|
| Parameter group: | Generic Update Arguments |
添加操作组和可选的 Webhook 属性,以在触发警报时触发。
用法:--add-action ACTION_GROUP_NAME_OR_ID [KEY=VAL [KEY=VAL ...]]
可以使用多个 --add-action 参数指定多个操作组。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
| 属性 | 值 |
|---|---|
| Parameter group: | Action Arguments |
添加触发规则的条件。
用法:--add-condition {avg,min,max,total,count} [NAMESPACE.]METRIC [{=,!=,>,>=,<,<=} THRESHOLD] [{>,><,<} 动态 SENSITIVITY VIOLATIONS [自 DATETIME]] [where DIMENSION {includes,excludes} VALUE [or VALUE ...][和 DIMENSION {includes,excludes} VALUE [or VALUE ...] ]
敏感度可以是“low”、“medium”、“high”。
冲突可以是触发警报的冲突数。 它应更小或等于计算。
评估可以是动态阈值的计算周期数。
日期时间可以是开始学习指标历史数据的日期,并计算动态阈值(ISO8601格式)。
可以通过添加“where”关键字和多个维度来查询维度,方法是将它们与“and”关键字组合在一起。
可以从 az monitor metrics list-definitions 命令获取 METRIC、DIMENSION 和适当的 THRESHOLD 值的值。
由于服务器限制,当警报规则包含多个条件时,每个条件中的维度的使用限制为每个维度的一个值。
可以使用多个 --add-condition 参数来指定多个条件。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
| 属性 | 值 |
|---|---|
| Parameter group: | Condition Arguments |
自动解决警报。
| 属性 | 值 |
|---|---|
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
规则的自由文本说明。
是否启用指标警报规则。
| 属性 | 值 |
|---|---|
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
以 ##h##m##s 格式评估规则的频率。
使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。
| 属性 | 值 |
|---|---|
| Parameter group: | Generic Update Arguments |
| 接受的值: | 0, 1, f, false, n, no, t, true, y, yes |
一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
警报规则的名称。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
从列表中删除属性或元素。 示例: --remove property.list <indexToRemove> OR --remove propertyToRemove.
| 属性 | 值 |
|---|---|
| Parameter group: | Generic Update Arguments |
要删除的操作组名称的空格分隔列表。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
| 属性 | 值 |
|---|---|
| Parameter group: | Action Arguments |
要删除的条件名称的空格分隔列表。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
| 属性 | 值 |
|---|---|
| Parameter group: | Condition Arguments |
资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
规则适用的范围的空间分隔列表。 此参数中指定的资源的类型必须相同,并且位于同一位置。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>。
| 属性 | 值 |
|---|---|
| Parameter group: | Generic Update Arguments |
警报的严重性从 0(严重)到 4(详细)。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。
| 属性 | 值 |
|---|---|
| Parameter group: | Resource Id Arguments |
空格分隔标记:key[=value] [key[=value] ...]。支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。
按 ##h##m##s 格式聚合指标的时间。
全局参数
提高日志记录详细程度以显示所有调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
| 属性 | 值 |
|---|---|
| 默认值: | False |
输出格式。
| 属性 | 值 |
|---|---|
| 默认值: | json |
| 接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
| 属性 | 值 |
|---|---|
| 默认值: | False |