Share via


az alerts-management prometheus-rule-group

注意

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

管理 Prometheus 規則群組。

命令

名稱 Description 類型 狀態
az alerts-management prometheus-rule-group create

建立 Prometheus 規則群組定義。

擴充 GA
az alerts-management prometheus-rule-group delete

刪除 Prometheus 規則群組定義。

擴充 GA
az alerts-management prometheus-rule-group list

列出訂用帳戶中的所有規則群組定義。

擴充 GA
az alerts-management prometheus-rule-group show

取得 Prometheus 規則群組定義。

擴充 GA
az alerts-management prometheus-rule-group update

更新 Prometheus 規則群組定義。

擴充 GA

az alerts-management prometheus-rule-group create

建立 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group create --name
                                                  --resource-group
                                                  --rules
                                                  --scopes
                                                  [--cluster-name]
                                                  [--description]
                                                  [--enabled {0, 1, f, false, n, no, t, true, y, yes}]
                                                  [--interval]
                                                  [--location]
                                                  [--tags]

範例

建立 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group create -n TestPrometheusRuleGroup -g TestResourceGroup -l westus --enabled --description "test" --interval PT10M --scopes "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/testrg/providers/microsoft.monitor/accounts/testaccount" --rules [{"record":"test","expression":"test","labels":{"team":"prod"}},{"alert":"Billing_Processing_Very_Slow","expression":"test","enabled":"true","severity":2,"for":"PT5M","labels":{"team":"prod"},"annotations":{"annotationName1":"annotationValue1"},"resolveConfiguration":{"autoResolved":"true","timeToResolve":"PT10M"},"actions":[{"actionGroupId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/microsoft.insights/actionGroups/test-action-group-name1","actionProperties":{"key11":"value11","key12":"value12"}},{"actionGroupId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/microsoft.insights/actionGroups/test-action-group-name2","actionProperties":{"key21":"value21","key22":"value22"}}]}]

必要參數

--name -n

規則群組的名稱。

--resource-group -g

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

--rules

定義 Prometheus 規則群組中的規則。 支援速記語法、json-file 和 yaml-file。 請嘗試 「??」 以顯示更多。

--scopes

目標 Azure 監視器工作區資源識別碼。 此 API 版本目前僅限於使用一個範圍建立。 這可能會在未來變更。 支援速記語法、json-file 和 yaml-file。 請嘗試 「??」 以顯示更多。

選擇性參數

--cluster-name

將規則套用至來自特定叢集的資料。

--description

規則群組描述。

--enabled

啟用/停用規則群組。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--interval

執行以 ISO 8601 持續時間格式表示之 Prometheus 規則群組的間隔。 應介於 1 到 15 分鐘之間。

--location -l

未指定資源所在的地理位置,將會使用資源群組的位置。

--tags

資源標籤。 支援速記語法、json-file 和 yaml-file。 請嘗試 「??」 以顯示更多。

全域參數
--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 alerts-management prometheus-rule-group delete

刪除 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group delete [--ids]
                                                  [--name]
                                                  [--resource-group]
                                                  [--subscription]

範例

刪除 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group delete -n TestPrometheusRuleGroup -g MyResourceGroup

選擇性參數

--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 alerts-management prometheus-rule-group list

列出訂用帳戶中的所有規則群組定義。

az alerts-management prometheus-rule-group list [--resource-group]

範例

列出 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group list -g 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 alerts-management prometheus-rule-group show

取得 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group show [--ids]
                                                [--name]
                                                [--resource-group]
                                                [--subscription]

範例

顯示 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group show -n TestPrometheusRuleGroup -g MyResourceGroup

選擇性參數

--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 alerts-management prometheus-rule-group update

更新 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group update [--add]
                                                  [--cluster-name]
                                                  [--description]
                                                  [--enabled {0, 1, f, false, n, no, t, true, y, yes}]
                                                  [--force-string {0, 1, f, false, n, no, t, true, y, yes}]
                                                  [--ids]
                                                  [--interval]
                                                  [--name]
                                                  [--remove]
                                                  [--resource-group]
                                                  [--rules]
                                                  [--scopes]
                                                  [--set]
                                                  [--subscription]
                                                  [--tags]

範例

更新 Prometheus 規則群組定義。

az alerts-management prometheus-rule-group update -n TestPrometheusRuleGroup -g MyResourceGroup --tags key=value

選擇性參數

--add

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

--cluster-name

將規則套用至來自特定叢集的資料。

--description

規則群組描述。

--enabled

啟用/停用規則群組。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--force-string

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

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--ids

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

--interval

執行以 ISO 8601 持續時間格式表示之 Prometheus 規則群組的間隔。 應介於 1 到 15 分鐘之間。

--name -n

規則群組的名稱。

--remove

從清單中移除屬性或專案。 範例:--remove property.list OR --remove 屬性ToRemove。

--resource-group -g

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

--rules

定義 Prometheus 規則群組中的規則。 支援速記語法、json-file 和 yaml-file。 請嘗試 「??」 以顯示更多。

--scopes

目標 Azure 監視器工作區資源識別碼。 此 API 版本目前僅限於使用一個範圍建立。 這可能會在未來變更。 支援速記語法、json-file 和 yaml-file。 請嘗試 「??」 以顯示更多。

--set

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

--subscription

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

--tags

資源標籤。 支援速記語法、json-file 和 yaml-file。 請嘗試 「??」 以顯示更多。

全域參數
--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 來取得完整偵錯記錄。