az monitor scheduled-query

注意

此參考是 Azure CLI 排程查詢延伸模組的一部分(2.54.0 版或更高版本)。 擴充功能會在您第一次執行 az monitor scheduled-query 命令時自動安裝。 深入了解擴充功能。

管理排程查詢的命令。

命令

名稱 Description 類型 狀態
az monitor scheduled-query create

建立排程的查詢。

副檔名 GA
az monitor scheduled-query delete

刪除排程的查詢。

副檔名 GA
az monitor scheduled-query list

列出所有排程的查詢。

副檔名 GA
az monitor scheduled-query show

顯示排程查詢的詳細數據。

副檔名 GA
az monitor scheduled-query update

更新排程的查詢。

副檔名 GA

az monitor scheduled-query create

建立排程的查詢。

az monitor scheduled-query create --condition
                                  --name
                                  --resource-group
                                  --scopes
                                  [--action-groups]
                                  [--auto-mitigate {false, true}]
                                  [--check-ws-alerts-storage {false, true}]
                                  [--condition-query]
                                  [--custom-properties]
                                  [--description]
                                  [--disabled {false, true}]
                                  [--evaluation-frequency]
                                  [--location]
                                  [--mad]
                                  [--severity]
                                  [--skip-query-validation {false, true}]
                                  [--tags]
                                  [--target-resource-type]
                                  [--window-size]

範例

建立 VM 的排程查詢。

az monitor scheduled-query create -g {rg} -n {name1} --scopes {vm_id} --condition "count 'Placeholder_1' > 360 resource id _ResourceId at least 1 violations out of 5 aggregated points" --condition-query Placeholder_1="union Event, Syslog | where TimeGenerated > ago(1h) | where EventLevelName=='Error' or SeverityLevel=='err'" --description "Test rule"

為資源群組中的 VM 建立排程查詢。

az monitor scheduled-query create -g {rg} -n {name1} --scopes {rg_id} --condition "count 'Placeholder_1' > 360 resource id _ResourceId at least 1 violations out of 5 aggregated points" --condition-query Placeholder_1="union Event, Syslog | where TimeGenerated > ago(1h) | where EventLevelName=='Error' or SeverityLevel=='err'" --description "Test rule"

必要參數

--condition

觸發規則的條件。

使用量: --condition {avg,min,max,total,count} [“METRIC COLUMN” from] “QUERY_PLACEHOLDER” {=>,=,>=<,,=,<=} THRESHOLD [resource id RESOURCEID] [where DIMENSION {includes,excludes} VALUE [or VALUE ...][and DIMENSION {includes,excludes} VALUE [or VALUE ...] ...]][至少 MinTimeToFail 違規超過 EvaluationPeriod 匯總點]' 查詢佔位元可以在 --condition-query 自變數維度中定義,方法是新增 'where' 關鍵詞和多個維度,藉由將它們與 'and' 關鍵詞結合來查詢。

--name -n

排程查詢規則的名稱。

--resource-group -g

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

--scopes

規則所套用的範圍以空格分隔的清單。 此參數中指定的資源必須具有相同類型,且存在於相同的位置。

選擇性參數

--action-groups

動作群組資源標識碼,以在警示引發時叫用。

使用方式:-action-groups ACTION_GROUP_NAME_OR_ID [NAME_OR_ID,...]。

--auto-mitigate

指出是否應該自動解決警示的旗標。 預設值為 True。

接受的值: false, true
預設值: True
--check-ws-alerts-storage --cwas

旗標,指出此排程的查詢規則是否應該儲存在客戶的記憶體中。

接受的值: false, true
預設值: False
--condition-query

查詢 deteils 以取代 自變數中的 --condition 佔位元。

--custom-properties

警示承載的屬性。

使用方式:--custom-properties ALERT_PAYLOAD_PROPERTIES [KEY=VAL,KEY=VAL ...]。

--description

規則的任意文字描述。

--disabled

停用排程的查詢。

接受的值: false, true
預設值: False
--evaluation-frequency

以 「##h##m##s」 格式評估規則的頻率。

預設值: 5m
--location -l

位置。​​ 來自的值: az account list-locations。 您可以使用 az configure --defaults location=<location> 設定預設位置。

--mad --mute-actions-duration

在引發警示之後,將所選期間(ISO 8601 持續時間格式)的動作設為靜音。

--severity

警示的嚴重性從 0 (重大) 到 4 (詳細資訊)。

預設值: 2
--skip-query-validation

指出是否應該驗證所提供查詢的旗標。

接受的值: false, true
預設值: False
--tags

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

--target-resource-type --type

範圍中目標資源的資源類型。 當範圍是資源群組或訂用帳戶時,必須提供此專案。

--window-size

用來匯總 “##h##m##s” 格式計量的時間。

預設值: 5m
全域參數
--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 scheduled-query delete

刪除排程的查詢。

az monitor scheduled-query delete [--ids]
                                  [--name]
                                  [--resource-group]
                                  [--subscription]
                                  [--yes]

選擇性參數

--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 scheduled-query list

列出所有排程的查詢。

az monitor scheduled-query list [--resource-group]

選擇性參數

--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 scheduled-query show

顯示排程查詢的詳細數據。

az monitor scheduled-query show [--ids]
                                [--name]
                                [--resource-group]
                                [--subscription]

選擇性參數

--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 scheduled-query update

更新排程的查詢。

az monitor scheduled-query update [--action-groups]
                                  [--add]
                                  [--auto-mitigate {false, true}]
                                  [--check-ws-alerts-storage {false, true}]
                                  [--condition]
                                  [--condition-query]
                                  [--custom-properties]
                                  [--description]
                                  [--disabled {false, true}]
                                  [--evaluation-frequency]
                                  [--force-string]
                                  [--ids]
                                  [--mad]
                                  [--name]
                                  [--remove]
                                  [--resource-group]
                                  [--set]
                                  [--severity]
                                  [--skip-query-validation {false, true}]
                                  [--subscription]
                                  [--tags]
                                  [--target-resource-type]
                                  [--window-size]

選擇性參數

--action-groups

動作群組資源標識碼,以在警示引發時叫用。

--add

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

預設值: []
--auto-mitigate

指出是否應該自動解決警示的旗標。 預設值為 True。

接受的值: false, true
--check-ws-alerts-storage --cwas

旗標,指出此排程的查詢規則是否應該儲存在客戶的記憶體中。

接受的值: false, true
--condition

觸發規則的條件。

使用量: --condition {avg,min,max,total,count} [“METRIC COLUMN” from] “QUERY_PLACEHOLDER” {=>,=,>=<,,=,<=} THRESHOLD [resource id RESOURCEID] [where DIMENSION {includes,excludes} VALUE [or VALUE ...][and DIMENSION {includes,excludes} VALUE [or VALUE ...] ...]][至少 MinTimeToFail 違規違反 EvaluationPeriod 匯總點]'

您可以在 --condition-query 自變數維度中定義查詢佔位符,方法是新增 'where' 關鍵詞和多個維度,方法是將它們與 'and' 關鍵詞結合來查詢。

--condition-query

查詢 deteils 以取代 自變數中的 --condition 佔位元。

--custom-properties

警示承載的屬性。

使用方式:--custom-properties ALERT_PAYLOAD_PROPERTIES [KEY=VAL,KEY=VAL ...]。

--description

規則的任意文字描述。

--disabled

停用排程的查詢。

接受的值: false, true
--evaluation-frequency

以 「##h##m##s」 格式評估規則的頻率。

--force-string

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

預設值: False
--ids

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

--mad --mute-actions-duration

在引發警示之後,將所選期間(ISO 8601 持續時間格式)的動作設為靜音。

--name -n

排程查詢規則的名稱。

--remove

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

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

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

--set

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

預設值: []
--severity

警示的嚴重性從 0 (重大) 到 4 (詳細資訊)。

--skip-query-validation

指出是否應該驗證所提供查詢的旗標。

接受的值: false, true
--subscription

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

--tags

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

--target-resource-type --type

範圍中目標資源的資源類型。 當範圍是資源群組或訂用帳戶時,必須提供此專案。

--window-size

用來匯總 “##h##m##s” 格式計量的時間。

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