阿里雲的CloudMonitor服務用於監控阿里雲資源和互連網應用,包括閾值警示和事件警示兩種模式,支援配置多種警示通知渠道。您可以將Log Service開放警示配置為其中一個通知渠道,從而由Log Service警示系統完成警示降噪、通知等處理。
前提條件
- 已建立協議為阿里雲CloudMonitor的開放警示應用。具體操作,請參見配置開放警示對外介面。
- 已建立警示連絡人和聯絡組,並將連絡人添加到聯絡組中。具體操作,請參見建立警示連絡人或警示連絡人群組。
CloudMonitor配置
- 登入CloudMonitor控制台。
- 在左側導覽列中,選擇。
- 編輯警示連絡人資訊。
- 在警示連絡人頁面,單擊目標警示連絡人對應的編輯。
- 在設定警示連絡人面版中,修改Webhook(http|https)或DingTalk機器人,然後單擊確認。設定Webhook(http|https)或DingTalk機器人為您在Log Service中建立開放警示服務和應用後產生的公網網域名稱介面資訊(完整URL)。如何擷取,請參見擷取介面資訊。
- 在CloudMonitor的各類警示規則中,設定通知對象為已建立的警示聯絡組。具體操作,請參見建立警示規則。
設定完成後,CloudMonitor產生的警示訊息將被發送到Log Service警示系統中,由Log Service完成警示降噪、通知等處理。
警示訊息語言

警示嚴重度映射關係
CloudMonitor警示訊息與Log Service警示訊息的嚴重度映射關係如下表所示。
| CloudMonitor | Log Service |
| CRITICAL | critical |
| WARN | medium |
| INFO | info |
閾值警示訊息解析
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 Service CloudMonitor 說明 aliuid 無 用於接入警示的開放警示應用所屬的阿里雲帳號ID。 alert_id ruleId 警示監控規則ID。 alert_type 無 警示類型,固定為sls_pub。 alert_name alertName 警示監控規則名稱。 status alertState 警示狀態。 - 如果CloudMonitor警示訊息中的alertState值為OK,則對應Log Service中的status值為resolved。
- 如果CloudMonitor警示訊息中的alertState值為其他值(例如alerting),則對應Log Service中的status值為firing。
next_eval_interval 無 警示評估時間間隔,固定為0。 alert_time timestamp Log Service接收到CloudMonitor警示訊息的時間。 fire_time timestamp Log Service接收到CloudMonitor警示訊息的時間。 resolve_time 無 警示恢復,如果alertState為OK,則顯示為目前時間,否則顯示0。 labels dimensions 警示標籤資訊。 - regionId欄位對應為CloudMonitor警示訊息中的regionId欄位。
- namespace欄位對應為CloudMonitor警示訊息中的namespace欄位或metricProject欄位。
說明 如果您在建立開放警示應用時 ,在資訊加工中添加了標籤資訊,則此標籤資訊將被添加到labels欄位中。annotations 無 CloudMonitor警示被接入到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欄位中。severity triggerLevel、preTriggerLevel 警示嚴重度。更多資訊,請參見警示嚴重程度。 policy 無 您在開放警示應用中配置的警示策略。更多資訊,請參見Policy結構。 project 無 警示中心所屬的Project。更多資訊,請參見專案(Project)。 region regionId Project所屬地區。 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 Service CloudMonitor 說明 aliuid 無 用於接入警示的開放警示應用所屬的阿里雲帳號ID。 alert_instance_id id 警示訊息ID。 alert_id name 警示監控規則ID。 alert_type 無 警示類型,固定為sls_pub。 alert_name name 警示監控規則名稱。 status 無 警示狀態,固定為firing。 next_eval_interval 無 警示評估時間間隔,固定為0。 alert_time 無 Log Service接收到CloudMonitor警示訊息的時間。 fire_time eventTime 解析eventTime,並轉為時間戳記。 resolve_time 無 警示恢復,固定為0。 labels 無 警示標籤資訊。 regionId欄位對應為CloudMonitor警示訊息中的regionId欄位。
說明 如果您在建立開放警示應用時 ,在資訊加工中添加了標籤資訊,則此標籤資訊將被添加到labels欄位中。annotations 無 CloudMonitor警示被接入到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欄位中。severity level 警示嚴重度。更多資訊,請參見警示嚴重程度。 policy 無 您在開放警示應用中配置的警示策略。更多資訊,請參見Policy結構。 project 無 警示中心所屬的Project。更多資訊,請參見專案(Project)。 region regionId Project所屬地區。 drill_down_query 無 連結形式,由CloudMonitor控制台URL、product和name組成。單擊該連結,可跳轉到CloudMonitor的事件監控頁面。