設定警示規則
介面說明
本文將提供一個樣本,為Elastic Compute Service 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程式碼範例。
調試
授權資訊
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RuleId |
string |
是 |
警示規則 ID。 您可以輸入新的警示規則 ID,也可以使用CloudMonitor已存在的警示規則 ID。關於如何查詢警示規則 ID,請參見 DescribeMetricRuleList 。 說明
輸入新的警示規則 ID,表示建立一條閾值警示規則。 |
a151cd6023eacee2f0978e03863cc1697c89508**** |
| RuleName |
string |
是 |
警示規則名稱。 您可以輸入新的警示規則名稱,也可以使用CloudMonitor已存在的警示規則名稱。關於如何查詢警示規則名稱,請參見 DescribeMetricRuleList 。 說明
輸入新的警示規則名稱,表示建立一條閾值警示規則。 |
test123 |
| Namespace |
string |
是 |
雲產品的資料命名空間。關於如何查詢雲產品的資料命名空間,請參見雲產品監控項。 說明
當您為企業CloudMonitor建立 Prometheus 警示規則時,該參數必須為 |
acs_ecs_dashboard |
| MetricName |
string |
是 |
監控項名稱。關於如何查詢監控項名稱,請參見雲產品監控項。 說明
當您為企業CloudMonitor建立 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執行個體警示 |
| 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 警示。 說明
僅當您為企業CloudMonitor建立 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 }} } |
關於公用請求參數的詳情,請參見公用參數。
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
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 | 超過數量限制。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。