az monitor alert-processing-rule

注意

此參考是 Azure CLI 的 alertsmanagement 延伸模組的一部分(2.45.0 版或更高版本)。 擴充功能會在您第一次執行 az monitor alert-processing-rule 命令時自動安裝。 深入了解擴充功能。

此命令群組處於預覽狀態,且正在開發中。 參考和支援層級: https://aka.ms/CLI_refstatus

使用alertsmanagement管理警示處理規則。

命令

名稱 Description 類型 狀態
az monitor alert-processing-rule create

建立警示處理規則。

副檔名 預覽
az monitor alert-processing-rule delete

刪除警示處理規則。

副檔名 預覽
az monitor alert-processing-rule list

列出訂用帳戶或資源群組中的所有警示處理規則。

副檔名 預覽
az monitor alert-processing-rule show

取得警示處理規則。

副檔名 預覽
az monitor alert-processing-rule update

啟用、停用或更新警示處理規則的標籤。

副檔名 預覽

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"

建立或更新規則,以在一次性維護期間從特定 VM 上的警示中移除所有動作群組(太平洋標準時間特定日期為 1800-2000)

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"

建立或更新規則,以在週期性維護期間,從兩個資源群組中任何 VM 上的所有警示中移除所有動作群組(每個 Sat 和 Sun 2200-0400 每一個星期六和印度標準時間 2200-0400)

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"

建立或更新規則,以移除上班時間以外的所有動作群組 (星期一-星期五 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"

必要參數

--name -n

警示處理規則的名稱。

--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

--rule-type

指出警示處理規則的類型。

接受的值: AddActionGroups, RemoveAllActionGroups
--scopes

範圍的資源標識碼清單(以空格分隔)。 此規則會套用至在該範圍內資源上引發的警示。

選擇性參數

--action-groups

要新增之動作群組的資源標識符清單(以空格分隔)。 使用此自變數需要規則類型為 AddActionGroups。

--description

警示處理規則的描述。

--enabled

指出指定的警示處理規則是否已啟用或停用 (預設值為已啟用)。

接受的值: false, true
--filter-alert-context

依警示內容篩選警示(承載)。

篩選格式是 Operator:其中 <一個 Equals、NotEquals、Contains、DoesNotContain> 值:要符合指定條件的值清單。

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

依嚴重性 <Sev0、Sev1、Sev2、Sev3、Sev4> 篩選警示。

--filter-signal-type

依訊號類型篩選警示。

--filter-target-resource

依資源篩選警示。

--schedule-end-datetime

規則的結束日期。 格式:『YYYY-MM-DD hh:mm:ss』。

--schedule-recurrence

週期模式值的清單。

--schedule-recurrence :週期模式值清單(空格分隔)。 針對每周週期類型,允許的值是星期日到星期六。 針對每月週期類型,允許的值是 1 到 31(月的天數)。

--schedule-recurrence-2

第二個週期模式的週期模式值清單。

--schedule-recurrence-2 :週期模式值清單(空格分隔)。 針對每周週期類型,允許的值是星期日到星期六。 針對每月週期類型,允許的值是 1 到 31(月的天數)。

--schedule-recurrence-2-end-time

每個週期的結束時間。 格式:hh:mm:ss。

--schedule-recurrence-2-start-time

每個週期的開始時間。 格式:hh:mm:ss。

--schedule-recurrence-2-type

指定何時應套用處理規則。 預設為Always。

接受的值: Daily, Monthly, Weekly
--schedule-recurrence-end-time

每個週期的結束時間。 格式:『hh:mm:ss』。

--schedule-recurrence-start-time

每個週期的開始時間。 格式:『hh:mm:ss』。

--schedule-recurrence-type

指定何時應套用處理規則。

接受的值: Daily, Monthly, Weekly
--schedule-start-datetime

規則的開始日期。 格式:『YYYY-MM-DD hh:mm:ss』。

--schedule-time-zone

排程時區。

預設值: UTC
--tags

以空格分隔的標記:key[=value] [key[=value] ...]。使用 「清除現有的標記」。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

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

選擇性參數

--ids

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--name -n

警示處理規則的名稱。

--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--yes -y

不提示確認。

預設值: False
全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

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

選擇性參數

--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

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

依標識碼取得警示處理規則

az monitor alert-processing-rule show \
--ids ruleId1 ruleId2

選擇性參數

--ids

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--name -n

警示處理規則的名稱。

--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。

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"

選擇性參數

--add

藉由指定路徑和索引鍵值組,將物件加入物件清單。 範例:--add property.listProperty <key=value, string or JSON string>

預設值: []
--enabled

指出指定的處理規則是否已啟用或停用 (值為 True 和 False)。

接受的值: false, true
--force-string

使用 'set' 或 'add' 時,請保留字串常值,而不是嘗試轉換成 JSON。

預設值: False
--ids

一或多個資源識別碼 (以空格分隔)。 它應該是包含 「資源標識碼」自變數所有資訊的完整資源識別碼。 您應該提供 --ids 或其他「資源識別碼」自變數。

--name -n

警示處理規則的名稱。

--remove

從清單中移除屬性或專案。 範例: --remove property.list <indexToRemove>--remove propertyToRemove

預設值: []
--resource-group -g

資源群組的名稱。 您可以使用 來設定預設群組 az configure --defaults group=<name>

--set

指定要設定的屬性路徑和值,以更新物件。 範例:--set property1.property2=<value>

預設值: []
--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--tags

以空格分隔的標記:key[=value] [key[=value] ...]。使用 「清除現有的標記」。

全域參數
--debug

增加記錄詳細資訊,以顯示所有偵錯記錄。

--help -h

顯示此說明訊息並結束。

--only-show-errors

只顯示錯誤,隱藏警告。

--output -o

輸出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
預設值: json
--query

JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/

--subscription

訂用帳戶的名稱或標識碼。 您可以使用 來設定預設訂用 az account set -s NAME_OR_ID帳戶。

--verbose

增加記錄詳細資訊。 使用 --debug 來取得完整偵錯記錄。