Use alert callbacks for system events (Recommended)
In addition to notifications via email, DingTalk, Lark, WeCom, and Slack, Cloud Monitor offers an alert callback feature for more flexible event handling. This topic explains how to use this feature to forward system event notifications to a webhook. This allows you to integrate Cloud Monitor alerts with your existing O&M or notification systems.
Prerequisites
Make sure you have a public URL for your O&M or messaging system.
Background information
Cloud Monitor pushes alert notifications to your specified URL using POST requests over HTTP or HTTPS. Add the following IP addresses to your firewall's whitelist. After you receive an alert notification, you can further process it based on its content.
Procedure
-
Create a push channel.
This example uses a webhook as the push channel.
-
Log on to the Cloud Monitor console.
-
In the left-side navigation pane, choose Event Center > Event Subscription.
-
On the Event Subscription page, click the Push Channel tab.
-
On the Push Channel tab, click Create Push Channel.
-
In the Create Push Channel panel, enter a Channel Name, set Target Type to Webhook, Request Method to POST, and Data Format to JSON. In the Address field, enter the alert callback URL and use the default settings for the other parameters.
-
Click OK.
-
-
Create a subscription policy.
This example subscribes to the Instance:InstanceFailure.Reboot:Executing system event for an ECS instance and pushes notifications to the webhook.
-
Click the Subscription Policy tab.
-
On the Subscription Policy tab, click Create Subscription Policy.
-
On the Create Subscription Policy page, configure the parameters.
-
Basic Information: Enter a name for the subscription policy.
-
Alert Subscription: Set Subscription Type to System Event. In the Subscription Scope section, set Product to ECS and Event Name to Instance:InstanceFailure.Reboot:Executing. Use the default settings for the other parameters. This subscribes to the Instance:InstanceFailure.Reboot:Executing system event for all ECS instances under your account.
NoteFor more information about the system events that ECS supports, see ECS.
-
Merge and Denoise: Use the default settings.
-
Notification: Do not configure Notification Configuration. Use the default notification method for Custom Notification Method.
NoteBecause no alert group is configured for the Notification Settings, there are no alert contacts, and you will not receive alert notifications.
-
Push and Integration: Select the push channel created in Step 1.
-
-
Click Submit.
-
-
Debug the event subscription.
-
On the Subscription Policy tab, click Debug Event Subscription.
-
In the Create Event Debugging panel, set Product to ECS and Name to Instance:InstanceFailure.Reboot:Executing.
The system automatically generates the debug content in JSON format.
-
Click OK.
The system displays an Operation successful message. Cloud Monitor then automatically sends a test alert notification to the webhook URL that you specified.
-
Results
When a system event triggers an alert, Cloud Monitor sends the alert information to the URL that you specified. Webhooks support POST and GET request methods. The following examples show the request content for each method:
-
POST JSON
Parameter name:
body.Sample content:
{ "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": "云服务器ECS", "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
Parameter name:
data.Sample content:
{ "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": "云服务器ECS", "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 and GET FORM
Parameter
Value
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": "云服务器ECS", "regionId": "cn-hangzhou", "eventTime": "20240109T140533.642+0800", "name": "CloudAssistant:FirstHeartbeat", "id": "testid", "status": "Normal", "eventNameZh": "云助手首次心跳事件" } } }severity
INFO
strategyName
eventwebhook
userId
test
time
1704780333000
Field descriptions
|
Field |
Description |
|
|
Outer fields |
batchId |
The batch ID of the notification. Each ID represents a unique notification delivery. |
|
severity |
The severity level. |
|
|
strategyName |
The name of the subscription policy. |
|
|
userId |
The ID of the Alibaba Cloud account. |
|
|
time |
The event time. |
|
|
Fields in the |
aliyunId |
The ID of the Alibaba Cloud account. |
|
userIdSec |
The ID of the RAM user. |
|
|
aliyunIdSec |
The masked ID of the Alibaba Cloud account. |
|
|
nickName |
The alias of the Alibaba Cloud account. |
|
|
nickNameSec |
The masked alias of the Alibaba Cloud account. |
|
|
userName |
The logon ID of the Alibaba Cloud account. |
|
|
userId |
The ID of the Alibaba Cloud account. |
|
|
userNameSec |
The masked logon ID of the Alibaba Cloud account. |
|
|
Fields in the |
subscriptionUuid |
The unique ID of the subscription policy. |
|
conditions |
The conditions of the subscription policy:
|
|
|
relation |
The logical relationship between conditions. Valid values: |
|
|
Fields in the |
alertStatus |
The alert status. Valid values: |
|
groupId |
The ID of the application group. |
|
|
source |
The type of the most recent alert event. |
|
|
dedupId |
The deduplication ID of the event. |
|
|
eventName |
The event name. |
|
|
arn |
The Alibaba Cloud Resource Name (ARN) of the resource that generated the event. |
|
|
timestamp |
The event timestamp. |
|
|
traceId |
The original ID of the event. |
|
|
severity |
The severity level. |
|
|
product |
The product name. |
|
|
eventRawContent |
The raw event data as a JSON string. The content varies depending on the cloud service. |
|
|
eventType |
The event type. |
|
|
userId |
The ID of the Alibaba Cloud account. |
|
|
Fields in the |
regionNameEn |
The name of the region in English. |
|
resourceId |
Information about the resource that is associated with the event. |
|
|
product |
The product code. |
|
|
eventNameEn |
The name of the event in English. |
|
|
instanceName |
The instance name. |
|
|
level |
The event level. |
|
|
resource |
The ARN of the system event. |
|
|
regionNameZh |
The name of the region in Chinese. |
|
|
groupId |
The ID of the application group. |
|
|
serviceTypeEn |
The service type in English. |
|
|
eventType |
The event type. |
|
|
serviceTypeZh |
The service type in Chinese. |
|
|
regionId |
The region ID. |
|
|
eventTime |
The time when the event was generated. |
|
|
name |
The event name. |
|
|
id |
The event ID. |
|
|
status |
The event status. |
|
|
eventNameZh |
The name of the event in Chinese. |
|
|
Fields in the |
The |
|