az monitor alert-processing-rule
Note
This reference is part of the alertsmanagement extension for the Azure CLI (version 2.45.0 or higher). 该扩展会在首次运行 az monitor alert-processing-rule 命令时自动安装。 Learn more about extensions.
此命令组处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus
使用 alertsmanagement 管理警报处理规则。
命令
名称 | 说明 | 类型 | Status |
---|---|---|---|
az monitor alert-processing-rule create |
创建警报处理规则。 |
Extension | Preview |
az monitor alert-processing-rule delete |
删除警报处理规则。 |
Extension | Preview |
az monitor alert-processing-rule list |
列出订阅或资源组中的所有警报处理规则。 |
Extension | Preview |
az monitor alert-processing-rule show |
获取警报处理规则。 |
Extension | Preview |
az monitor alert-processing-rule update |
为警报处理规则启用、禁用或更新标记。 |
Extension | Preview |
az monitor alert-processing-rule create
命令组“监视警报处理规则”处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus
创建警报处理规则。
az monitor alert-processing-rule create --name
--resource-group
--rule-type {AddActionGroups, RemoveAllActionGroups}
--scopes
[--action-groups]
[--description]
[--enabled {false, true}]
[--filter-alert-context]
[--filter-alert-rule-description]
[--filter-alert-rule-id]
[--filter-alert-rule-name]
[--filter-monitor-condition]
[--filter-monitor-service]
[--filter-resource-group]
[--filter-resource-type]
[--filter-severity]
[--filter-signal-type]
[--filter-target-resource]
[--schedule-end-datetime]
[--schedule-recurrence]
[--schedule-recurrence-2]
[--schedule-recurrence-2-end-time]
[--schedule-recurrence-2-start-time]
[--schedule-recurrence-2-type {Daily, Monthly, Weekly}]
[--schedule-recurrence-end-time]
[--schedule-recurrence-start-time]
[--schedule-recurrence-type {Daily, Monthly, Weekly}]
[--schedule-start-datetime]
[--schedule-time-zone]
[--tags]
示例
创建或更新将作组添加到订阅中的所有警报的规则
az monitor alert-processing-rule create \
--name 'AddActionGroupToSubscription' \
--rule-type AddActionGroups \
--scopes "/subscriptions/MySubscriptionId" \
--action-groups "/subscriptions/MySubscriptionId/resourcegroups/MyResourceGroup1/providers/microsoft.insights/actiongroups/ActionGroup1" \
--enabled true \
--resource-group alertscorrelationrg \
--description "Add ActionGroup1 to all alerts in the subscription"
创建或更新将两个作组添加到两个资源组中的所有 Sev0 和 Sev1 警报的规则
az monitor alert-processing-rule create \
--name 'AddActionGroupsBySeverity' \
--rule-type AddActionGroups \
--action-groups "/subscriptions/MySubscriptionId/resourcegroups/MyResourceGroup1/providers/microsoft.insights/actiongroups/MyActionGroupId1" "/subscriptions/MySubscriptionId/resourceGroups/MyResourceGroup2/providers/microsoft.insights/actionGroups/MyActionGroup2" \
--scopes "/subscriptions/MySubscriptionId" \
--resource-group alertscorrelationrg \
--filter-severity Equals Sev0 Sev1 \
--description "Add AGId1 and AGId2 to all Sev0 and Sev1 alerts in these resourceGroups"
创建或更新在一次性维护时段(在特定日期(太平洋标准时间 1800-2000)期间从特定 VM 上的警报中删除所有作组的规则。
az monitor alert-processing-rule create \
--name 'RemoveActionGroupsMaintenanceWindow' \
--rule-type RemoveAllActionGroups \
--scopes "/subscriptions/MySubscriptionId/resourceGroups/MyResourceGroup1/providers/Microsoft.Compute/virtualMachines/VMName" \
--resource-group alertscorrelationrg \
--schedule-start-datetime '2022-01-02 18:00:00' \
--schedule-end-datetime '2022-01-02 20:00:00' \
--schedule-time-zone 'Pacific Standard Time' \
--description "Removes all ActionGroups from all Alerts on VMName during the maintenance window"
创建或更新从来自特定警报规则的订阅中的所有警报中删除所有作组的规则
az monitor alert-processing-rule create \
--name 'RemoveActionGroupsSpecificAlertRule' \
--rule-type RemoveAllActionGroups \
--scopes "/subscriptions/MySubscriptionId" \
--resource-group alertscorrelationrg \
--filter-alert-rule-id Equals "/subscriptions/MySubscriptionId/resourceGroups/MyResourceGroup1/providers/microsoft.insights/activityLogAlerts/RuleName" \
--description "Removes all ActionGroups from all Alerts that fire on above AlertRule"
创建或更新规则,在定期维护时段(印度标准时间 2200-0400 每个星期六和太阳)期间,从两个资源组中的任何 VM 上的所有警报中删除所有作组)
az monitor alert-processing-rule create \
--name 'RemoveActionGroupsRecurringMaintenance' \
--rule-type RemoveAllActionGroups \
--scopes "/subscriptions/MySubscriptionId/resourceGroups/MyResourceGroup1" "/subscriptions/MySubscriptionId/resourceGroups/MyResourceGroup2" \
--resource-group alertscorrelationrg \
--filter-resource-type Equals "microsoft.compute/virtualmachines" \
--schedule-time-zone "India Standard Time" \
--schedule-recurrence-type Weekly \
--schedule-recurrence-start-time "22:00:00" \
--schedule-recurrence-end-time "04:00:00" \
--schedule-recurrence Sunday Saturday \
--description "Remove all ActionGroups from all Virtual machine Alerts during the recurring maintenance"
创建或更新在工作时间之外删除所有作组的规则(Mon-Fri 09:00-17:00、东部标准时间)
az monitor alert-processing-rule create \
--name 'RemoveActionGroupsOutsideBusinessHours' \
--rule-type RemoveAllActionGroups \
--scopes "/subscriptions/MySubscriptionId" \
--resource-group alertscorrelationrg \
--schedule-time-zone "Eastern Standard Time" \
--schedule-recurrence-type Daily \
--schedule-recurrence-start-time "17:00:00" \
--schedule-recurrence-end-time "09:00:00" \
--schedule-recurrence-2-type Weekly \
--schedule-recurrence-2 Saturday Sunday \
--description "Remove all ActionGroups outside business hours"
必需参数
警报处理规则的名称。
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
指示警报处理规则的类型。
属性 | 值 |
---|---|
接受的值: | AddActionGroups, RemoveAllActionGroups |
范围的资源 ID 列表(空格分隔)。 该规则将应用于在该范围内针对资源触发的警报。
可选参数
The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.
要添加的作组的资源 ID 列表(空格分隔)。 使用此参数要求规则类型为 AddActionGroups。
警报处理规则的说明。
指示给定的警报处理规则是启用或禁用的(默认值已启用)。
属性 | 值 |
---|---|
接受的值: | false, true |
按警报上下文(有效负载)筛选警报。
筛选器格式是 <operator> <space-delimited values>
运算符:Equals、NotEquals、Contains、DoesNotContain 值之一:要匹配给定条件的值列表。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按警报规则说明筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按警报 ID 筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按警报规则名称筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按监视条件筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按监视服务筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按资源组筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按资源类型筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按严重性 Sev0、Sev1、Sev2、Sev3、Sev4 筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按信号类型筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
按资源筛选警报。
属性 | 值 |
---|---|
Parameter group: | Filter Arguments |
规则的结束日期。 格式:“YYYY-MM-DD hh:mm:ss”。
属性 | 值 |
---|---|
Parameter group: | Schedule Arguments |
重复模式值列表。
--schedule-recurrence :定期模式值列表(空格分隔)。 对于每周重复类型,允许的值是星期日到星期六。 对于每月重复类型,允许的值为 1 到 31(月中的天数)。
属性 | 值 |
---|---|
Parameter group: | Schedule First Recurrence Arguments |
第二个重复模式的重复模式值列表。
--schedule-recurrence-2:重复模式值列表(空格分隔)。 对于每周重复类型,允许的值是星期日到星期六。 对于每月重复类型,允许的值为 1 到 31(月中的天数)。
属性 | 值 |
---|---|
Parameter group: | Schedule Second Recurrence Arguments |
每个重复周期的结束时间。 Format: hh:mm:ss.
属性 | 值 |
---|---|
Parameter group: | Schedule Second Recurrence Arguments |
每个重复周期的开始时间。 Format: hh:mm:ss.
属性 | 值 |
---|---|
Parameter group: | Schedule Second Recurrence Arguments |
指定何时应应用处理规则。 默认为 Always。
属性 | 值 |
---|---|
Parameter group: | Schedule Second Recurrence Arguments |
接受的值: | Daily, Monthly, Weekly |
每个重复周期的结束时间。 Format: 'hh:mm:ss'.
属性 | 值 |
---|---|
Parameter group: | Schedule First Recurrence Arguments |
每个重复周期的开始时间。 Format: 'hh:mm:ss'.
属性 | 值 |
---|---|
Parameter group: | Schedule First Recurrence Arguments |
指定何时应应用处理规则。
属性 | 值 |
---|---|
Parameter group: | Schedule First Recurrence Arguments |
接受的值: | Daily, Monthly, Weekly |
规则的开始日期。 格式:“YYYY-MM-DD hh:mm:ss”。
属性 | 值 |
---|---|
Parameter group: | Schedule Arguments |
计划时区。
属性 | 值 |
---|---|
Parameter group: | Schedule Arguments |
默认值: | UTC |
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az monitor alert-processing-rule delete
命令组“监视警报处理规则”处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus
删除警报处理规则。
az monitor alert-processing-rule delete [--ids]
[--name]
[--resource-group]
[--subscription]
[--yes]
示例
删除警报处理规则。
az monitor alert-processing-rule delete \
--resource-group myResourceGroup \
--name myRuleName
可选参数
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 |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az monitor alert-processing-rule list
命令组“监视警报处理规则”处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus
列出订阅或资源组中的所有警报处理规则。
az monitor alert-processing-rule list [--resource-group]
示例
列出当前订阅中的所有警报处理规则
az monitor alert-processing-rule list
列出资源组中的所有警报处理规则
az monitor alert-processing-rule 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 |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az monitor alert-processing-rule show
命令组“监视警报处理规则”处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus
获取警报处理规则。
az monitor alert-processing-rule show [--ids]
[--name]
[--resource-group]
[--subscription]
示例
按名称获取警报处理规则
az monitor alert-processing-rule show \
--name myRuleName \
--resource-group myRuleNameResourceGroup
按 ID 获取警报处理规则
az monitor alert-processing-rule show \
--ids ruleId1 ruleId2
可选参数
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 |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |
az monitor alert-processing-rule update
命令组“监视警报处理规则”处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus
为警报处理规则启用、禁用或更新标记。
az monitor alert-processing-rule update [--add]
[--enabled {false, true}]
[--force-string]
[--ids]
[--name]
[--remove]
[--resource-group]
[--set]
[--subscription]
[--tags]
示例
PatchAlertProcessingRule
az monitor alert-processing-rule update \
--name "WeeklySuppression" \
--enabled false \
--tags key1="value1" key2="value2" --resource-group "alertscorrelationrg"
可选参数
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 |
默认值: | [] |
指示给定的处理规则是启用或禁用的(值为 True 和 False)。
属性 | 值 |
---|---|
接受的值: | false, true |
使用“set”或“add”时,保留字符串文本,而不是尝试转换为 JSON。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | False |
一个或多个资源 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 |
默认值: | [] |
资源组的名称。 可以使用 az configure --defaults group=<name>
配置默认组。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
通过指定要设置的属性路径和值来更新对象。 示例:--set property1.property2=<value>
。
属性 | 值 |
---|---|
Parameter group: | Generic Update Arguments |
默认值: | [] |
订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID
配置默认订阅。
属性 | 值 |
---|---|
Parameter group: | Resource Id Arguments |
空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。
全局参数
提高日志记录详细程度以显示所有调试日志。
属性 | 值 |
---|---|
默认值: | False |
显示此帮助消息并退出。
仅显示错误,禁止显示警告。
属性 | 值 |
---|---|
默认值: | False |
Output format.
属性 | 值 |
---|---|
默认值: | json |
接受的值: | json, jsonc, none, table, tsv, yaml, yamlc |
JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/。
增加日志记录详细程度。 使用 --debug 获取完整的调试日志。
属性 | 值 |
---|---|
默认值: | False |