tencent cloud

Serverless Cloud Function

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Related Concepts
How It Works
Strengths
Scenarios
Related Products
Purchase Guide
Billing Overview
Billing Mode
Billable Items and Billing Modes
Function Computing Power Support
Free Tier
SCF Pricing
Billing Example
Payment Overdue
Getting Started
Creating Event Function in Console
User Guide
Quota Management
Managing Functions
Web Function Management
Log Management
Concurrence Management
Trigger Management
Function URL
A Custom Domain Name
Version Management
Alias Management
Permission Management
Running Instance Management
Plugin Management
Managing Monitors and Alarms
Network Configuration
Layer Management
Execution Configuration
Extended Storage Management
DNS Caching Configuration
Resource Managed Mode Management
Near-Offline Resource Hosting Model
Workflow
Triggers
Trigger Overview
Trigger Event Message Structure Summary
API Gateway Trigger
COS Trigger
CLS Trigger
Timer Trigger
CKafka Trigger
Apache Kafka Trigger
MQTT Trigger
Trigger Configuration Description
MPS Trigger
CLB Trigger Description
TencentCloud API Trigger
Development Guide
Basic Concepts
Testing a Function
Environment Variables
Dependency Installation
Using Container Image
Error Types and Retry Policies
Dead Letter Queue
Connecting SCF to Database
Automated Deployment
Cloud Function Status Code
Common Errors and Solutions
Developer Tools
Serverless Web IDE
Calling SDK Across Functions
Third-Party Tools
Code Development
Python
Node.js
Golang
PHP
Java
Custom Runtime
Deploying Image as Function
Web Framework Development
Deploying Framework on Command Line
Quickly Deploying Egg Framework
Quickly Deploying Express Framework
Quickly Deploying Flask Framework
Quickly Deploying Koa Framework
Quickly Deploying Laravel Framework
Quickly Deploying Nest.js Framework
Quickly Deploying Next.js Framework
Quickly Deploying Nuxt.js Framework
Quickly Deploying Django Framework
Use Cases
Overview
Solutions with Tencent Cloud Services
Business Development
TRTC Practices
COS Practices
CKafka Practice
CLS
CLB Practice
MPS
CDN
CDWPG
VOD
SMS
ES
Scheduled Task
Video Processing
Success Stories
Tencent Online Education
Online Video Industry
Tencent Online Education
Best Practice of Tencent IEG Going Global
API Documentation
History
Introduction
API Category
Making API Requests
Other APIs
Namespace APIs
Layer Management APIs
Async Event Management APIs
Trigger APIs
Function APIs
Function and Layer Status Description
Data Types
Error Codes
SDK Documentation
FAQs
General
Web Function
Billing FAQs
Network FAQs
Log FAQs
SCF utility class
Event Handling FAQs
API Gateway Trigger FAQs
Related Agreement
Service Level Agreement
Contact Us
Glossary
ドキュメントServerless Cloud FunctionTriggersTrigger Event Message Structure Summary

Trigger Event Message Structure Summary

PDF
フォーカスモード
フォントサイズ
最終更新日: 2024-12-02 19:58:17
This document summarizes the message structures of all trigger events that are connected to SCF. For more information on trigger configuration and restrictions, see Trigger Management.
Note:
The event structure of the input parameter passed in by a trigger has been partially defined and can be used directly. You can get and use the Java library through the Java Cloud Event Definition or the Go library through the Go Cloud Event Definition.

Event Message Structure of Integration Request for API Gateway Trigger

When an API Gateway trigger receives a request, event data will be sent to the bound function in JSON format as shown below. For more information, see API Gateway Trigger.
{
"requestContext": {
"serviceId": "service-f94sy04v",
"path": "/test/{path}",
"httpMethod": "POST",
"requestId": "c6af9ac6-****-****-9a41-93e8deadbeef",
"identity": {
"secretId": "abdcdxxxxxxxsdfs"
},
"sourceIp": "10.0.2.14",
"stage": "release"
},
"headers": {
"Accept-Language": "en-US,en,cn",
"Accept": "text/html,application/xml,application/json",
"Host": "service-3ei3tii4-251000691.ap-guangzhou.apigateway.myqloud.com",
"User-Agent": "User Agent String"
},
"body": "{\\"test\\":\\"body\\"}",
"pathParameters": {
"path": "value"
},
"queryStringParameters": {
"foo": "bar"
},
"headerParameters":{
"Refer": "10.0.2.14"
},
"stageVariables": {
"stage": "release"
},
"path": "/test/value",
"queryString": {
"foo" : "bar",
"bob" : "alice"
},
"httpMethod": "POST"
}

Event Message Structure for Timer Trigger

When a function is invoked at a scheduled time, event data will be sent to the bound function in JSON format as shown below.
{
"Type":"Timer",
"TriggerName":"EveryDay",
"Time":"2019-02-21T11:49:00Z",
"Message":"user define msg body"
}

Event Message Structure for COS Trigger

When an object creation or deletion event occurs in the specified COS bucket, event data will be sent to the bound function in JSON format as shown below. For more information, see COS Trigger.
{
"Records": [{
"cos": {
"cosSchemaVersion": "1.0",
"cosObject": {
"url": "http://testpic-1253970026.cos.ap-chengdu.myqcloud.com/testfile",
"meta": {
"x-cos-request-id": "NWMxOWY4MGFfMjViMjU4NjRfMTUy********ZjM=",
"Content-Type": ""
},
"vid": "",
"key": "/1253970026/testpic/testfile",
"size": 1029
},
"cosBucket": {
"region": "cd",
"name": "testpic",
"appid": "1253970026"
},
"cosNotificationId": "unkown"
},
"event": {
"eventName": "cos:ObjectCreated:*",
"eventVersion": "1.0",
"eventTime": 1545205770,
"eventSource": "qcs::cos",
"requestParameters": {
"requestSourceIP": "192.168.15.101",
"requestHeaders": {
"Authorization": "q-sign-algorithm=******"
}
},
"eventQueue": "qcs:0:lambda:cd:appid/1253970026:default.printevent.$LATEST",
"reservedInfo": "",
"reqid": 179398952
}
}]
}

Event Message Structure for CKafka Trigger

When a specified CKafka topic receives a message, the backend consumption module of SCF will consume the message and encapsulate it into an event in JSON format like the one below, which will trigger the bound function and pass the data content as input parameters to the function. For more information, see CKafka Trigger.
{
"Records": [
{
"Ckafka": {
"topic": "test-topic",
"partition":1,
"offset":36,
"msgKey": "None",
"msgBody": "Hello from Ckafka!"
}
},
{
"Ckafka": {
"topic": "test-topic",
"partition":1,
"offset":37,
"msgKey": "None",
"msgBody": "Hello from Ckafka again!"
}
}
]
}

Event Message Structure for CLS Trigger

When the specified CLS trigger receives a message, the CLS backend consumption module will consume the message and encapsulate it to asynchronously invoke your function. In order to ensure the efficiency of data transfer in a single triggering action, the value of the data field is a Base64-encoded ZIP document. For more information, see CLS Trigger.
{
"clslogs": {
"data": "ewogICAgIm1lc3NhZ2VUeXBlIjogIkRBVEFfTUVTU0FHRSIsCiAgICAib3duZXIiOiAiMTIzNDU2Nzg5MDEyIiwKICAgICJsb2dHcm91cCI6I..."
}
}
After being decoded and decompressed, the log data will look like the following JSON body (using decoded CLS Logs message data as an example):
{
"topic_id": "xxxx-xx-xx-xx-yyyyyyyy",
"topic_name": "testname",
"records": [{
"timestamp": "1605578090000000",
"content": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}, {
"timestamp": "1605578090000003",
"content": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}]
}

Event Message Structure for MPS Trigger

When a specified MPS trigger receives a message, the event structures and fields will be as shown below (with the WorkflowTask task as an example). For more information, see MPS Trigger.
{
"EventType":"WorkflowTask",
"WorkflowTaskEvent":{
"TaskId":"245****654-WorkflowTask-f46dac7fe2436c47******d71946986t0",
"Status":"FINISH",
"ErrCode":0,
"Message":"",
"InputInfo":{
"Type":"COS",
"CosInputInfo":{
"Bucket":"macgzptest-125****654",
"Region":"ap-guangzhou",
"Object":"/dianping2.mp4"
}
},
"MetaData":{
"AudioDuration":11.261677742004395,
"AudioStreamSet":[
{
"Bitrate":127771,
"Codec":"aac",
"SamplingRate":44100
}
],
"Bitrate":2681468,
"Container":"mov,mp4,m4a,3gp,3g2,mj2",
"Duration":11.261677742004395,
"Height":720,
"Rotate":90,
"Size":3539987,
"VideoDuration":10.510889053344727,
"VideoStreamSet":[
{
"Bitrate":2553697,
"Codec":"h264",
"Fps":29,
"Height":720,
"Width":1280
}
],
"Width":1280
},
"MediaProcessResultSet":[
{
"Type":"Transcode",
"TranscodeTask":{
"Status":"SUCCESS",
"ErrCode":0,
"Message":"SUCCESS",
"Input":{
"Definition":10,
"WatermarkSet":[
{
"Definition":515247,
"TextContent":"",
"SvgContent":""
}
],
"OutputStorage":{
"Type":"COS",
"CosOutputStorage":{
"Bucket":"gztest-125****654",
"Region":"ap-guangzhou"
}
},
"OutputObjectPath":"/dasda/dianping2_transcode_10",
"SegmentObjectName":"/dasda/dianping2_transcode_10_{number}",
"ObjectNumberFormat":{
"InitialValue":0,
"Increment":1,
"MinLength":1,
"PlaceHolder":"0"
}
},
"Output":{
"OutputStorage":{
"Type":"COS",
"CosOutputStorage":{
"Bucket":"gztest-125****654",
"Region":"ap-guangzhou"
}
},
"Path":"/dasda/dianping2_transcode_10.mp4",
"Definition":10,
"Bitrate":293022,
"Height":320,
"Width":180,
"Size":401637,
"Duration":11.26200008392334,
"Container":"mov,mp4,m4a,3gp,3g2,mj2",
"Md5":"31dcf904c03d0cd78346a12c25c0acc9",
"VideoStreamSet":[
{
"Bitrate":244608,
"Codec":"h264",
"Fps":24,
"Height":320,
"Width":180
}
],
"AudioStreamSet":[
{
"Bitrate":48414,
"Codec":"aac",
"SamplingRate":44100
}
]
}
},
"AnimatedGraphicTask":null,
"SnapshotByTimeOffsetTask":null,
"SampleSnapshotTask":null,
"ImageSpriteTask":null
},
{
"Type":"AnimatedGraphics",
"TranscodeTask":null,
"AnimatedGraphicTask":{
"Status":"FAIL",
"ErrCode":30010,
"Message":"TencentVodPlatErr Or Unkown",
"Input":{
"Definition":20000,
"StartTimeOffset":0,
"EndTimeOffset":600,
"OutputStorage":{
"Type":"COS",
"CosOutputStorage":{
"Bucket":"gztest-125****654",
"Region":"ap-guangzhou"
}
},
"OutputObjectPath":"/dasda/dianping2_animatedGraphic_20000"
},
"Output":null
},
"SnapshotByTimeOffsetTask":null,
"SampleSnapshotTask":null,
"ImageSpriteTask":null
},
{
"Type":"SnapshotByTimeOffset",
"TranscodeTask":null,
"AnimatedGraphicTask":null,
"SnapshotByTimeOffsetTask":{
"Status":"SUCCESS",
"ErrCode":0,
"Message":"SUCCESS",
"Input":{
"Definition":10,
"TimeOffsetSet":[

],
"WatermarkSet":[
{
"Definition":515247,
"TextContent":"",
"SvgContent":""
}
],
"OutputStorage":{
"Type":"COS",
"CosOutputStorage":{
"Bucket":"gztest-125****654",
"Region":"ap-guangzhou"
}
},
"OutputObjectPath":"/dasda/dianping2_snapshotByOffset_10_{number}",
"ObjectNumberFormat":{
"InitialValue":0,
"Increment":1,
"MinLength":1,
"PlaceHolder":"0"
}
},
"Output":{
"Storage":{
"Type":"COS",
"CosOutputStorage":{
"Bucket":"gztest-125****654",
"Region":"ap-guangzhou"
}
},
"Definition":0,
"PicInfoSet":[
{
"TimeOffset":0,
"Path":"/dasda/dianping2_snapshotByOffset_10_0.jpg",
"WaterMarkDefinition":[
515247
]
}
]
}
},
"SampleSnapshotTask":null,
"ImageSpriteTask":null
},
{
"Type":"ImageSprites",
"TranscodeTask":null,
"AnimatedGraphicTask":null,
"SnapshotByTimeOffsetTask":null,
"SampleSnapshotTask":null,
"ImageSpriteTask":{
"Status":"SUCCESS",
"ErrCode":0,
"Message":"SUCCESS",
"Input":{
"Definition":10,
"OutputStorage":{
"Type":"COS",
"CosOutputStorage":{
"Bucket":"gztest-125****654",
"Region":"ap-guangzhou"
}
},
"OutputObjectPath":"/dasda/dianping2_imageSprite_10_{number}",
"WebVttObjectName":"/dasda/dianping2_imageSprite_10",
"ObjectNumberFormat":{
"InitialValue":0,
"Increment":1,
"MinLength":1,
"PlaceHolder":"0"
}
},
"Output":{
"Storage":{
"Type":"COS",
"CosOutputStorage":{
"Bucket":"gztest-125****654",
"Region":"ap-guangzhou"
}
},
"Definition":10,
"Height":80,
"Width":142,
"TotalCount":2,
"ImagePathSet":[
"/dasda/imageSprite/dianping2_imageSprite_10_0.jpg"
],
"WebVttPath":"/dasda/imageSprite/dianping2_imageSprite_10.vtt"
}
}
}
]
}
}

Event Message Structure for CLB Trigger

When a CLB trigger receives a request, event data will be sent to the bound function in JSON format as shown below. For more information, see CLB Trigger Description.
{  
  "headers": { 
    "Content-type": "application/json",  
    "Host": "test.clb-scf.com",  
    "User-Agent": "Chrome",  

    "X-Stgw-Time": "1591692977.774",  
    "X-Client-Proto": "http",  
    "X-Forwarded-Proto": "http",  
    "X-Client-Proto-Ver": "HTTP/1.1",  
  "X-Real-IP": "9.43.175.219",
    "X-Forwarded-For": "9.43.175.xx"  

    "X-Vip": "121.23.21.xx",  
    "X-Vport": "xx",  
    "X-Uri": "/scf_location",  
    "X-Method": "POST"    
    "X-Real-Port": "44347",  
  },  
  "payload": {  
    "key1": "123",  
    "key2": "abc"  
  },
"isBase64Encoded": "false"
}  

Event Message Structure for EventBridge Trigger

With EventBridge, you can further expand the function event trigger sources and send events generated by EventBridge to SCF in the following form, where the content of the "data" field is determined by the event source. Here, TDMQ is used as an example:
{
"specversion": "0",
"id": "13a3f42d-7258-4ada-da6d-023a33******",
"type": "connector:tdmq",
"source": "tdmq.cloud.tencent",
"subjuect": "qcs::tdmq:$region:$account:topicName/$topicSets.clusterId/$topicSets.environmentId/$topicSets.topicName/$topicSets.subscriptionName",
"time": "1615430559146",
"region": "ap-guangzhou",
"datacontenttype": "application/json;charset=utf-8",
"data": {
"topic": "persistent://appid/namespace/topic-1",
"tags": "testtopic",
"TopicType": "0",
"subscriptionName": "xxxxxx",
"toTimestamp": "1603352765001",
"partitions": "0",
"msgId": "123345346",
"msgBody": "Hello from TDMQ!"
}


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック