All Products
Search
Document Center

Function Compute (2.0):Formats of event for different triggers

Last Updated:May 06, 2024

The content and structure of the event parameter of different triggers in Function Compute vary based on the specific trigger events. When a function is invoked, the corresponding business logic is implemented based on information in event.

Usage notes

The trigger events of triggers, which is passed in the form of event, must be parsed before you can use it. For more information about the sample code that is used to parse the event parameter, see Example 1: Parse JSON-formatted parameters.

HTTP triggers

The function signatures for HTTP triggers are request and response objects, instead of event objects. Therefore, HTTP triggers do not follow the event formats. For more information, see Configure and use an HTTP trigger.

Time triggers

{
    "triggerTime":"2023-12-26T07:49:00Z",
    "triggerName":"timer-trigger",
    "payload":"awesome-fc"
}            

Parameter

Type

Example

Description

triggerTime

String

2023-12-26T07:49:00Z

The time when the function is triggered.

triggerName

String

timer-trigger

The name of the time trigger.

payload

String

awesome-fc

The value of Trigger Message that you entered when you created the trigger.

OSS triggers

{
    "events": [
        {
            "eventName": "ObjectCreated:PutObject",
            "eventSource": "acs:oss",
            "eventTime": "2022-08-13T06:45:43.000Z",
            "eventVersion": "1.0",
            "oss": {
                "bucket": {
                    "arn": "acs:oss:cn-hangzhou:123456789:testbucket",
                    "name": "testbucket",
                    "ownerIdentity": "164901546557****"
                },
                "object": {
                    "deltaSize": 122539,
                    "eTag": "688A7BF4F233DC9C88A80BF985AB****",
                    "key": "source/a.png",
                    "size": 122539
                },
                "ossSchemaVersion": "1.0",
                "ruleId": "9adac8e253828f4f7c0466d941fa3db81161****"
            },
            "region": "cn-hangzhou",
            "requestParameters": {
                "sourceIPAddress": "140.205.XX.XX"
            },
            "responseElements": {
                "requestId": "58F9FF2D3DF792092E12044C"
            },
            "userIdentity": {
                "principalId": "164901546557****"
            }
        }
    ]
}

The following table describes the fields in event.

Field

Data type

Example

Description

eventName

String

ObjectCreated:PutObject

The event type.

eventSource

String

acs:oss

The event source. Set the value to acs.oss.

eventTime

String

2022-08-13T06:45:43.000Z

The time when the event occurs. The time is in the ISO 8601 standard format.

eventVersion

String

1.0

The version of the event protocol.

oss

Map

The content of the OSS event.

bucket

Map

Details of the OSS bucket.

name

String

testbucket

The name of the bucket.

arn

String

acs:oss:cn-hangzhou:123456789:testbucket

The Alibaba Cloud Resource Name (ARN) of the bucket.

ownerIdentity

String

164901546557****

The ID of the user that created the bucket.

object

Map

Details of the OSS object.

size

Int

122539

The size of the OSS object. Unit: bytes.

deltaSize

Int

122539

The variation of the size of the OSS object. Unit: bytes.

  • If an object is added, the value of this parameter indicates the size of the object.

  • If a new object overwrites an existing object that has the same name, the value of this parameter indicates the size difference between the new object and the original object.

eTag

String

688A7BF4F233DC9C88A80BF985AB****

The object tag.

key

String

source/a.png

The object name.

ossSchemaVersion

String

1.0

The version of the OSS schema.

ruleId

String

9adac8e253828f4f7c0466d941fa3db81161****

The ID of the rule that matches the event.

region

String

cn-hangzhou

The region where the bucket resides.

requestParameters

Map

The request parameters.

sourceIPAddress

String

140.205.XX.XX

The IP address from which the request is sent.

responseElements

Map

The response elements.

requestId

String

58F9FF2D3DF792092E12044C

The request ID.

userIdentity

Map

The property of the user.

principalId

String

164901546557****

The ID of the Alibaba Cloud account that initiated the request.

Simple Log Service triggers

In Function Compute, event is an input parameter. The following code shows the format of the event parameter:

{
    "parameter": {},
    "source": {
        "endpoint": "http://cn-hangzhou-intranet.log.aliyuncs.com",
        "projectName": "aliyun-fc-cn-hangzhou-2238f0df-a742-524f-9f90-976ba457****",
        "logstoreName": "function-log",
        "shardId": 0,
        "beginCursor": "MTUyOTQ4MDIwOTY1NTk3ODQ2Mw==",
        "endCursor": "MTUyOTQ4MDIwOTY1NTk3ODQ2NA=="
    },
    "jobName": "1f7043ced683de1a4e3d8d70b5a412843d81****",
    "taskId": "c2691505-38da-4d1b-998a-f1d4bb8c****",
    "cursorTime": 1529486425
}                       

Parameter

Description

Example

parameter

The value of the Invocation Parameters parameter that you configure when you create the trigger.

None

source

The log block information that you want the function to read from Simple Log Service.

  • endpoint: the endpoint of the Alibaba Cloud region in which the Simple Log Service project resides.

  • projectName: the name of the Simple Log Service project.

  • logstoreName: the name of the Logstore.

  • shardId: the ID of a specific shard in the Logstore.

  • beginCursor: the offset from which data consumption starts.

  • endCursor: the offset at which data consumption ends.

{
    "endpoint": "http://cn-hangzhou-intranet.log.aliyuncs.com",
    "projectName": "aliyun-fc-cn-hangzhou-2238f0df-a742-524f-9f90-976ba457****",
    "logstoreName": "function-log",
    "shardId": 0,
    "beginCursor": "MTUyOTQ4MDIwOTY1NTk3ODQ2Mw==",
    "endCursor": "MTUyOTQ4MDIwOTY1NTk3ODQ2NA=="
}

jobName

The name of an ETL job in Simple Log Service. Simple Log Service triggers must correspond to ETL jobs in Simple Log Service.

1f7043ced683de1a4e3d8d70b5a412843d81****

taskId

For an ETL job, taskId is the identifier for a deterministic function invocation.

c2691505-38da-4d1b-998a-f1d4bb8c****

cursorTime

The UNIX timestamp of the time when the last log arrives at Simple Log Service.

1529486425

Alibaba Cloud CDN triggers

The event parameter is an input parameter of Function Compute. The following items show the format of event. The key-value pairs in eventParameter vary with the Alibaba Cloud CDN event type.

  • Example of the LogFileCreated event

    Replace filePath with the path of Alibaba Cloud CDN logs or a test file.

    {
        "events": [
            {
                "eventName": "LogFileCreated",
                "eventSource": "cdn",
                "region": "cn-hangzhou",
                "eventVersion": "1.0.0",
                "eventTime": "2018-06-14T15:31:49+08:00",
                "traceId": "c6459282-6a4d-4413-894c-e4ea3968****",
                "userIdentity": {
                    "aliUid": "164901546557****"
                },
                "resource": {
                    "domain": "example.com"
                },
                "eventParameter": {
                    "domain": "example.com",
                    "endTime": 1528959900,
                    "fileSize": 1788115,
                    "filePath": "http://cdnlog.cn-hangzhou.oss.aliyun-inc.com/www.aliyun.com/2017_12_27/www.aliyun.com_2017_12_27_0800_0900.gz?OSSAccessKeyId=xxxx&Expires=xxxx&Signature=xxxx",
                    "startTime": 1528959600
                }
            }
        ]
    }
                        

    The following table describes the fields in the event parameter.

    Field

    Type

    Example

    Description

    eventName

    String

    LogFileCreated

    The type of the event.

    eventSource

    String

    cdn

    The name of the event source.

    region

    String

    cn-hangzhou

    The region where Alibaba Cloud CDN resides. Default value: cn-hangzhou.

    eventVersion

    String

    1.0.0

    The version of the event trigger.

    eventTime

    String

    2018-06-14T15:31:49+08:00

    The time at which an event occurred.

    traceId

    String

    c6459282-6a4d-4413-894c-e4ea3968****

    The ID that is delivered by the event source for troubleshooting.

    userIdentity

    Map

    The information about the user.

    aliUid

    String

    164901546557****

    The ID of the Alibaba Cloud account that created the namespace.

    resource

    Map

    The information about the resources.

    domain

    String

    example.com

    The domain name.

    eventParameter

    Map

    The event parameters.

    domain

    String

    example.com

    The domain name.

    endTime

    String

    1528959900

    The end time of the log file.

    fileSize

    String

    1788115

    The size of the log file.

    filePath

    String

    http://cdnlog.cn-hangzhou.oss.aliyun-inc.com/www.aliyun.com/2017_12_27/www.aliyun.com_2017_12_27_0800_0900.gz?OSSAccessKeyId=xxxx&Expires=xxxx&Signature=xxxx

    The location of the log file.

    startTime

    String

    1528959600

    The start time of the log file.

  • Examples of event for the CachedObjectsRefreshed and CachedObjectsPushed events

    {
        "events": [
            {
                "eventName": "CachedObjectsRefreshed",
                "eventVersion": "1.0.0", 
                "eventSource": "cdn", 
                "region": "cn-hangzhou",
                "eventTime": "2018-03-16T14:19:55+08:00",
                "traceId": "cf89e5a8-7d59-4bb5-a33e-4c3d08e2****",
                "resource": {
                    "domain": "example.com"
                },
                "eventParameter": {
                    "objectPath": [
                        "/2018/03/16/13/33b430c57e7.mp4",
                        "/2018/03/16/14/4ff6b9bd54d.mp4"
                    ],
                    "createTime": 1521180769,
                    "domain": "example.com",
                    "completeTime": 1521180777,
                    "objectType": "File",
                    "taskId": 2089687230
                },
                "userIdentity": {
                    "aliUid": "164901546557****"
                }
            }
        ]
    }                    

    The following table describes the fields in the event parameter.

    Field

    Type

    Example

    Description

    eventName

    String

    CachedObjectsRefreshed

    The type of the event.

    eventSource

    String

    cdn

    The name of the event source.

    region

    String

    cn-hangzhou

    The region where Alibaba Cloud CDN resides. Default value: cn-hangzhou.

    eventVersion

    String

    1.0.0

    The version of the event trigger.

    eventTime

    String

    2018-06-14T15:31:49+08:00

    The time at which an event occurred.

    traceId

    String

    c6459282-6a4d-4413-894c-e4ea3968****

    The ID that is delivered by the event source for troubleshooting.

    resource

    Map

    The information about the resources.

    domain

    String

    example.com

    The domain name.

    eventParameter

    Map

    The event parameters.

    objectPath

    String

    /2018/03/16/13/33b430c57e7.mp4

    The resource identifier.

    createTime

    String

    1521180769

    The start time of the refresh.

    domain

    String

    example.com

    The domain name.

    completeTime

    String

    1521180777

    The end time of the refresh.

    objectType

    String

    File

    The item that is refreshed. Valid values:

    • File: files

    • Directory: folders

    taskId

    String

    2089687230

    The ID of the resource refresh task.

    userIdentity

    Map

    The information about the user.

    aliUid

    String

    164901546557****

    The ID of the Alibaba Cloud account that created the namespace.

  • Samples of CdnDomainStarted and CdnDomainStopped events

    {  "events": [
          { 
             "eventName": "CdnDomainStarted",
             "eventVersion": "1.0.0",
             "eventSource": "cdn",
             "region": "cn-hangzhou",
             "eventTime": "2018-03-16T14:19:55+08:00",
             "traceId": "cf89e5a8-7d59-4bb5-a33e-4c3d08e2****",
             "resource": {
                  "domain": "example.com" 
             }, 
             "eventParameter": {
                  "domain": "example.com", 
                  "status": "online"
             }, 
             "userIdentity": {
                  "aliUid": "164901546557****"
             } 
          } 
       ]
    }

    The following table describes the fields in the event parameter.

    Field

    Type

    Example

    Description

    eventName

    String

    CdnDomainStarted

    The type of the event.

    eventSource

    String

    cdn

    The name of the event source.

    region

    String

    cn-hangzhou

    The region where Alibaba Cloud CDN resides. Default value: cn-hangzhou.

    eventVersion

    String

    1.0.0

    The version of the event trigger.

    eventTime

    String

    2018-06-14T15:31:49+08:00

    The time at which an event occurred.

    traceId

    String

    c6459282-6a4d-4413-894c-e4ea3968****

    The ID that is delivered by the event source for troubleshooting.

    resource

    Map

    The information about the resources.

    domain

    String

    example.com

    The domain name.

    eventParameter

    Map

    The event parameters.

    domain

    String

    example.com

    The domain name.

    status

    String

    online

    The status of the accelerated domain name.

    userIdentity

    Map

    The information about the user.

    aliUid

    String

    164901546557****

    The ID of the Alibaba Cloud account that created the namespace.

  • Samples of CdnDomainAdded and CdnDomainDeleted events

    {  "events": [
          {
             "eventName": "CdnDomainAdded",
             "eventVersion": "1.0.0",
             "eventSource": "cdn",
             "region": "cn-hangzhou",
             "eventTime": "2018-03-16T14:19:55+08:00",
             "traceId": "cf89e5a8-7d59-4bb5-a33e-4c3d08e2****",
             "resource": {
                  "domain": "example.com"
             },
             "eventParameter": {
                  "domain": "example.com"
             },
             "userIdentity": {
                  "aliUid": "164901546557****"
             }
          }
       ]
    }

    The following table describes the fields in the event parameter.

    Field

    Type

    Example

    Description

    eventName

    String

    CdnDomainAdded

    The event type.

    eventSource

    String

    cdn

    The name of the event source.

    region

    String

    cn-hangzhou

    The region where Alibaba Cloud CDN resides. Default value: cn-hangzhou.

    eventVersion

    String

    1.0.0

    The version of the event trigger.

    eventTime

    String

    2018-06-14T15:31:49+08:00

    The time at which an event occurred.

    traceId

    String

    c6459282-6a4d-4413-894c-e4ea3968****

    The ID that is delivered by the event source for troubleshooting.

    resource

    Map

    The information about the resources.

    domain

    String

    example.com

    The domain name.

    eventParameter

    Map

    The event parameters.

    domain

    String

    example.com

    The domain name.

    userIdentity

    Map

    The information about the user.

    aliUid

    String

    164901546557****

    The ID of the Alibaba Cloud account that created the namespace.

Tablestore triggers

{
    "Version": "Sync-v1",
    "Records": [
        {
            "Type": "PutRow",
            "Info": {
                "Timestamp": 1506416585740836
            },
            "PrimaryKey": [
                {
                    "ColumnName": "pk_0",
                    "Value": 1506416585881590900
                },
                {
                    "ColumnName": "pk_1",
                    "Value": "2017-09-26 17:03:05.8815909 +0800 CST"
                },
                {
                    "ColumnName": "pk_2",
                    "Value": 1506416585741000
                }
            ],
            "Columns": [
                {
                    "Type": "Put",
                    "ColumnName": "attr_0",
                    "Value": "hello_table_store",
                    "Timestamp": 1506416585741
                },
                {
                    "Type": "Put",
                    "ColumnName": "attr_1",
                    "Value": 1506416585881590900,
                    "Timestamp": 1506416585741
                }
            ]
        }
    ]
}

The following table describes the fields in event.

Field

Description

Version

The version of the payload. Example: Sync-v1. The value is a string.

Records

The array that stores the rows of incremental data in the table. This parameter includes the following fields:

  • Type: the type of the operation that is performed on the row. Valid values: PutRow, UpdateRow, and DeleteRow. The value is a string.

  • Info: the information about the row, including the Timestamp parameter, which specifies the time when the row was last modified. The time must be in UTC. The value is of type "Int64."

PrimaryKey

The array that stores primary key columns. This parameter includes the following fields:

  • ColumnName: the name of the primary key column. The value is a string.

  • Value: the content of the primary key column. The value is of type formated_value, which can be Integer, String, or Blob.

Columns

The array that stores the attribute columns. This parameter includes the following fields:

  • Type: the type of the operation that is performed on the attribute column. Valid values: Put, DeleteOneVersion, and DeleteAllVersions. The value is a string.

  • ColumnName: the name of the attribute column. The value is a string.

  • Value: the content of the attribute column. The value is of type formatted_value, which can be Integer, Boolean, Double, String, or Blob.

  • Timestamp: the time when the attribute column was last modified. The time must be in UTC. The value is of type "Int64."

MNS topic trigger

  • If you set Event Format to STREAM:

    • The following code shows the format of the event parameter if messages do not contain message attributes:

      Note

      If messages do not contain message attributes, the content of the event parameter is a string in JSON format.

      # The message body. 
      'hello topic'
    • The following code shows the format of the event parameter if messages contain message attributes:

      Note

      The content of the event parameter contains the key-value pairs that are related to message attributes. For more information, see PublishMessage.

         {
              "body": "hello topic",
              "attrs": {
                  "Extend": "{\\"key\\":\\"value\\"}"
              }
          }                    
  • If you set Event Format to JSON:

    • The following code shows the format of the event parameter if messages do not contain message attributes:

          {
              "TopicOwner": "118620210433****",
              "Message": "hello topic",
              "Subscriber": "118620210433****",
              "PublishTime": 1550216480040,
              "SubscriptionName": "test-fc-subscribe",
              "MessageMD5": "BA4BA9B48AC81F0F9C66F6C909C3****",
              "TopicName": "Mytopic",
              "MessageId": "2F5B3C082B923D4EAC694B76D928****"
          }        
                                  
    • The following code shows the format of the event parameter if messages contain message attributes:

      Note

      The content of the event parameter contains the key-value pairs that are related to message attributes. For more information, see PublishMessage.

          {
              "key": "value",
              "TopicOwner": "118620210433****",
              "Message": "hello topic",
              "Subscriber": "118620210433****",
              "PublishTime": 1550216302888,
              "SubscriptionName": "test-fc-subscribe",
              "MessageMD5": "BA4BA9B48AC81F0F9C66F6C909C3****",
              "TopicName": "Mytopic",
              "MessageId": "2F5B3C281B283D4EAC694B742528****"
          }
                                  

MNS queue triggers

Sample code of event in the event mode:
{
    "id":"c2g71017-6f65-fhcf-a814-a396fc8d****",
    "source":"MNS-Function-mnstrigger",
    "specversion":"1.0",
    "type":"mns:Queue:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mns:cn-hangzhou:164901546557****:queues/zeus",
    "time":"2021-04-08T06:28:17.093Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T07:06:34.028Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"MNS-Function-mnstrigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "requestId":"606EA3074344430D4C81****",
        "messageId":"C6DB60D1574661357FA227277445****",
        "messageBody":"TEST"
    }
}
Sample code of event in the event stream mode:
[
    {
    "id":"c2g71017-6f65-fhcf-a814-a396fc8d****",
    "source":"MNS-Function-mnstrigger",
    "specversion":"1.0",
    "type":"mns:Queue:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mns:cn-hangzhou:164901546557****:queues/zeus",
    "time":"2021-04-08T06:28:17.093Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T07:06:34.028Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"MNS-Function-mnstrigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "requestId":"606EA3074344430D4C81****",
        "messageId":"C6DB60D1574661357FA227277445****",
        "messageBody":"TEST"
    }
    },
    {
    "id":"d2g71017-6f65-fhcf-a814-a396fc8d****",
    "source":"MNS-Function-mnstrigger",
    "specversion":"1.0",
    "type":"mns:Queue:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mns:cn-hangzhou:164901546557****:queues/zeus",
    "time":"2021-04-08T06:28:17.093Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T07:06:34.028Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"MNS-Function-mnstrigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "requestId":"606EA3074344430D4C81****",
        "messageId":"C6DB60D1574661357FA227277445****",
        "messageBody":"TEST"
    }
    }
]
The following table describes the parameters in data. For information about the parameters that are defined in the CloudEvents specification, see Overview.
ParameterTypeExampleDescription
requestIdString606EA3074344430D4C81****The ID of the request. The ID of each request is unique.
messageIdStringC6DB60D1574661357FA227277445****The ID of the message. The ID of each message is unique.
messageBodyStringTESTThe content of the message.

ApsaraMQ for RocketMQ triggers

Sample code of event in the event mode:
{
    "id":"94ebc15f-f0db-4bbe-acce-56fb72fb****",
    "source":"RocketMQ-Function-rocketmq-trigger",
    "specversion":"1.0",
    "type":"mq:Topic:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mq:cn-hangzhou:164901546557****:MQ_INST_164901546557****_BXhFHryi%TopicName",
    "time":"2021-04-08T06:01:20.766Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T02:05:16.791Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RocketMQ-Function-rocketmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "topic":"TopicName",
        "systemProperties":{
            "MIN_OFFSET":"0",
            "TRACE_ON":"true",
            "MAX_OFFSET":"8",
            "MSG_REGION":"cn-hangzhou",
            "KEYS":"systemProperties.KEYS",
            "CONSUME_START_TIME":1628577790396,
            "TAGS":"systemProperties.TAGS",
            "INSTANCE_ID":"MQ_INST_164901546557****_BXhFHryi"
        },
        "userProperties":{

        },
        "body":"TEST"
    }
}
Sample code of event in the event stream mode:
[
    {
    "id":"94ebc15f-f0db-4bbe-acce-56fb72fb****",
    "source":"RocketMQ-Function-rocketmq-trigger",
    "specversion":"1.0",
    "type":"mq:Topic:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mq:cn-hangzhou:164901546557****:MQ_INST_164901546557****_BXhFHryi%TopicName",
    "time":"2021-04-08T06:01:20.766Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T02:05:16.791Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RocketMQ-Function-rocketmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "topic":"TopicName",
        "systemProperties":{
            "MIN_OFFSET":"0",
            "TRACE_ON":"true",
            "MAX_OFFSET":"8",
            "MSG_REGION":"cn-hangzhou",
            "KEYS":"systemProperties.KEYS",
            "CONSUME_START_TIME":1628577790396,
            "TAGS":"systemProperties.TAGS",
            "INSTANCE_ID":"MQ_INST_164901546557****_BXhFHryi"
        },
        "userProperties":{

        },
        "body":"TEST"
    }
    },
    {
    "id":"94ebc15f-f0db-4bbe-acce-56fb72fb****",
    "source":"RocketMQ-Function-rocketmq-trigger",
    "specversion":"1.0",
    "type":"mq:Topic:SendMessage",
    "datacontenttype":"application/json; charset=utf-8",
    "subject":"acs:mq:cn-hangzhou:164901546557****:MQ_INST_164901546557****_BXhFHryi%TopicName",
    "time":"2021-04-08T06:01:20.766Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T02:05:16.791Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RocketMQ-Function-rocketmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "topic":"TopicName",
        "systemProperties":{
            "MIN_OFFSET":"0",
            "TRACE_ON":"true",
            "MAX_OFFSET":"8",
            "MSG_REGION":"cn-hangzhou",
            "KEYS":"systemProperties.KEYS",
            "CONSUME_START_TIME":1628577790396,
            "TAGS":"systemProperties.TAGS",
            "INSTANCE_ID":"MQ_INST_164901546557****_BXhFHryi"
        },
        "userProperties":{

        },
        "body":"TEST"
    }
    }
]
The following table describes the parameters in data. For information about the parameters that are defined in the CloudEvents specification, see Overview.

Parameter

Type

Example

Description

topic

String

TopicName

The topic name.

systemProperties

Map

The system properties.

MIN_OFFSET

Int

0

The earliest offset.

TRACE_ON

Boolean

true

Indicates whether a message trace exists. Valid values:

  • true

  • false

MAX_OFFSET

Int

8

The latest offset.

MSG_REGION

String

cn-hangzhou

The region from which the message is sent.

KEYS

String

systemProperties.KEYS

The keys that are used to filter the message.

CONSUME_START_TIME

Long

1628577790396

The start time of message consumption. Unit: milliseconds.

UNIQ_KEY

String

AC14C305069E1B28CDFA3181CDA2****

The unique key of the message.

TAGS

String

systemProperties.TAGS

The tags that are used to filter the message.

INSTANCE_ID

String

MQ_INST_123456789098****_BXhFHryi

The ID of the ApsaraMQ for RocketMQ instance.

userProperties

Map

None

The user properties.

body

String

TEST

The message body.

ApsaraMQ for RabbitMQ triggers

Sample code of event in the event mode:
  {
    "id":"bj694332-4cj1-389e-9d8c-b137h30b****",
    "source":"RabbitMQ-Function-rabbitmq-trigger",
    "specversion":"1.0",
    "type":"amqp:Queue:SendMessage",
    "datacontenttype":"application/json;charset=utf-8",
    "subject":"acs:amqp:cn-hangzhou:164901546557****:/instances/amqp-cn-tl32e756****/vhosts/eb-connect/queues/housekeeping",
    "time":"2021-08-12T06:56:40.709Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T08:58:55.140Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RabbitMQ-Function-rabbitmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "envelope":{
            "deliveryTag":98,
            "exchange":"",
            "redeliver":false,
            "routingKey":"housekeeping"
        },
        "body":{
            "Hello":"RabbitMQ"
        },
        "props":{
            "contentEncoding":"UTF-8",
            "messageId":"f7622d51-e198-41de-a072-77c1ead7****"
        }
    }
}
Sample code of event in the event stream mode:
[
      {
    "id":"bj694332-4cj1-389e-9d8c-b137h30b****",
    "source":"RabbitMQ-Function-rabbitmq-trigger",
    "specversion":"1.0",
    "type":"amqp:Queue:SendMessage",
    "datacontenttype":"application/json;charset=utf-8",
    "subject":"acs:amqp:cn-hangzhou:164901546557****:/instances/amqp-cn-tl32e756****/vhosts/eb-connect/queues/housekeeping",
    "time":"2021-08-12T06:56:40.709Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T08:58:55.140Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RabbitMQ-Function-rabbitmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "envelope":{
            "deliveryTag":98,
            "exchange":"",
            "redeliver":false,
            "routingKey":"housekeeping"
        },
        "body":{
            "Hello":"RabbitMQ"
        },
        "props":{
            "contentEncoding":"UTF-8",
            "messageId":"f7622d51-e198-41de-a072-77c1ead7****"
        }
    }
    },
    {
    "id":"bj694332-4cj1-389e-9d8c-b137h30b****",
    "source":"RabbitMQ-Function-rabbitmq-trigger",
    "specversion":"1.0",
    "type":"amqp:Queue:SendMessage",
    "datacontenttype":"application/json;charset=utf-8",
    "subject":"acs:amqp:cn-hangzhou:164901546557****:/instances/amqp-cn-tl32e756****/vhosts/eb-connect/queues/housekeeping",
    "time":"2021-08-12T06:56:40.709Z",
    "aliyunaccountid":"164901546557****",
    "aliyunpublishtime":"2021-10-15T08:58:55.140Z",
    "aliyunoriginalaccountid":"164901546557****",
    "aliyuneventbusname":"RabbitMQ-Function-rabbitmq-trigger",
    "aliyunregionid":"cn-chengdu",
    "aliyunpublishaddr":"42.120.XX.XX",
    "data":{
        "envelope":{
            "deliveryTag":98,
            "exchange":"",
            "redeliver":false,
            "routingKey":"housekeeping"
        },
        "body":{
            "Hello":"RabbitMQ"
        },
        "props":{
            "contentEncoding":"UTF-8",
            "messageId":"f7622d51-e198-41de-a072-77c1ead7****"
        }
    }
    }
]
The following table describes the parameters in data. For information about the parameters that are defined in the CloudEvents specification, see Overview.

Parameter

Type

Example

Description

body

Map

The message body.

Hello

String

EventBridge

The user data.

props

Map

The message attributes.

contentEncoding

String

utf-8

The format in which the message body is encoded.

messageId

String

f7622d51-e198-41de-a072-77c1ead7****

The message ID. The ID of each message is unique.

envelope

Map

The information about the message envelope.

deliveryTag

Int

98

The message tag.

exchange

String

None

The name of the exchange that sends the message.

redeliver

Boolean

false

Specifies whether the message can be resent. Valid values:

  • true

  • false

routingKey

String

housekeeping

The routing rule of the message.

ApsaraMQ for Kafka triggers

[
    {
        "specversion":"1.0",
        "id":"8e215af8-ca18-4249-8645-f96c1026****",
        "source":"acs:alikafka",
        "type":"alikafka:Topic:Message",
        "subject":"acs:alikafka_pre-cn-i7m2t7t1****:topic:mytopic",
        "datacontenttype":"application/json; charset=utf-8",
        "time":"2022-06-23T02:49:51.589Z",
        "aliyunaccountid":"164901546557****",
        "data":{
            "topic":"****",
            "partition":7,
            "offset":25,
            "timestamp":1655952591589,
            "headers":{
                "headers":[

                ],
                "isReadOnly":false
            },
            "key":"keytest",
            "value":"hello kafka msg"
        }
    },
    {
        "specversion":"1.0",
        "id":"8e215af8-ca18-4249-8645-f96c1026****",
        "source":"acs:alikafka",
        "type":"alikafka:Topic:Message",
        "subject":"acs:alikafka_pre-cn-i7m2t7t1****:topic:mytopic",
        "datacontenttype":"application/json; charset=utf-8",
        "time":"2022-06-23T02:49:51.589Z",
        "aliyunaccountid":"164901546557****",
        "data":{
            "topic":"****",
            "partition":7,
            "offset":25,
            "timestamp":1655952591589,
            "headers":{
                "headers":[

                ],
                "isReadOnly":false
            },
            "key":"keytest",
            "value":"hello kafka msg"
        }
    }
]

The following table describes the parameters contained in data.

Parameter

Type

Example

Details

topic

String

TopicName

The topic name.

partition

Int

1

The information about partitions on the ApsaraMQ for Kafka instance.

offset

Int

0

The message offset of the ApsaraMQ for Kafka instance.

timestamp

String

1655952591589

The timestamp that indicates when message consumption started.

DTS triggers

Sample code of event:
[
  {
    "data": {
      "id": 321****,
      "topicPartition": {
        "hash": 0,
        "partition": 0,
        "topic": "cn_hangzhou_rm_1234****_test_version2"
      },
      "offset": 3218099,
      "sourceTimestamp": 1654847757,
      "operationType": "UPDATE",
      "schema": {
        "recordFields": [
          {
            "fieldName": "id",
            "rawDataTypeNum": 8,
            "isPrimaryKey": true,
            "isUniqueKey": false,
            "fieldPosition": 0
          },
          {
            "fieldName": "topic",
            "rawDataTypeNum": 253,
            "isPrimaryKey": false,
            "isUniqueKey": false,
            "fieldPosition": 1
          }
        ],
        "nameIndex": {
          "id": {
            "fieldName": "id",
            "rawDataTypeNum": 8,
            "isPrimaryKey": true,
            "isUniqueKey": false,
            "fieldPosition": 0
          },
          "topic": {
            "fieldName": "topic",
            "rawDataTypeNum": 253,
            "isPrimaryKey": false,
            "isUniqueKey": false,
            "fieldPosition": 1
          }
        },
        "schemaId": "(hangzhou-test-db,hangzhou-test-db,message_info)",
        "databaseName": "hangzhou--test-db",
        "tableName": "message_info",
        "primaryIndexInfo": {
          "indexType": "PrimaryKey",
          "indexFields": [
            {
              "fieldName": "id",
              "rawDataTypeNum": 8,
              "isPrimaryKey": true,
              "isUniqueKey": false,
              "fieldPosition": 0
            }
          ],
          "cardinality": 0,
          "nullable": true,
          "isFirstUniqueIndex": false
        },
        "uniqueIndexInfo": [],
        "foreignIndexInfo": [],
        "normalIndexInfo": [],
        "databaseInfo": {
          "databaseType": "MySQL",
          "version": "5.7.35-log"
        },
        "totalRows": 0
      },
      "beforeImage": {
        "recordSchema": {
          "recordFields": [
            {
              "fieldName": "id",
              "rawDataTypeNum": 8,
              "isPrimaryKey": true,
              "isUniqueKey": false,
              "fieldPosition": 0
            },
            {
              "fieldName": "topic",
              "rawDataTypeNum": 253,
              "isPrimaryKey": false,
              "isUniqueKey": false,
              "fieldPosition": 1
            }
          ],
          "nameIndex": {
            "id": {
              "fieldName": "id",
              "rawDataTypeNum": 8,
              "isPrimaryKey": true,
              "isUniqueKey": false,
              "fieldPosition": 0
            },
            "topic": {
              "fieldName": "topic",
              "rawDataTypeNum": 253,
              "isPrimaryKey": false,
              "isUniqueKey": false,
              "fieldPosition": 1
            }
          },
          "schemaId": "(hangzhou-test-db,hangzhou-test-db,message_info)",
          "databaseName": "hangzhou-test-db",
          "tableName": "message_info",
          "primaryIndexInfo": {
            "indexType": "PrimaryKey",
            "indexFields": [
              {
                "fieldName": "id",
                "rawDataTypeNum": 8,
                "isPrimaryKey": true,
                "isUniqueKey": false,
                "fieldPosition": 0
              }
                ],
                "cardinality": 0,
                "nullable": true,
                "isFirstUniqueIndex": false
              },
                "uniqueIndexInfo": [],
                "foreignIndexInfo": [],
                "normalIndexInfo": [],
                "databaseInfo": {
                "databaseType": "MySQL",
                "version": "5.7.35-log"
              },
                "totalRows": 0
              },
                "values": [
                {
                "data": 115
              },
                {
                "data": {
                "hb": [
                104,
                101,
                108,
                108,
                111
                ],
                "offset": 0,
                "isReadOnly": false,
                "bigEndian": true,
                "nativeByteOrder": false,
                "mark": -1,
                "position": 0,
                "limit": 9,
                "capacity": 9,
                "address": 0
              },
                "charset": "utf8mb4"
              }
                ],
                "size": 45
              },
                "afterImage": {
                "recordSchema": {
                "recordFields": [
                {
                "fieldName": "id",
                "rawDataTypeNum": 8,
                "isPrimaryKey": true,
                "isUniqueKey": false,
                "fieldPosition": 0
              },
                {
                "fieldName": "topic",
                "rawDataTypeNum": 253,
                "isPrimaryKey": false,
                "isUniqueKey": false,
                "fieldPosition": 1
              }
                ],
                "nameIndex": {
                "id": {
                "fieldName": "id",
                "rawDataTypeNum": 8,
                "isPrimaryKey": true,
                "isUniqueKey": false,
                "fieldPosition": 0
              },
                "topic": {
                "fieldName": "topic",
                "rawDataTypeNum": 253,
                "isPrimaryKey": false,
                "isUniqueKey": false,
                "fieldPosition": 1
              }
              },
                "schemaId": "(hangzhou-test-db,hangzhou-test-db,message_info)",
                "databaseName": "hangzhou-test-db",
                "tableName": "message_info",
                "primaryIndexInfo": {
                "indexType": "PrimaryKey",
                "indexFields": [
                {
                "fieldName": "id",
                "rawDataTypeNum": 8,
                "isPrimaryKey": true,
                "isUniqueKey": false,
                "fieldPosition": 0
              }
                ],
                "cardinality": 0,
                "nullable": true,
                "isFirstUniqueIndex": false
              },
                "uniqueIndexInfo": [],
                "foreignIndexInfo": [],
                "normalIndexInfo": [],
                "databaseInfo": {
                "databaseType": "MySQL",
                "version": "5.7.35-log"
              },
                "totalRows": 0
              },
                "values": [
                {
                "data": 115
              },
                {
                "data": {
                "hb": [
                98,
                121,
                101
                ],
                "offset": 0,
                "isReadOnly": false,
                "bigEndian": true,
                "nativeByteOrder": false,
                "mark": -1,
                "position": 0,
                "limit": 11,
                "capacity": 11,
                "address": 0
              },
                "charset": "utf8mb4"
              }
                ],
                "size": 47
              }
              },
    "id": "12f701a43741d404fa9a7be89d9acae0-321****",
    "source": "DTSstreamDemo",
    "specversion": "1.0",
    "type": "dts:ConsumeMessage",
    "datacontenttype": "application/json; charset=utf-8",
    "time": "2022-06-10T07:55:57Z",
    "subject": "acs:dts:cn-hangzhou:12345****:kk123abc60g782/dtsabcdet1ro"
  }
]

For information about the parameters defined in the CloudEvents specification, see Overview.

The following table describes the parameters contained in the data field.

Parameter

Type

Description

id

String

The ID of the DTS data entry.

topicPartition

Array

The partition information about the topic to which the event is pushed.

hash

String

The underlying storage parameter of DTS.

partition

String

The partition.

topic

String

The topic name.

offset

Int

The offset of the DTS data entry.

sourceTimestamp

Int

The timestamp that indicates when the DTS data entry was generated.

operationType

String

The type of operation involved in the DTS data entry.

schema

Array

The schema information about the database.

recordFields

Array

The details of fields.

fieldName

String

The field name.

rawDataTypeNum

Int

The mapped value of the field type.

The value of this parameter corresponds to the value of the dataTypeNumber field in the deserialized incremental data from the change tracking instance. For more information, see Use a Kafka client to consume tracked data.

isPrimaryKey

Boolean

Indicates whether the field is a primary key field.

isUniqueKey

Boolean

Indicates whether the field has a unique key.

fieldPosition

String

The field position.

nameIndex

Array

The indexing information about the fields based on field names.

schemaId

String

The ID of the database schema.

databaseName

String

The database name.

tableName

String

The table name.

primaryIndexInfo

String

The primary key indexes.

indexType

String

The index type.

indexFields

Array

The fields on which the indexes are created.

cardinality

String

The cardinality of the primary keys.

nullable

Boolean

Indicates whether the primary keys can be null.

isFirstUniqueIndex

Boolean

Indicates whether the index is the first unique index.

uniqueIndexInfo

String

The unique indexes.

foreignIndexInfo

String

The indexes for foreign keys.

normalIndexInfo

String

The regular indexes.

databaseInfo

Array

The information about the database.

databaseType

String

The database engine.

version

String

The database engine version.

totalRows

Int

The total number of rows in the table.

beforeImage

String

The image that records field values before the operation is performed.

values

String

The field values recorded.

size

Int

The size of the fields recorded.

afterImage

String

The image that records field values after the operation is performed.

ApsaraMQ for MQTT triggers

Sample code of event:

[
  {
    "props": {
      "firstTopic": "testTopic",
      "secondTopic": "/testMq4****",
      "clientId": "consumerGroupID@@@xxx"
    },
    "body": "hello mq4Iot pub sub msg"
  }
]

The following table describes parameters that are contained in event.

Parameter

Type

Example

Description

props

Map

The properties of the message.

firstTopic

String

testTopic

The parent topic that is used to send and receive messages.

secondTopic

String

/testMq4****

The subtopic.

clientId

String

consumerGroupID@@@xx

The ID of the client.

body

String

hello mq4Iot pub sub msg

The content of the message.

Self-managed Apache RocketMQ triggers

Sample code of event:

[
  {
    "msgId": "7F0000010BDD2A84AEE70DA49B57****",
    "topic": "testTopic",
    "systemProperties": {
      "UNIQ_KEY": "7F0000010BDD2A84AEE70DA49B57****",
      "CLUSTER": "DefaultCluster",
      "MIN_OFFSET": "0",
      "TAGS": "TagA",
      "MAX_OFFSET": "128"
    },
    "userProperties": {},
    "body": "Hello RocketMQ"
  }
]

The following table describes parameters that are contained in event.

Parameter

Type

Example

Description

msgId

String

7F0000010BDD2A84AEE70DA49B57****

The ID of the Apache RocketMQ message.

topic

String

testTopic

The topic name.

systemProperties

Map

The system properties.

UNIQ_KEY

String

7F0000010BDD2A84AEE70DA49B57****

The unique key of the message.

CLUSTER

String

DefaultCluster

The name of the Apache RocketMQ cluster.

MIN_OFFSET

Int

0

The minimum offset.

MAX_OFFSET

Int

128

The maximum offset.

TAGS

String

TagA

The tags that are used to filter messages.

userProperties

Map

None.

The user properties.

body

String

Hello RocketMQ

The content of the message.

API Gateway triggers

{
    "path":"api request path",
    "httpMethod":"request method name",
    "headers":{all headers,including system headers},
    "queryParameters":{query parameters},
    "pathParameters":{path parameters},
    "body":"string of request payload",
    "isBase64Encoded":"true|false, indicate if the body is Base64-encode"
}  
Note
  • If the value of isBase64Encoded is true, the body content that API Gateway sends to Function Compute is Base64-encoded. Function Compute decodes the body content from Base64 format before the content is processed.
  • If the value of isBase64Encoded is false, API Gateway does not perform Base64 encoding on the body content. Function Compute can directly obtain the body content.

DataHub triggers

{
  "eventSource": "acs:datahub",
  "eventName": "acs:datahub:putRecord",
  "eventSourceARN": "/projects/test_project_name/topics/test_topic_name",
  "region": "cn-hangzhou",
  "records": [
    {
      "eventId": "0:12345",
      "systemTime": 1463000123000,
      "data": "[\"col1's value\",\"col2's value\"]"
    },
    {
      "eventId": "0:12346",
      "systemTime": 1463000156000,
      "data": "[\"col1's value\",\"col2's value\"]"
    }
  ]
}

For more information, see Data structure of events.