This topic describes how to create a custom event source of the HTTP/HTTPS Events type in the EventBridge console.
Background information
After a custom event source of the HTTP/HTTPS Event type is created, a webhook URL is generated to receive URL requests. If an event occurs in the server that is configured with the webhook URL, a message is sent through the URL to EventBridge. Then, EventBridge determines whether to convert the message to an event and push the event to the event target.
Prerequisites
Procedure
Sample event
EventBridge converts HTTP requests that meet the specified requirements to events. In the data field, the request headers are nested under the headers parameter and the body is nested under the body parameter.
{
"datacontenttype": "application/json",
"aliyunaccountid": "175299981560****",
"data": {
"headers": {
"Host": "175299981560****.eventbridge.cn-hangzhou.aliyuncs.com",
"Accept-Encoding": "gzip, deflate, br",
"accept": "*/*",
"Content-Length": "538",
"Content-Type": "application/json"
},
"path": "/webhook/putEvents",
"body": {
"infoId": 1,
"ruleName": "Test",
"state": "alerting",
"message": "EventBridge test info.",
"ruleId": "796014154722826****"
},
"httpMethod": "GET",
"queryString": {}
},
"subject": "acs:eventbridge:cn-hangzhou:175299981560****:eventbus/EventBridgeDemoBus/eventsource/my.httpSource",
"aliyunoriginalaccountid": "175299981560****",
"source": "my.httpSource",
"type": "eventbridge:Events:HTTPEvent",
"aliyunpublishtime": "2022-03-03T03:33:14.097Z",
"specversion": "1.0",
"aliyuneventbusname": "EventBridgeDemoBus",
"id": "ac0d574c-d862-4662-a87b-784e3d77****",
"time": "2022-03-03T11:33:14.093+08:00",
"aliyunregionid": "cn-hangzhou",
"aliyunpublishaddr": "42.120.XX.XX"
}
For more information about the parameters defined in the CloudEvents specification, see Overview.
The following table describes the parameters in the data field.
Parameter | Type | Example | Description |
---|---|---|---|
headers | Map |
|
The headers of the HTTP request. |
path | String | /webhook/putEvents | The HTTP request path. |
body | String/Map |
|
The body of the HTTP request. If the value of the Content-Type parameter is application/json, the body of the HTTP request is parsed as a JSON object. Otherwise, the body is parsed as a common string. |
httpMethod | String | GET | The HTTP request method. |
queryString | Map | N/A | The value of the query parameter in the HTTP request, excluding the content of the token parameter. |