設定報警規則。
介面說明
本文將提供一個示例,為雲端伺服器 ECS acs_ecs_dashboard的執行個體i-uf6j91r34rnwawoo****中的監控項cpu_total設定閾值報警規則。該報警規則的報警聯絡群組為ECS_Group、報警規則名稱為test123、報警規則 ID 為a151cd6023eacee2f0978e03863cc1697c89508****、Critical 級別的統計方法為Average、Critical 級別的比較符為GreaterThanOrEqualToThreshold、Critical 級別的閾值為90和 Critical 級別的報警重試次數為3。
2024-08-15 增加 Statistics 校驗,統計值只能填對應指標的 Statistics。關於如何取得該參數的取值,請參見雲端產品監控項。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
cms:PutResourceMetricRule |
create |
*All Resource
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RuleId |
string |
是 |
報警規則 ID。 您可以輸入新的報警規則 ID,也可以使用雲端監控已存在的報警規則 ID。關於如何查詢報警規則 ID,請參見 DescribeMetricRuleList 。 說明
輸入新的報警規則 ID,表示建立一條閾值報警規則。 |
a151cd6023eacee2f0978e03863cc1697c89508**** |
| RuleName |
string |
是 |
報警規則名稱。 您可以輸入新的報警規則名稱,也可以使用雲端監控已存在的報警規則名稱。關於如何查詢報警規則名稱,請參見 DescribeMetricRuleList 。 說明
輸入新的報警規則名稱,表示建立一條閾值報警規則。 |
test123 |
| Namespace |
string |
是 |
雲端產品的資料命名空間。關於如何查詢雲端產品的資料命名空間,請參見雲端產品監控項。 說明
當您為企業雲端監控建立 Prometheus 報警規則時,該參數必須為 |
acs_ecs_dashboard |
| MetricName |
string |
是 |
監控項名稱。關於如何查詢監控項名稱,請參見雲端產品監控項。 說明
當您為企業雲端監控建立 Prometheus 報警規則時,該參數為指標倉庫名稱。關於如何取得指標倉庫名稱,請參見 DescribeHybridMonitorNamespaceList 。 |
cpu_total |
| Resources |
string |
否 |
資源資訊,例如: 關於資源資訊支援的維度 Dimensions,請參見雲端產品監控項。 |
[{"instanceId":"i-uf6j91r34rnwawoo****"}] |
| ContactGroups |
string |
是 |
報警聯絡群組。報警通知會傳送給該報警聯絡群組中的報警聯絡人。 說明
報警聯絡群組是一組報警聯絡人,可以包含一個或多個報警聯絡人。關於如何建立報警聯絡人和報警聯絡群組,請參見 PutContact 和 PutContactGroup 。 |
ECS_Group |
| Webhook |
string |
否 |
報警發生回呼時指定的 URL 位址,向 URL 傳送 POST 請求。 |
https://alert.aliyun.com.com:8080/callback |
| EffectiveInterval |
string |
否 |
報警規則的生效時間範圍。 |
00:00-23:59 |
| NoEffectiveInterval |
string |
否 |
報警規則的失效時間範圍。 |
00:00-06:00 |
| SilenceTime |
integer |
否 |
通道沉默週期。單位:秒,預設值:86400。 說明
通道沉默週期是指報警發生後未恢復正常,間隔多久重新傳送一次報警通知。 |
86400 |
| Period |
string |
否 |
監控項的統計週期。單位:秒。預設為監控項的原始上報週期。 說明
關於如何查詢監控項的統計週期,請參見雲端產品監控項。 |
60 |
| Interval |
string |
否 |
報警規則的觸發週期。單位:秒。 說明
關於如何查詢監控項的統計週期,請參見雲端產品監控項。 |
60 |
| EmailSubject |
string |
否 |
報警郵件主題。 |
ECS instance alert |
| Escalations.Critical.Statistics |
string |
否 |
Critical 級別報警統計方法。 該參數的取值由指定雲端產品的 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
Average |
| Escalations.Critical.ComparisonOperator |
string |
否 |
Critical 級別閾值比較符。取值:
說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
GreaterThanOrEqualToThreshold |
| Escalations.Critical.Threshold |
string |
否 |
Critical 級別報警閾值。 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
90 |
| Escalations.Critical.Times |
integer |
否 |
Critical 級別報警重試次數。 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
3 |
| Escalations.Warn.Statistics |
string |
否 |
Warn 級別報警統計方法。 該參數的取值由指定雲端產品的 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
Average |
| Escalations.Warn.ComparisonOperator |
string |
否 |
Warn 級別閾值比較符。取值:
說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
GreaterThanOrEqualToThreshold |
| Escalations.Warn.Threshold |
string |
否 |
Warn 級別報警閾值。 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
90 |
| Escalations.Warn.Times |
integer |
否 |
Warn 級別報警重試次數。 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
3 |
| Escalations.Info.Statistics |
string |
否 |
Info 級別報警統計方法。 該參數的取值由指定雲端產品的 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
Average |
| Escalations.Info.ComparisonOperator |
string |
否 |
Info 級別閾值比較符。取值:
說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
GreaterThanOrEqualToThreshold |
| Escalations.Info.Threshold |
string |
否 |
Info 級別報警閾值。 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
90 |
| Escalations.Info.Times |
integer |
否 |
Info 級別報警重試次數。 說明
報警級別 Critical(嚴重)、Warn(警告)或 Info(資訊)至少設定一個,且該報警級別中的參數 Statistics、ComparisonOperator、Threshold 和 Times 必須同時設定。 |
3 |
| NoDataPolicy |
string |
否 |
無監控資料時報警的處理方式。取值:
|
KEEP_LAST_STATE |
| CompositeExpression |
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) |
| Level |
string |
否 |
報警級別。取值:
|
CRITICAL |
| Times |
integer |
否 |
發出報警通知需要達到報警條件的次數。 |
3 |
| Labels |
array<object> |
否 |
當監控項達到報警條件並進行報警時,標籤同時寫入監控項,在報警通知中進行展示。 說明
該功能與 Prometheus 報警中的 Label 相同。 |
|
|
object |
否 |
無。 |
||
| Key |
string |
否 |
標籤鍵。 |
tagKey1 |
| Value |
string |
否 |
標籤值。 說明
標籤值支援範本參數,將範本參數替換為實際標籤值。 |
ECS |
| Prometheus |
object |
否 |
Prometheus 報警。 說明
僅當您為企業雲端監控建立 Prometheus 報警規則,需要設定該參數。 |
|
| PromQL |
string |
否 |
PromQL 查詢語句。 說明
透過 PromQL 查詢語句取得的資料即為報警資料,請您在該語句中攜帶報警閾值。 |
cpuUsage{instanceId="xxxx"}[1m]>90 |
| Level |
string |
否 |
報警級別。取值:
|
CRITICAL |
| Times |
integer |
否 |
發出報警通知需要達到報警條件的次數。 |
3 |
| Annotations |
array<object> |
否 |
Prometheus 報警時,將註釋的鍵和值進行渲染,易於您對監控項或報警規則的理解。 說明
該功能等同於 Prometheus 的 Annotation。 |
|
|
object |
否 |
無。 |
||
| Key |
string |
否 |
註釋的鍵。 |
summary |
| Value |
string |
否 |
註釋的值。 |
{{ $labels.instance }} CPU usage above 10% {current value: {{ humanizePercentage $value }} } |
| SendOK |
boolean |
否 |
是否傳送恢復通知。 |
true |
關於公共請求參數的詳情,請參見公共參數。
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
無。 |
||
| Code |
string |
狀態碼。 說明
200 表示成功。 |
200 |
| Message |
string |
錯誤資訊。 |
The request processing has failed due to some unknown error. |
| RequestId |
string |
請求 ID。 |
65D50468-ECEF-48F1-A6E1-D952E89D9436 |
| Success |
boolean |
操作是否成功。取值:
|
true |
樣本
正常返回樣本
JSON格式
{
"Code": "200",
"Message": "The request processing has failed due to some unknown error.",
"RequestId": "65D50468-ECEF-48F1-A6E1-D952E89D9436",
"Success": true
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | %s | %s | |
| 499 | %s | %s | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 204 | %s | %s | |
| 403 | %s | %s | |
| 206 | %s | %s | |
| 404 | %s | %s | |
| 503 | %s | %s | |
| 406 | %s | %s | |
| 429 | ResourceOverLimit | The resource has exceeded the limit. %s |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。