This topic describes how to create a custom event source of the Simple Log Service type in the EventBridge console.
Before you start
Procedure
Log on to the EventBridge console. In the left-side navigation pane, click Event Buses.
In the top navigation bar, select a region. On the Event Buses page, click the name of the custom event bus that you want to manage.
In the left-side navigation pane, click Event Sources and then click Add Event Source.
In the Add Custom Event Source panel, enter a name in the Name field and a description in the Description field, select Simple Log Service from the Event Provider drop-down list, configure the parameters, and then click OK.
Project: Select the Simple Log Service project that you created.
Logstore: Select the Simple Log Service Logstore that you created.
Consumer Offset: Select Earliest Offset, Latest Offset, or Specified Time as the starting offset for consumption.
Role: Specify the role that EventBridge assumes to read logs in Simple Log Service.
When EventBridge uses the role that you specify to read logs in Simple Log Service, the system creates a consumer group whose name starts with eventbridge- in the Simple Log Service Logstore. After the task is released, the consumer group is also removed.
You must ensure that the role that you specify is granted the permissions to read the logs, add consumer groups, and remove consumer groups in the Simple Log Service Logstore. The following code provides an example of permission policies. For more information, see Policies and examples.
{ "Version": "1", "Statement": [ { "Action": [ "log:ListShards", "log:GetCursorOrData", "log:GetConsumerGroupCheckPoint", "log:UpdateConsumerGroup", "log:ConsumerGroupHeartBeat", "log:ConsumerGroupUpdateCheckPoint", "log:ListConsumerGroup", "log:CreateConsumerGroup", "log:DeleteConsumerGroup" ], "Resource": [ "acs:log:*:*:project/<Project name>/logstore/<Logstore name>", "acs:log:*:*:project/<Project name>/logstore/<Logstore name>/*" ], "Effect": "Allow" } ] }
Sample event
{
"datacontenttype": "application/json;charset=utf-8",
"aliyunaccountid": "175299981560****",
"data": {
"key1": "value1",
"key2": "value2",
"__topic__": "test_topic",
"__source__": "test_source",
"__client_ip__": "122.231.XX.XX",
"__receive_time__": "1663487595",
"__pack_id__": "59b662b2257796****"
},
"subject": "acs:log:cn-qingdao:175299981560****:project/qiingdaoproject/logstore/qingdao-logstore-1",
"aliyunoriginalaccountid": "175299981560****",
"source": "test-SLS",
"type": "sls:connector",
"aliyunpublishtime": "2022-09-18T07:53:15.387Z",
"specversion": "1.0",
"aliyuneventbusname": "qingdaoBus",
"id": "qiingdaoproject-qingdao-logstore-1-1-MTY2MzExODM5ODY4NjAxOTQyMw****",
"time": "2022-09-18T07:53:12Z",
"aliyunregionid": "cn-qingdao",
"aliyunpublishaddr": "10.50.XX.XX"
}
For more information about the parameters defined in the CloudEvents specification, see Overview.
The following table describes the parameters contained in the data field. The parameters that are prefixed and suffixed with underscores (_) are the system fields of Simple Log Service. For more information, see Reserved fields.
Parameter | Required | Example | Description |
key1 | String | testKey | The field in the log of the user. |
__topic__ | String | testTopic | The log topic. |
__source__ | String | testSource | The device from which the log is collected. |
__client_ip__ | String | 122.231.XX.XX | The IP address of the host where the log resides. |
__receive_time__ | String | 1663487595 | The time when the log arrives at the server. |
__pack_id__ | String | 59b662b2257796**** | The unique ID of the log group to which the log belongs. |