Event content conversion
Overview
The event bus EventBridge supports event content conversion, which converts standard events into event types compatible with event targets before routing them to their destination. This document details the types of event conversions provided by event bus EventBridge.
Event content conversion
The event content conversion types supported by event bus EventBridge are as follows: complete event, partial event, constant, variable template
Complete event
When the conversion type is "Complete Event," event bus EventBridge directly routes the native CloudEvents structure to event targets without alteration. The following table illustrates examples before and after complete event conversion.
- Before conversion
1{
2 "data": {
3 "info": "System exception",
4 "advice": "Please contact the administrator"
5 },
6 "id": "*****",
7 "source": "BCE_BCC",
8 "specversion": "1.0",
9 "type": "driverInstallError",
10 "subject": "*****",
11 "time": "2020-11-19T21:04:41+08:00",
12 "level": "WARNING",
13 "accountId": "*****",
14 "eventBusId": "eb-1b63902d",
15 "eventBusName": "defualt",
16 “eventAlias”: “Driver installation failed”,
17 "eventAliasEn": "driverInstallError",
18 "region": "bj",
19 "recvTimestamp": "2020-11-19T21:04:41+08:00"
20}
- Conversion type
1 Complete event
- Conversed event
1{
2 "data": {
3 "info": "System exception",
4 "advice": "Please contact the administrator"
5 },
6 "id": "*****",
7 "source": "BCE_BCC",
8 "specversion": "1.0",
9 "type": "driverInstallError",
10 "subject": "*****",
11 "time": "2020-11-19T21:04:41+08:00",
12 "level": "WARNING",
13 "accountId": "*****",
14 "eventBusId": "eb-1b63902d",
15 "eventBusName": "defualt",
16 “eventAlias”: “Driver installation failed”,
17 "eventAliasEn": "driverInstallError",
18 "region": "bj",
19 "recvTimestamp": "2020-11-19T21:04:41+08:00"
20}
Partial events
When the conversion type is "Partial Events," event bus EventBridge uses JSONPath to extract event parameters from CloudEvents and routes the specified event content to event targets. Examples of before and after partial event conversion are illustrated in the table below.
- Before conversion
1{
2 "data": {
3 "info": "System exception",
4 "advice": "Please contact the administrator"
5 },
6 "id": "*****",
7 "source": "BCE_BCC",
8 "specversion": "1.0",
9 "type": "driverInstallError",
10 "subject": "*****",
11 "time": "2020-11-19T21:04:41+08:00",
12 "level": "WARNING",
13 "accountId": "*****",
14 "eventBusId": "eb-1b63902d",
15 "eventBusName": "defualt",
16 “eventAlias”: “Driver installation failed”,
17 "eventAliasEn": "driverInstallError",
18 "region": "bj",
19 "recvTimestamp": "2020-11-19T21:04:41+08:00"
20}
- Conversion type
1 Partial events: $.eventBusId
- Conversed event
1 eb-1b63902d
Constant
When the conversion type is "Constant," the event serves solely as a trigger. Regardless of the event's content, event bus EventBridge routes the constant to event targets. The table below demonstrates examples before and after constant conversion.
- Before conversion
1{
2 "data": {
3 "info": "System exception",
4 "advice": "Please contact the administrator"
5 },
6 "id": "*****",
7 "source": "BCE_BCC",
8 "specversion": "1.0",
9 "type": "driverInstallError",
10 "subject": "*****",
11 "time": "2020-11-19T21:04:41+08:00",
12 "level": "WARNING",
13 "accountId": "*****",
14 "eventBusId": "eb-1b63902d",
15 "eventBusName": "defualt",
16 “eventAlias”: “Driver installation failed”,
17 "eventAliasEn": "driverInstallError",
18 "region": "bj",
19 "recvTimestamp": "2020-11-19T21:04:41+08:00"
20}
- Conversion type
1 Constant: test
- Conversed event
1 test
Variable templates
When the conversion type is "Template," variables are defined in the template using a custom format. Event bus EventBridge extracts event parameters via JSONPath from CloudEvents, stores these values in variables, and routes them to event targets in the predefined template format. Examples of before and after template conversion are provided in the table below.
- Before conversion
1{
2 "data": {
3 "info": "System exception",
4 "advice": "Please contact the administrator"
5 },
6 "id": "id1",
7 "source": "BCE_BCC",
8 "specversion": "1.0",
9 "type": "driverInstallError",
10 "subject": "*****",
11 "time": "2020-11-19T21:04:41+08:00",
12 "level": "WARNING",
13 "accountId": "*****",
14 "eventBusId": "eb-1b63902d",
15 "eventBusName": "defualt",
16 “eventAlias”: “Driver installation failed”,
17 "eventAliasEn": "driverInstallError",
18 "region": "bj",
19 "recvTimestamp": "2020-11-19T21:04:41+08:00"
20}
- Conversion type
1Variables: Values extracted by JSONPath can be either variables or constants.
2{
3 "id":"$.id",
4 “constant”: “Please handle it promptly.”
5}
6 Template
7 'Instance ${id} is normal, ${constant}’
- Conversed event
1Instance id1 is normal, please handle it timely.
