全部產品
Search
文件中心

Cloud Monitor:使用系統事件警示回調(推薦)

更新時間:Jul 30, 2025

CloudMonitor除了郵件、DingTalk、飛書、企業微信和Slack的警示通知方式外,還可以使用警示回調方式,讓您更自由、更靈活的處理事件警示。本文以將訂閱的系統事件推送至Webhook為例,為您介紹如何使用系統事件的警示回調功能,實現將CloudMonitor發送的警示通知整合到已有的營運系統或訊息通知系統。

前提條件

請確保您已準備好公網URL地址。該URL地址為營運系統或訊息通知系統的URL地址。

背景資訊

CloudMonitor通過HTTP協議或HTTPS協議的POST請求推送警示通知到您指定的URL地址,請您將以下IP地址,加入防火牆的白名單。當您接收到警示通知後,可以根據通知內容做進一步處理。

操作步驟

  1. 建立推送渠道。

    本文以建立推送渠道Webhook為例進行介紹。

    1. 登入CloudMonitor控制台

    2. 在左側導覽列,選擇事件中心 > 事件訂閱

    3. 事件訂閱頁面,單擊推送渠道頁簽。

    4. 推送渠道頁簽,單擊建立推送渠道

    5. 建立推送渠道面板,輸入渠道名稱目標類型選擇Webhook,要求方法選擇POST,資料格式選擇JSON,地址輸入警示回調的URL地址,其他參數均不設定。

    6. 單擊確認

  2. 建立訂閱策略。

    以訂閱ECS執行個體的系統事件因執行個體錯誤執行個體重啟開始,並推送到Webhook為例。

    1. 單擊訂閱策略頁簽。

    2. 訂閱策略頁簽,單擊建立訂閱策略

    3. 建立訂閱策略頁面,設定訂閱策略的相關參數。

      • 基本資料:輸入訂閱策略名稱稱。

      • 警示訂閱訂閱類型選擇系統事件訂閱範圍中的產品選擇Elastic Compute Service事件名稱選擇因執行個體錯誤執行個體重啟開始,其他參數均不設定,表示訂閱本帳號內所有ECS執行個體的系統事件因執行個體錯誤執行個體重啟開始

        說明

        關於Elastic Compute Service支援的系統事件,請參見Elastic Compute Service

      • 合并降噪:使用預設值。

      • 通知通知配置不設定,自訂通知方式使用預設通知方式。

        說明

        由於通知配置未設定警示組,即無警示連絡人,將不會收到警示通知。

      • 推送與整合:選擇步驟 1建立的推送渠道。

    4. 單擊提交

  3. 調試事件訂閱。

    1. 訂閱策略頁簽,單擊調試事件訂閱

    2. 建立事件調試面板,產品選擇Elastic Compute Service名稱選擇因執行個體錯誤執行個體重啟開始

      系統自動產生JSON格式的調試內容。

    3. 單擊確定

      系統提示操作成功,CloudMonitor自動給您設定的Webhook地址發送一條測試警示通知。

執行結果

當系統事件觸發警示時,CloudMonitor會將警示資訊發送到您指定的URL地址。Webhook的要求方法包括POST和GET,其請求內容如下:

  • POST JSON

    參數名稱:body

    內容如下:

    {
      "userInfo": {
        "aliyunId": "test",
        "userIdSec": "te***st",
        "aliyunIdSec": "test***test",
        "nickName": "test",
        "nickNameSec": "te***st",
        "userName": "test",
        "userId": "test",
        "userNameSec": "te***st"
      },
      "subscription": {
        "subscriptionUuid": "testid",
        "conditions": [
          {
            "field": "source",
            "op": "EQ",
            "value": "SYS_EVENT"
          },
          {
            "field": "product",
            "op": "IN",
            "value": "ECS,Redis,RDS,Config,tag"
          }
        ],
        "relation": "AND"
      },
      "batchId": "testbatchid",
      "alert": {
        "alertStatus": "TRIGGERED",
        "groupId": "",
        "source": "SYS_EVENT",
        "eventContentMap": {
          "extensions": {
            "agentVersion": "test-version",
            "region": "cn-hangzhou",
            "azone": "cn-hangzhou-i",
            "uptime": 23000
          },
          "vmName": "i-testhost",
          "impact": "Alert",
          "opsCode": "InstanceStatusChange",
          "bizEventId": "test-event-id"
        },
        "dedupId": "test-id",
        "eventName": "CloudAssistant:FirstHeartbeat",
        "arn": "acs:ecs:cn-hangzhou:testuser:instance/i-testhost",
        "timestamp": 1704780333000,
        "traceId": "testid",
        "severity": "INFO",
        "product": "ECS",
        "eventRawContent": "{}",
        "eventType": "Notification",
        "userId": "test",
        "meta": {
          "sysEventMeta": {
            "regionNameEn": "cn-hangzhou",
            "resourceId": "acs:ecs:cn-hangzhou:test:instance/i-testhost",
            "product": "ECS",
            "eventNameEn": "CloudAssistant:FirstHeartbeat",
            "instanceName": "i-testhost",
            "level": "INFO",
            "resource": "",
            "regionNameZh": "華東1(杭州)",
            "groupId": "",
            "serviceTypeEn": "ECS",
            "eventType": "Notification",
            "serviceTypeZh": "Elastic Compute Service",
            "regionId": "cn-hangzhou",
            "eventTime": "20240109T140533.642+0800",
            "name": "CloudAssistant:FirstHeartbeat",
            "id": "testid",
            "status": "Normal",
            "eventNameZh": "雲助手首次心跳事件"
          }
        }
      },
      "severity": "INFO",
      "strategyName": "eventwebhook",
      "userId": "test",
      "time": 1704780333000
    }
  • GET JSON

    參數名稱:data

    內容如下:

    {
      "userInfo": {
        "aliyunId": "test",
        "userIdSec": "te***st",
        "aliyunIdSec": "test***test",
        "nickName": "test",
        "nickNameSec": "te***st",
        "userName": "test",
        "userId": "test",
        "userNameSec": "te***st"
      },
      "subscription": {
        "subscriptionUuid": "testid",
        "conditions": [
          {
            "field": "source",
            "op": "EQ",
            "value": "SYS_EVENT"
          },
          {
            "field": "product",
            "op": "IN",
            "value": "ECS,Redis,RDS,Config,tag"
          }
        ],
        "relation": "AND"
      },
      "batchId": "testbatchid",
      "alert": {
        "alertStatus": "TRIGGERED",
        "groupId": "",
        "source": "SYS_EVENT",
        "eventContentMap": {
          "extensions": {
            "agentVersion": "test-version",
            "region": "cn-hangzhou",
            "azone": "cn-hangzhou-i",
            "uptime": 23000
          },
          "vmName": "i-testhost",
          "impact": "Alert",
          "opsCode": "InstanceStatusChange",
          "bizEventId": "test-event-id"
        },
        "dedupId": "test-id",
        "eventName": "CloudAssistant:FirstHeartbeat",
        "arn": "acs:ecs:cn-hangzhou:testuser:instance/i-testhost",
        "timestamp": 1704780333000,
        "traceId": "testid",
        "severity": "INFO",
        "product": "ECS",
        "eventRawContent": "{}",
        "eventType": "Notification",
        "userId": "test",
        "meta": {
          "sysEventMeta": {
            "regionNameEn": "cn-hangzhou",
            "resourceId": "acs:ecs:cn-hangzhou:test:instance/i-testhost",
            "product": "ECS",
            "eventNameEn": "CloudAssistant:FirstHeartbeat",
            "instanceName": "i-testhost",
            "level": "INFO",
            "resource": "",
            "regionNameZh": "華東1(杭州)",
            "groupId": "",
            "serviceTypeEn": "ECS",
            "eventType": "Notification",
            "serviceTypeZh": "Elastic Compute Service",
            "regionId": "cn-hangzhou",
            "eventTime": "20240109T140533.642+0800",
            "name": "CloudAssistant:FirstHeartbeat",
            "id": "testid",
            "status": "Normal",
            "eventNameZh": "雲助手首次心跳事件"
          }
        }
      },
      "severity": "INFO",
      "strategyName": "eventwebhook",
      "userId": "test",
      "time": 1704780333000
    }
  • POST FORM和GET FORM

    參數名稱

    內容

    userInfo

    {
        "aliyunId": "test",
        "userIdSec": "te***st",
        "aliyunIdSec": "test***test",
        "nickName": "test",
        "nickNameSec": "te***st",
        "userName": "test",
        "userId": "test",
        "userNameSec": "te***st"
     }

    subscription

    {
        "subscriptionUuid": "testid",
        "conditions": [
          {
            "field": "source",
            "op": "EQ",
            "value": "SYS_EVENT"
          },
          {
            "field": "product",
            "op": "IN",
            "value": "ECS,Redis,RDS,Config,tag"
          }
        ],
        "relation": "AND"
      }

    alert

     {
        "alertStatus": "TRIGGERED",
        "groupId": "",
        "source": "SYS_EVENT",
        "eventContentMap": {
          "extensions": {
            "agentVersion": "test-version",
            "region": "cn-hangzhou",
            "azone": "cn-hangzhou-i",
            "uptime": 23000
          },
          "vmName": "i-testhost",
          "impact": "Alert",
          "opsCode": "InstanceStatusChange",
          "bizEventId": "test-event-id"
        },
        "dedupId": "test-id",
        "eventName": "CloudAssistant:FirstHeartbeat",
        "arn": "acs:ecs:cn-hangzhou:testuser:instance/i-testhost",
        "timestamp": 1704780333000,
        "traceId": "testid",
        "severity": "INFO",
        "product": "ECS",
        "eventRawContent": "{}",
        "eventType": "Notification",
        "userId": "test",
        "meta": {
          "sysEventMeta": {
            "regionNameEn": "cn-hangzhou",
            "resourceId": "acs:ecs:cn-hangzhou:test:instance/i-testhost",
            "product": "ECS",
            "eventNameEn": "CloudAssistant:FirstHeartbeat",
            "instanceName": "i-testhost",
            "level": "INFO",
            "resource": "",
            "regionNameZh": "華東1(杭州)",
            "groupId": "",
            "serviceTypeEn": "ECS",
            "eventType": "Notification",
            "serviceTypeZh": "Elastic Compute Service",
            "regionId": "cn-hangzhou",
            "eventTime": "20240109T140533.642+0800",
            "name": "CloudAssistant:FirstHeartbeat",
            "id": "testid",
            "status": "Normal",
            "eventNameZh": "雲助手首次心跳事件"
          }
        }
      }

    severity

    INFO

    strategyName

    eventwebhook

    userId

    test

    time

    1704780333000

返回欄位說明

欄位

描述

外層欄位

batchId

當前發送通知的批次id,表示每一次通知

severity

嚴重層級

strategyName

訂閱名稱

userId

使用者ID

time

事件時間

userInfo 對象欄位

aliyunId

阿里雲ID

userIdSec

阿里雲ID

aliyunIdSec

脫敏的阿里雲ID

nickName

阿里雲別名

nickNameSec

脫敏的阿里雲別名

userName

阿里雲登入Id

userId

阿里雲ID

userNameSec

脫敏的阿里雲登入Id

subscription 對象欄位

subscriptionUuid

訂閱策略的唯一Id

conditions

事件訂閱策略條件:

  • field:訂閱欄位。

  • op:條件對比符號。

  • value:對比值。

relation

訂閱條件管理,

取值 AND /OR,預設為AND

alert 對象欄位

alertStatus

警示狀態:

取值TRIGGERED, RESOLVED;

groupId

應用分組ID

source

最近警示事件類型

dedupId

事件的去重ID

eventName

事件名稱

arn

產生事件資源資訊

timestamp

事件時間戳記

traceId

事件原始Id

severity

嚴重層級

product

產品名稱

eventRawContent

事件未經處理資料內容JSON字串,每個雲端服務不同

eventType

事件類型

userId

使用者ID

meta.sysEventMeta(子物件欄位)

regionNameEn

region英文資訊

resourceId

事件相關資源資訊

product

產品code

eventNameEn

事件英文名稱

instanceName

執行個體名稱

level

事件等級

resource

系統事件ARN

regionNameZh

region中文資訊

groupId

應用分組ID

serviceTypeEn

服務類型(英文)

eventType

事件類型

serviceTypeZh

服務類型(中文)

regionId

region ID

eventTime

事件產生時間

name

事件名稱

id

事件ID

status

事件狀態

eventNameZh

事件中文名稱

eventContentMap(子物件欄位)

eventContentMap該欄位是有各個業務方上報的資訊,需要查具體的雲產品的事件文檔

相關文檔