Creates a custom event source.
URL
/openapi/createEventSource
Usage notes
You can specify only one of the SourceMNSParameters, SourceRocketMQParameters, SourceRabbitMQParameters, SourceHttpEventParameters, SourceSLSParameters parameters for an event source.
Request parameters
| Parameter | Type | Required | Example | Description |
| EventSourceName | String | Yes | myrabbitmq.source | The name of the event source. For more information, see Limits. |
| Description | String | Yes | Event source of the Message Queue for RabbitMQ type | The description of the event source. |
| SourceMNSParameters | Object | No | Specifies that the event provider is Simple Message Queue (formerly MNS). For more information, see Request parameter SourceMNSParameters. | |
| SourceRocketMQParameters | Object | No | Specifies that the event provider is ApsaraMQ for RocketMQ. For more information, see Request parameter SourceRocketMQParameters. | |
| SourceRabbitMQParameters | Object | No | Specifies that the event provider is ApsaraMQ for RabbitMQ. For more information, see Request parameter SourceRabbitMQParameters. | |
| SourceHttpEventParameters | Object | No | Specifies that the event provider is HTTP or HTTPS. For more information, see Request parameter SourceHttpEventParameters. | |
| SourceSLSParameters | Object | No | Specifies that the event provider is Log Service. For more information, see Request parameter SourceSLSParameters. | |
| EventBusName | String | Yes | my-event-bus | The name of the event bus with which the event source is to be associated. For more information, see Limits. |
Request parameter SourceMNSParameters
If you specify the SourceMNSParameters parameter, you can configure the parameters described in the following table.
| Parameter | Type | Required | Example | Description |
| RegionId | String | Yes | cn-zhangjiakou | The ID of the region where the Simple Message Queue (formerly MNS) queue resides. |
| QueueName | String | Yes | MyQueue | The name of the queue in the Simple Message Queue (formerly MNS) instance. |
| IsBase64Decode | String | Yes | true | Specifies whether to enable Base64 decoding. Default value: true. |
Request parameter SourceRocketMQParameters
If you specify the SourceRocketMQParameters parameter, you can configure the parameters described in the following table.
| Parameter | Type | Required | Example | Description |
| RegionId | String | Yes | cn-zhangjiakou | The ID of the region where the ApsaraMQ for RocketMQ instance resides. |
| InstanceId | String | Yes | MQ_INST_164901546557****_BAAN**** | The ID of the ApsaraMQ for RocketMQ instance. For more information, see Limits. |
| Topic | String | Yes | mytopic | The name of the topic in the ApsaraMQ for RocketMQ instance. For more information, see Limits. |
| Tag | String | No | test | The tags that are used to filter messages. |
| Offset | String | No | CONSUME_FROM_TIMESTAMP | The consumer offset of messages. Valid values:
Default value: CONSUME_FROM_LAST_OFFSET. |
| Timestamp | Long | No | 1636597951964 | The timestamp of the offset from which consumption starts. Unit: milliseconds. This parameter is valid only if you set the Offset parameter to CONSUME_FROM_TIMESTAMP. |
| GroupID | String | Yes | GID_group1 | The ID of the group in the ApsaraMQ for RocketMQ instance. |
Request parameter SourceRabbitMQParameters
If you specify the SourceRabbitMQParameters parameter, you can configure the parameters described in the following table.
| Parameter | Type | Required | Example | Description |
| RegionId | String | Yes | cn-zhangjiakou | The ID of the region where the ApsaraMQ for RabbitMQ instance resides. |
| InstanceId | String | Yes | amqp-cn-nif22u74**** | The ID of the ApsaraMQ for RabbitMQ instance. For more information, see Limits. |
| VirtualHostName | String | Yes | eb-connect | The name of the vhost in the ApsaraMQ for RabbitMQ instance. For more information, see Limits. |
| QueueName | String | Yes | demo | The name of the queue in the ApsaraMQ for RabbitMQ instance. For more information, see Limits. |
Request parameter SourceHttpEventParameters
If you specify the SourceHttpEventParameters parameter, you can set the parameters described in the following table.
| Parameter | Type | Required | Example | Description |
| Type | String | Yes | HTTPS | The protocol type supported by the generated webhook URL. Valid values:
|
| Method | List | Yes | GET | The HTTP request method supported by the generated webhook URL. You can select multiple values. Valid values:
|
| SecurityConfig | String | Yes | ip | The type of security settings. Valid values:
|
| Ip | List | No | 10.0.0.0/8 | The CIDR blocks used for security settings. This parameter is required only if you set the SecurityConfig parameter to ip. You can enter CIDR blocks or IP addresses. Separate multiple CIDR blocks or IP addresses with commas (,). |
| Referer | List | No | aliyundoc.com | The security domain names. This parameter is required only when you set the SecurityConfig parameter to referer. You can enter domain names. |
Request parameter SourceSLSParameters
If you specify the SourceSLSParameters parameter, you can configure the parameters described in the following table.
| Parameter | Type | Required | Example | Description |
| Project | String | Yes | test-project | The Log Service project. |
| LogStore | String | Yes | test-logstore | The Log Service Logstore. |
| ConsumePosition | String | No | end | The starting consumer offset. The value begin indicates the earliest offset, and the value end indicates the latest offset. You can also specify a time in seconds to start consumption. |
| RoleName | String | Yes | testRole | The name of the role. If you want to authorize EventBridge to use this role to read the logs in Log Service, you must select Alibaba Cloud Service for the Selected Trusted Entity parameter, and select EventBridge for the Select Trusted Service parameter when you create the role in the RAM console. For information about the permission policy of this role, see Create a custom event source of the Simple Log Service type. |
Response parameters
| Parameter | Type | Example | Description |
| EventSourceARN | String | acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/mymns.source | The Alibaba Cloud Resource Name (ARN) of the event source. |
Example 1: Custom event source of the MNS type
Sample request
POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26
{
"EventSourceName":"mymns.source",
"Description":"Event source of the MNS type",
"SourceMNSParameters":{
"RegionId":"cn-zhangjiakou",
"QueueName":"MyQueue",
"IsBase64Decode":true
},
"EventBusName":"my-event-bus"
}Sample response
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"code":"200",
"data":{
"RequestId":"244BED53-719A-15D7-B7F9-1C404273****",
"Data":{
"EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/mymns.source"
},
"Code":"Success",
"Success":true
},
"httpStatusCode":"200",
"requestId":"244BED53-719A-15D7-B7F9-1C404273****",
"successResponse":true
}Example 2: Custom event source of the Message Queue for Apache RocketMQ type
Sample request
POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26
{
"EventSourceName":"myRocketMQ.source",
"Description":"Event source of the Message Queue for Apache RocketMQ type",
"SourceRocketMQParameters":{
"InstanceId":"MQ_INST_164901546557****_BAAN****",
"GroupID":"GID_group1",
"Topic":"mytopic",
"Offset":"CONSUME_FROM_TIMESTAMP",
"Tag":"test",
"RegionId":"cn-hangzhou",
"Timestamp":1636597951964
},
"EventBusName":"my-event-bus"
}Sample response
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"code":"200",
"data":{
"RequestId":"244BED53-719A-15D7-B7F9-1C404273****",
"Data":{
"EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/myRocketMQ.source"
},
"Code":"Success",
"Success":true
},
"httpStatusCode":"200",
"requestId":"244BED53-719A-15D7-B7F9-1C404273****",
"successResponse":true
}Example 3: Custom event source of the Message Queue for RabbitMQ type
Sample request
POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26
{
"EventSourceName":"myRabbitMQ.source",
"Description":"Event source of the Message Queue for RabbitMQ type",
"SourceRabbitMQParameters":{
"RegionId":"cn-hangzhou",
"InstanceId":"amqp-cn-nif22u74****",
"VirtualHostName":"eb-connect",
"QueueName":"demo"
},
"EventBusName":"my-event-bus"
}Sample response
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"code":"200",
"data":{
"RequestId":"244BED53-719A-15D7-B7F9-1C404273****",
"Data":{
"EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/myRabbitMQ.source"
},
"Code":"Success",
"Success":true
},
"httpStatusCode":"200",
"requestId":"244BED53-719A-15D7-B7F9-1C404273****",
"successResponse":true
}Example 4: Custom event source of the HTTP/HTTPS type
Sample request
POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT****azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26
{
"EventSourceName":"myhttp.source",
"Description":"Event source of the HTTP or HTTPS type",
"SourceHttpEventParameters":{
"Type":"HTTPS",
"Method":["GET","POST"],
"SecurityConfig":"ip",
"Ip":["10.0.0.0/8", "192.168.XX.XX"]
},
"EventBusName":"my-event-bus"
}Sample response
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"code":"200",
"data":{
"RequestId":"325BED98-734A-15D7-P7F1-7B409088****",
"Data":{
"EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/myhttp.source"
},
"Code":"Success",
"Success":true
},
"httpStatusCode":"200",
"requestId":"325BED98-734A-15D7-P7F1-7B409088****",
"successResponse":true
}Example 5: Custom event source of the Log Service type
Sample request
POST /openapi/createEventSource HTTP/1.1
Host: 164901546557****.eventbridge.cn-hangzhou.aliyuncs.com
Date: Sat, 18 Apr 2020 05:30:41 GMT
x-eventbridge-version: 2020-04-01
Authorization: acs vZ3VL0SuJdHi****:Jo2PbT******azYAYoYslKLvWzg=
Content-Type: application/json;charset=UTF-8
Content-Length: 26
{
"EventSourceName":"mySLS.source",
"Description":"Event source of the Log Service type",
"SourceSLSParameters":{
"RegionId":"cn-hangzhou",
"Project":"test-project",
"LogStore":"test-logstore",
"ConsumePosition":"end",
"RoleName":"testRole"
},
"EventBusName":"my-event-bus"
}Sample response
HTTP/1.1 200 OK
Server: AliyunEventBridge
Connection: keep-alive
Content-Type: application/json;charset=utf-8
Content-Length: 79
x-eventbridge-request-id: 244BED53-719A-15D7-B7F9-1C404273****
Date: Sat, 18 Apr 2020 05:30:41 GMT
{
"code":"200",
"data":{
"RequestId":"325BED98-734A-15D7-P7F1-7B409088****",
"Data":{
"EventSourceARN":"acs:eventbridge:cn-hangzhou:164901546557****:eventbus/my-event-bus/eventsource/mySLS.source"
},
"Code":"Success",
"Success":true
},
"httpStatusCode":"200",
"requestId":"325BED98-734A-15D7-P7F1-7B409088****",
"successResponse":true
}