查詢警示規則列表中的所有規則。
介面說明
本文將提供一個樣本,查詢當前阿里雲帳號下的警示規則列表中的所有警示規則。返回結果顯示,警示規則列表中只有一條警示規則,該警示規則的名稱為Rule_01、ID 為applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
cms:DescribeMetricRuleList |
get |
*全部資源
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| MetricName |
string |
否 |
監控項名稱。 關於如何擷取監控項名稱,請參見 DescribeMetricMetaList 或雲產品監控項。 補充說明:針對組合指標,只能夠根據第一個指標項進行檢索。 |
cpu_total |
| EnableState |
boolean |
否 |
警示規則的啟用狀態。取值:
|
true |
| Namespace |
string |
否 |
雲產品的命名空間。 關於如何擷取雲產品的命名空間,請參見 DescribeMetricMetaList 或雲產品監控項。 |
acs_ecs_dashboard |
| Page |
integer |
否 |
頁碼。 起始值:1。預設值:1。 |
1 |
| PageSize |
integer |
否 |
分頁時每頁顯示的資料行數。 起始值:1。預設值:10。 |
10 |
| AlertState |
string |
否 |
警示規則狀態。取值:
|
OK |
| Dimensions |
string |
否 |
指定資源的監控維度。 格式: |
{"instanceId":"i-2ze2d6j5uhg20x47****"} |
| RuleName |
string |
否 |
警示規則名稱。 該參數支援模糊查詢。 |
Rule_01 |
| GroupId |
string |
否 |
應用分組 ID。 關於如何擷取應用分組 ID,請參見 DescribeMonitorGroups 。 |
7301**** |
| RuleIds |
string |
否 |
警示規則 ID。多個警示規則 ID 之間用半形逗號(,)分隔,一次最多可查詢 20 條。 |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
關於公用請求參數的詳情,請參見公用參數。
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
無。 |
||
| Code |
integer |
狀態代碼。 說明
200 表示成功。 |
200 |
| Message |
string |
錯誤資訊。 |
The specified resource is not found. |
| RequestId |
string |
請求 ID。 |
386C6712-335F-5054-930A-CC92B851ECBA |
| Total |
string |
總記錄數。 |
1 |
| Success |
boolean |
操作是否成功。取值:
|
true |
| Alarms |
object |
||
| Alarm |
array<object> |
警示規則列表。 |
|
|
array<object> |
無。 |
||
| SilenceTime |
integer |
通道沉默周期。單位:秒。預設值:86400,最小值:3600。 監控資料持續超過警示規則閾值時,每個沉默周期內只發送一次警示通知。 |
86400 |
| MetricName |
string |
監控項名稱。 |
cpu_total |
| Webhook |
string |
警示發生回調時的 URL 地址。CloudMonitor會將警示資訊通過 POST 請求推送到該地址,目前僅支援 HTTP 協議。 |
https://www.aliyun.com |
| ContactGroups |
string |
警示聯絡組。 |
ECS_Alarm |
| SourceType |
string |
警示規則類型。取值:METRIC,表示時序指標警示規則。 |
METRIC |
| Namespace |
string |
雲端服務的命名空間。 |
acs_ecs_dashboard |
| MailSubject |
string |
警示郵件主題。 |
"${serviceType}-${metricName}-${levelDescription}通知(${dimensions})" |
| NoEffectiveInterval |
string |
警示規則的失效時間範圍。 |
00:00-05:30 |
| EffectiveInterval |
string |
警示規則的生效時間範圍。 |
05:31-23:59 |
| RuleName |
string |
警示規則名稱。 |
Rule_01 |
| AlertState |
string |
警示規則狀態。取值:
|
OK |
| Period |
string |
統計周期。 |
60 |
| RuleId |
string |
警示規則 ID。 |
applyTemplate344cfd42-0f32-4fd6-805a-88d7908a**** |
| GroupName |
string |
應用分組名稱。 說明
如果警示規則關聯到應用分組,此處顯示該參數。 |
ECS_Group |
| GroupId |
string |
應用分組 ID。 |
7301**** |
| Dimensions |
string |
警示規則維度。 |
[{"instanceId":"i-2ze2d6j5uhg20x47****"}] |
| EnableState |
boolean |
啟用狀態。取值:
|
true |
| Resources |
string |
警示規則關聯的資源。 |
[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}] |
| Escalations |
object |
警示分層級觸發條件。 |
|
| Info |
object |
Info 層級警示觸發條件。 |
|
| ComparisonOperator |
string |
Info 層級閾值比較符。取值:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
Info 層級警示的前置條件。當參數 ComparisonOperator 設定為同比或環比時,與該參數共同起作用。 例如:該參數設定為$Average>80,ComparisonOperator 設定為 GreaterThanYesterday,Threshold 設定為 10,表示當平均值大於 80 且環比昨天上漲 10%時,觸發警示。 說明
$Average>0 中的$Average 為一個預留位置,格式為$監控結果欄位值,CloudMonitor會將其替換為對應的統計值或原始的監控值。 |
$Average>80 |
| Times |
integer |
Info 層級警示連續出現次數。警示連續出現這個次數,且超過閾值才會觸發警示。 |
3 |
| Threshold |
string |
Info 層級警示閾值。 |
90 |
| Statistics |
string |
Info 層級警示統計方法。 |
Average |
| Warn |
object |
Warn 層級警示觸發條件。 |
|
| ComparisonOperator |
string |
Warn 層級閾值比較符。取值:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
Warn 層級警示的前置條件。當參數 ComparisonOperator 設定為同比或環比時,與該參數共同起作用。 例如:該參數設定為$Average>80,ComparisonOperator 設定為 GreaterThanYesterday,Threshold 設定為 10,表示當平均值大於 80 且環比昨天上漲 10%時,觸發警示。 說明
$Average>0 中的$Average 為一個預留位置,格式為$監控結果欄位值,CloudMonitor會將其替換為對應的統計值或原始的監控值。 |
$Average>80 |
| Times |
integer |
Warn 層級警示連續出現次數。警示連續出現這個次數,且超過閾值才會觸發警示。 |
3 |
| Threshold |
string |
Warn 層級警示閾值。 |
90 |
| Statistics |
string |
Warn 層級警示統計方法。 |
Average |
| Critical |
object |
Critical 層級警示觸發條件。 |
|
| ComparisonOperator |
string |
Critical 層級閾值比較符。取值:
|
GreaterThanOrEqualToThreshold |
| PreCondition |
string |
Critical 層級警示的前置條件。當參數 ComparisonOperator 設定為同比或環比時,與該參數共同起作用。 例如:該參數設定為$Average>80,ComparisonOperator 設定為 GreaterThanYesterday,Threshold 設定為 10,表示當平均值大於 80 且環比昨天上漲 10%時,觸發警示。 說明
$Average>0 中的$Average 為一個預留位置,格式為 |
$Average>80 |
| Times |
integer |
Critical 層級警示連續出現次數。警示連續出現這個次數,且超過閾值才會觸發警示。 |
3 |
| Threshold |
string |
Critical 層級警示閾值。 |
90 |
| Statistics |
string |
Critical 層級警示統計方法。 |
Average |
| NoDataPolicy |
string |
無監控資料時警示的處理方式。取值:
|
KEEP_LAST_STATE |
| CompositeExpression |
object |
多指標的警示條件。 說明
單指標和多指標互斥,不能同時設定。 |
|
| Level |
string |
警示層級。取值:
|
CRITICAL |
| ExpressionList |
object |
||
| ExpressionList |
array<object> |
標準建立的警示條件列表。 |
|
|
object |
無。 |
||
| MetricName |
string |
雲產品的監控項名稱。 |
cpu_total |
| Period |
integer |
監控項的彙總周期。 單位:秒。 |
60 |
| Statistics |
string |
監控項的統計方法。取值:
說明
|
$Maximum |
| ComparisonOperator |
string |
閾值比較符。取值:
|
GreaterThanOrEqualToThreshold |
| Threshold |
string |
警示閾值。 |
90 |
| ExpressionListJoin |
string |
多指標警示條件之間的關係。取值:
|
|| |
| ExpressionRaw |
string |
運算式建立的警示條件。包括但不限於以下情況:
|
$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50) |
| Times |
integer |
發出警示通知需要達到警示條件的次數。 |
3 |
| Labels |
object |
||
| Labels |
array<object> |
警示規則標籤。 |
|
|
object |
無。 |
||
| Key |
string |
警示規則的標籤鍵。 |
cmsRuleKey |
| Value |
string |
警示規則的標籤值。 |
cmsRuleValue |
| Prometheus |
object |
Prometheus 警示。 說明
僅當您為企業CloudMonitor建立 Prometheus 警示規則,需要設定該參數。 |
|
| PromQL |
string |
PromQL 查詢語句。 說明
通過 PromQL 查詢語句擷取的資料即為警示資料,請您在該語句中攜帶警示閾值。 |
CpuUsage{instanceId="xxxx"}[1m]>90 |
| Level |
string |
警示層級。取值:
|
CRITICAL |
| Times |
integer |
發出警示通知需要達到警示條件的次數。 |
3 |
| Annotations |
object |
||
| Annotations |
array<object> |
Prometheus 警示時,將注釋的鍵和值進行渲染,易於您對監控項或警示規則的理解。 說明
該功能等同於 Prometheus 的 Annotation。 |
|
|
object |
無。 |
||
| Key |
string |
注釋的鍵。 |
summary |
| Value |
string |
注釋的值。 |
{{ $labels.instance }} CPU usage above 10% {current value: {{ humanizePercentage $value }} } |
| ProductCategory |
string |
雲產品類型。 |
slb |
| GmtCreate |
integer |
規則建立時間,Unix 時間戳記。 |
1760432061000 |
| GmtUpdate |
string |
規則更新時間,Unix 時間戳記。 |
1760432061000 |
樣本
正常返回樣本
JSON格式
{
"Code": 200,
"Message": "The specified resource is not found.",
"RequestId": "386C6712-335F-5054-930A-CC92B851ECBA",
"Total": "1",
"Success": true,
"Alarms": {
"Alarm": [
{
"SilenceTime": 86400,
"MetricName": "cpu_total",
"Webhook": "https://www.aliyun.com",
"ContactGroups": "ECS_Alarm",
"SourceType": "METRIC",
"Namespace": "acs_ecs_dashboard",
"MailSubject": "\"${serviceType}-${metricName}-${levelDescription}通知(${dimensions})\"",
"NoEffectiveInterval": "00:00-05:30",
"EffectiveInterval": "05:31-23:59",
"RuleName": "Rule_01",
"AlertState": "OK",
"Period": "60",
"RuleId": "applyTemplate344cfd42-0f32-4fd6-805a-88d7908a****",
"GroupName": "ECS_Group",
"GroupId": "7301****",
"Dimensions": "[{\"instanceId\":\"i-2ze2d6j5uhg20x47****\"}]",
"EnableState": true,
"Resources": "[{\\\"instanceId\\\":\\\"i-2ze2d6j5uhg20x47****\\\"}]",
"Escalations": {
"Info": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"PreCondition": "$Average>80",
"Times": 3,
"Threshold": "90",
"Statistics": "Average"
},
"Warn": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"PreCondition": "$Average>80",
"Times": 3,
"Threshold": "90",
"Statistics": "Average"
},
"Critical": {
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"PreCondition": "$Average>80",
"Times": 3,
"Threshold": "90",
"Statistics": "Average"
}
},
"NoDataPolicy": "KEEP_LAST_STATE",
"CompositeExpression": {
"Level": "CRITICAL",
"ExpressionList": {
"ExpressionList": [
{
"MetricName": "cpu_total",
"Period": 60,
"Statistics": "$Maximum",
"ComparisonOperator": "GreaterThanOrEqualToThreshold",
"Threshold": "90"
}
]
},
"ExpressionListJoin": "||",
"ExpressionRaw": "$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50)",
"Times": 3
},
"Labels": {
"Labels": [
{
"Key": "cmsRuleKey",
"Value": "cmsRuleValue"
}
]
},
"Prometheus": {
"PromQL": "CpuUsage{instanceId=\"xxxx\"}[1m]>90",
"Level": "CRITICAL",
"Times": 3,
"Annotations": {
"Annotations": [
{
"Key": "summary",
"Value": "{{ $labels.instance }} CPU usage above 10% {current value: {{ humanizePercentage $value }} }"
}
]
}
},
"ProductCategory": "slb",
"GmtCreate": 1760432061000,
"GmtUpdate": "1760432061000"
}
]
}
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | InvalidParameter | Invalid parameter. | 參數錯誤 |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | InvalidAuthorization | The Request is not authorization. | |
| 404 | ResourceNotFound | The specified resource is not found. | 未找到指定資源。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。