全部產品
Search
文件中心

:接入CloudMonitor警示

更新時間:Jan 14, 2025

阿里雲的CloudMonitor服務用於監控阿里雲資源和互連網應用,包括閾值警示和事件警示兩種模式,支援配置多種警示通知渠道。您可以將Log Service開放警示配置為其中一個通知渠道,從而由Log Service警示系統完成警示降噪、通知等處理。

前提條件

CloudMonitor配置

  1. 登入CloudMonitor控制台
  2. 在左側導覽列中,選擇警示服務 > 警示連絡人
  3. 編輯警示連絡人資訊。
    1. 警示連絡人頁面,單擊目標警示連絡人對應的編輯
    2. 設定警示連絡人面版中,修改Webhook(http|https)或DingTalk機器人,然後單擊確認
      設定Webhook(http|https)或DingTalk機器人為您在Log Service中建立開放警示服務和應用後產生的公網網域名稱介面資訊(完整URL)。如何擷取,請參見擷取介面資訊
  4. 在CloudMonitor的各類警示規則中,設定通知對象為已建立的警示聯絡組。
    具體操作,請參見建立警示規則

    設定完成後,CloudMonitor產生的警示訊息將被發送到Log Service警示系統中,由Log Service完成警示降噪、通知等處理。

警示訊息語言

您在建立開放警示應用時,選擇協議阿里雲CloudMonitor,則Log Service將根據控制台語言自動添加標註__user_language__ ,值可以為en(英文)或cn(中文)。CloudMonitor警示標註

警示嚴重度映射關係

CloudMonitor警示訊息與Log Service警示訊息的嚴重度映射關係如下表所示。

CloudMonitorLog Service
CRITICALcritical
WARNmedium
INFOinfo

閾值警示訊息解析

CloudMonitor閾值警示訊息被發送到Log Service警示系統後,Log Service會對應產生一條警示訊息,兩者的映射關係如下:

  • CloudMonitor閾值警示訊息樣本

    關於CloudMonitor閾值警示訊息的更多內容,請參見使用閾值警示回調

    {
        "alertName": "串連數",
        "alertState": "ALERT",
        "curValue": "4.5",
        "dimensions": "{instanceId=i-bp1d7111111115htda, state=TCP_TOTAL, userId=11596111111355}",
        "expression": "$Average>=1",
        "instanceName": "launch-advisor-20210607/11.**.**.111",
        "lastTime": "27天19小時47分鐘",
        "metricName": "Host.tcpconnection",
        "metricProject": "acs_ecs",
        "namespace": "acs_ecs",
        "preTriggerLevel": "WARN",
        "productGroupName": "null",
        "rawMetricName": "net_tcpconnection",
        "regionId": "cn-hangzhou",
        "regionName": "華東1(杭州)",
        "ruleId": "i-bp11111111115111_111111-0703-4811-9113-1c1111111111",
        "signature": "F111111w1111qN1111bw=",
        "timestamp": "1625455812126",
        "triggerLevel": "WARN",
        "userId": "11596111111355"
    }
  • Log Service警示訊息樣本

    CloudMonitor閾值警示訊息被接入到Log Service後,映射為Log Service警示內容。樣本如下:

    {
        "aliuid": "aliuid1",
        "alert_instance_id": "",
        "alert_id": "i-bp11111111115111_111111-0703-4811-9113-1c1111111111",
        "alert_type": "sls_pub",
        "alert_name": "串連數",
        "region": "cn-hangzhou",
        "project": "sls-alert--",
        "project_id": 0,
        "next_eval_interval": 0,
        "alert_time": 1625455812,
        "fire_time": 1625455812,
        "fire_results": null,
        "fire_results_count": 0,
        "resolve_time": 0,
        "status": "firing",
        "results": null,
        "labels": {
            "instanceId": "i-bp1d7111111115htda",
            "namespace": "acs_ecs",
            "regionId": "cn-hangzhou",
            "state": "TCP_TOTAL",
            "userId": "11596111111355"
        },
        "annotations": {
            "__cloud_monitor_type__": "threshold",
            "__config_app__": "sls_pub_alert",
            "__pub_alert_app__": "appid1",
            "__pub_alert_protocol__": "cloud_monitor",
            "__pub_alert_region__": "e",
            "__pub_alert_service__": "serverid1",
            "curValue": "4.5",
            "desc": "Host.tcpconnection $Average>=1 持續: 27天19小時47分鐘, 詳情: {instanceId=i-bp1d7111111115htda, state=TCP_TOTAL, userId=11596111111355}",
            "expression": "$Average\u003e=1",
            "instanceName": "launch-advisor-20210607/11.**.**.111",
            "lastTime": "27天19小時47分鐘",
            "metricName": "Host.tcpconnection",
            "metricProject": "acs_ecs",
            "namespace": "acs_ecs",
            "preTriggerLevel": "WARN",
            "rawMetricName": "net_tcpconnection",
            "title": "acs_ecs Host.tcpconnection 當前值: 4.5"
        },
        "severity": 6,
        "policy": {
            "alert_policy_id": "",
            "action_policy_id": "",
            "use_default": false,
            "repeat_interval": "0s"
        },
        "template": null,
        "drill_down_query": "https://cloudmonitor.console.alibabacloud.com/index.htm#/alarmInfo/name=i-bp11111111115111_111111-0703-4811-9113-1c1111111111\u0026searchValue=\u0026searchType=name\u0026searchProduct=/history//"
    }
  • 欄位對應

    Log Service警示屬性與CloudMonitor欄位的映射關係如下表所示。

    Log ServiceCloudMonitor說明
    aliuid用於接入警示的開放警示應用所屬的阿里雲帳號ID。
    alert_idruleId警示監控規則ID。
    alert_type警示類型,固定為sls_pub。
    alert_namealertName警示監控規則名稱。
    statusalertState警示狀態。
    • 如果CloudMonitor警示訊息中的alertState值為OK,則對應Log Service中的status值為resolved。
    • 如果CloudMonitor警示訊息中的alertState值為其他值(例如alerting),則對應Log Service中的status值為firing。
    next_eval_interval警示評估時間間隔,固定為0。
    alert_timetimestampLog Service接收到CloudMonitor警示訊息的時間。
    fire_timetimestampLog Service接收到CloudMonitor警示訊息的時間。
    resolve_time警示恢復,如果alertState為OK,則顯示為目前時間,否則顯示0。
    labelsdimensions警示標籤資訊。
    • regionId欄位對應為CloudMonitor警示訊息中的regionId欄位。
    • namespace欄位對應為CloudMonitor警示訊息中的namespace欄位或metricProject欄位。
    說明 如果您在建立開放警示應用時 ,在資訊加工中添加了標籤資訊,則此標籤資訊將被添加到labels欄位中。
    annotationsCloudMonitor警示被接入到Log Service後,Log Service警示的annotations欄位中將添加如下額外欄位。
    • __cloud_monitor_type__: "threshold"
    • __config_app__: "sls_pub_alert"
    • __pub_alert_service__: {所屬的開放警示服務id}
    • __pub_alert_app__: {所屬的開放警示應用id}
    • __pub_alert_protocol__: "cloud_monitor"
    • __pub_alert_region__: {警示訊息發送的endpoint對應的region}

    CloudMonitor警示訊息中的大部分欄位都將被添加到annotations中,以下欄位除外:ruleId欄位、alertName欄位、alertState欄位、dimensions欄位、signature欄位、timestamp欄位、regionId欄位、regionName欄位、triggerLevel欄位、userId欄位。

    說明 如果您在建立開放警示應用時 ,在資訊加工中添加了標註資訊,則此標註資訊將被添加到annotations欄位中。
    severitytriggerLevelpreTriggerLevel警示嚴重度。更多資訊,請參見警示嚴重程度
    policy您在開放警示應用中配置的警示策略。更多資訊,請參見Policy結構
    project警示中心所屬的Project。更多資訊,請參見專案(Project)
    regionregionIdProject所屬地區。
    drill_down_query由CloudMonitor控制台URL和ruleId組成。單擊該連結,可跳轉到CloudMonitor的警示歷史頁面。

事件警示訊息解析

CloudMonitor事件警示訊息被發送到Log Service警示系統後,Log Service會對應產生一條警示訊息,兩者的映射關係如下:

  • CloudMonitor事件警示訊息樣本

    關於CloudMonitor事件警示訊息的更多內容,請參見使用系統事件警示回調(舊版)

    {
        "traceId": "411112-c49d-4143-a38e-c111159e-0",
        "resourceId": "acs:ecs:cn-hangzhou:115111111111355:instance/i-bp1d71111111x15htda",
        "product": "ECS",
        "ver": "1.0",
        "instanceName": "launch-advisor-20210607",
        "level": "INFO",
        "userId": "115111111111355",
        "content": {
            "resourceId": "i-bp1d7411111111g111htda",
            "publicIpAddress": "127.0.0.1",
            "instanceName": "launch-advisor-20210607",
            "state": "Running",
            "privateIpAddress": "127.0.0.1",
            "resourceType": "ALIYUN::ECS::Instance"
        },
        "regionId": "cn-hangzhou",
        "eventTime": "20210705T113013.398+0800",
        "name": "Instance:StateChange",
        "id": "26111205-51113-4D118-8119-3111113CB735",
        "timeMetrics": {
            "ingestion_in_time": 1625455813563,
            "ingestion_out_time": 1625455816000,
            "notify_in_time": 1625455819578,
            "engine_in_time": 1625455816467,
            "event_time": 1625455813398,
            "engine_out_time": 1625455818000
        },
        "status": "Normal"
    }
  • Log Service警示訊息樣本

    CloudMonitor事件警示訊息被接入到Log Service後,映射為Log Service警示內容。樣本如下:

    {
        "aliuid": "aliuid1",
        "alert_instance_id": "26111205-51113-4D118-8119-3111113CB735",
        "alert_id": "Instance:StateChange",
        "alert_type": "sls_pub",
        "alert_name": "Instance:StateChange",
        "region": "cn-hangzhou",
        "project": "sls-alert--",
        "project_id": 0,
        "next_eval_interval": 0,
        "alert_time": 1625455813,
        "fire_time": 1625743445,
        "fire_results": null,
        "fire_results_count": 0,
        "resolve_time": 0,
        "status": "firing",
        "results": null,
        "labels": {
            "resourceId": "acs:ecs:cn-hangzhou:115111111111355:instance/i-bp1d71111111x15htda"
        },
        "annotations": {
            "__cloud_monitor_type__": "event",
            "__config_app__": "sls_pub_alert",
            "__pub_alert_app__": "appid1",
            "__pub_alert_protocol__": "cloud_monitor",
            "__pub_alert_region__": "e",
            "__pub_alert_service__": "serverid1",
            "content_instanceName": "launch-advisor-20210607",
            "content_privateIpAddress": "127.0.0.1",
            "content_publicIpAddress": "127.0.0.1",
            "content_resourceId": "i-bp1d7411111111g111htda",
            "content_resourceType": "ALIYUN::ECS::Instance",
            "content_state": "Running",
            "desc": "事件Instance:StateChange觸發, 詳情: {\"instanceName\":\"launch-advisor-20210607\",\"privateIpAddress\":\"127.0.0.1\",\"publicIpAddress\":\"127.0.0.1\",\"resourceId\":\"i-bp1d7411111111g111htda\",\"resourceType\":\"ALIYUN::ECS::Instance\",\"state\":\"Running\"}",
            "instanceName": "launch-advisor-20210607",
            "level": "INFO",
            "product": "ECS",
            "status": "Normal",
            "title": "Instance:StateChange: Normal",
            "traceId": "411112-c49d-4143-a38e-c111159e-0",
            "userId": "115111111111355"
        },
        "severity": 4,
        "policy": {
            "alert_policy_id": "",
            "action_policy_id": "",
            "use_default": false,
            "repeat_interval": "0s"
        },
        "template": null,
        "drill_down_query": "https://cloudmonitor.console.alibabacloud.com/index.htm#/eventmonitoring/events/detail?product=ECS\u0026eventName=Instance:StateChange"
    }
  • 欄位對應

    Log Service警示屬性與CloudMonitor欄位的映射關係如下表所示。

    Log ServiceCloudMonitor說明
    aliuid用於接入警示的開放警示應用所屬的阿里雲帳號ID。
    alert_instance_idid警示訊息ID。
    alert_idname警示監控規則ID。
    alert_type警示類型,固定為sls_pub。
    alert_namename警示監控規則名稱。
    status警示狀態,固定為firing。
    next_eval_interval警示評估時間間隔,固定為0。
    alert_timeLog Service接收到CloudMonitor警示訊息的時間。
    fire_timeeventTime解析eventTime,並轉為時間戳記。
    resolve_time警示恢復,固定為0。
    labels警示標籤資訊。

    regionId欄位對應為CloudMonitor警示訊息中的regionId欄位。

    說明 如果您在建立開放警示應用時 ,在資訊加工中添加了標籤資訊,則此標籤資訊將被添加到labels欄位中。
    annotationsCloudMonitor警示被接入到Log Service後,Log Service警示的annotations欄位中將添加如下額外欄位。
    • __cloud_monitor_type__: "event"
    • __config_app__: "sls_pub_alert"
    • _pub_alert_service__: {所屬的開放警示服務id}
    • __pub_alert_app__: {所屬的開放警示應用id}
    • __pub_alert_protocol__: "cloud_monitor"
    • __pub_alert_region__: {警示訊息發送的endpoint對應的region}

    CloudMonitor警示訊息中的大部分欄位都將被添加到annotations中,以下欄位除外:name欄位、id欄位、eventTime欄位、timeMetrics欄位、content欄位、ver欄位、resourceId欄位。

    其中,content欄位內的索引值對將被展開,並添加首碼content_,例如"content_snapshotType": "timer"

    說明 如果您在建立開放警示應用時 ,在資訊加工中添加了標註資訊,則此標註資訊將被添加到annotations欄位中。
    severitylevel警示嚴重度。更多資訊,請參見警示嚴重程度
    policy您在開放警示應用中配置的警示策略。更多資訊,請參見Policy結構
    project警示中心所屬的Project。更多資訊,請參見專案(Project)
    regionregionIdProject所屬地區。
    drill_down_query連結形式,由CloudMonitor控制台URL、productname組成。單擊該連結,可跳轉到CloudMonitor的事件監控頁面。