This section describes the cloud services that can be configured as event sources for your FunctionGraph functions. After you preconfigure the event source mapping, these event sources automatically invoke the relevant function when detecting events.
SMN
Simple Message Notification (SMN) sends messages to email addresses, mobile phones, or HTTP/HTTPS URLs. If you create a function with an SMN trigger, messages published to a specified topic will be passed as a parameter (SMN example event) to invoke the function. Then, the function processes the event, for example, publishing messages to other SMN topics or sending them to other cloud services. For details, see Using an SMN Trigger.
API Gateway
API Gateway is an API hosting service that helps enterprises to build, manage, and deploy APIs at any scale. With API Gateway, your function can be invoked through HTTPS by using a custom REST API and a specified backend. You can map each API operation (such as, GET and PUT) to a specific function. API Gateway invokes the relevant function when an HTTPS request (API Gateway example event) is sent to the API backend. For details, see Using an APIG Trigger.
OBS
Object Storage Service (OBS) is a stable, secure, efficient, and easy-to-use cloud storage service. You can create a function to process OBS bucket events, for example, creating and deleting objects. When an image is uploaded to a specified bucket, OBS invokes the function to read the image and create a thumbnail. For details, see Using an OBS Trigger.
Event | Description |
---|---|
ObjectCreated | All kinds of object creation operations, including PUT, POST, and COPY of objects, as well as the merging of parts. |
Put | Use the PUT method to upload objects. |
Post | Use the POST method to upload objects. |
Copy | Use the COPY method to replicate objects. |
CompleteMultipartUpload | Merge parts of multi-part tasks. |
ObjectRemoved | Delete objects. |
Delete | Delete objects by versions. |
DeleteMarkerCreated | Delete objects without specifying versions. |
Multiple event types can be used on the same object. For example, if you have selected Put, Copy, and Delete in an event notification rule, a notification message will be sent to you when the specified object is uploaded to, copied to, or deleted from the bucket. ObjectCreated contains Put, Post, Copy, and CompleteMultipartUpload. If you select ObjectCreated, the others are automatically selected and cannot be selected again. Similarly, if you select ObjectRemoved, Delete and DeleteMarkerCreated are automatically selected and cannot be selected again.
DIS
Data Ingestion Service (DIS) can ingest large amounts of data in real time. You can create a function to automatically poll a DIS stream and process all new data records, such as website click streams, financial transactions, social media streams, IT logs, and location-tracking events (DIS example event). FunctionGraph periodically polls the stream for new data records. For details, see .
Timer
You can schedule a timer (timer example event) to invoke your code based on a fixed rate of minutes, hours, or days or a cron expression. For details, see Using a Timer Trigger.
LTS
Log Tank Service (LTS) collects and stores logs, allowing you to query them in real time. If you create a function with an LTS trigger, subscribed logs collected by LTS will be passed as a parameter (LTS example event) to invoke the function. Then, the function processes or analyzes the logs, or loads the logs to other systems. For details, see Using an LTS Trigger.
CTS
Cloud Trace Service (CTS) collects operation records of subscribed cloud resources. If you create a function with a CTS trigger, collected operation records of specified cloud services will be passed as a parameter (CTS example event) to invoke the function. Then, the function analyzes and processes key information in the operation records, automatically recovers system or network modules, or reports alarms to service personnel by SMS or email. For details, see Using a CTS Trigger.
DMS for Kafka
DMS for Kafka is a message queuing service that provides Kafka premium instances. If you create a Kafka trigger for a function, when a message is sent to a Kafka instance topic, FunctionGraph will retrieve the message and trigger the function to perform other operations. For details, see Using a Kafka Trigger.
Cloud Eye
Cloud Eye is a multi-dimensional resource monitoring platform. FunctionGraph is interconnected with Cloud Eye to report metrics, allowing you to view function metrics and alarm messages through Cloud Eye. For more information about metrics, see Viewing Function Metrics.
DMS for RabbitMQ
When a DMS (for RabbitMQ) trigger is used, FunctionGraph periodically polls for new messages in a specific topic bound to the exchange of a RabbitMQ instance and passes the messages as input parameters to invoke functions.
Example Events
- SMN example event
In the following example, the function name is test and the topic name is serverless_Test. subject is the message header, and message is the message body.
{"record": [{"event_version": "1.0","smn": {"message_attributes": null,"subject": "This is the message title of smn trigger","message_id": "a5dbd701d70d4ac2a153e7dd6dd9b601","topic_urn": "urn:smn:xx-xxxxx-x:bb8695913bb74682b9ca82a8803b60d8:serverless_Test","type": "notification","message": "This is the message body of smn trigger","timestamp": "2017-11-15T04:02:24Z"},"event_source": "smn","event_subscription_urn": "urn:fss:xx-xxxxx-xxx:bb8695913bb74682b9ca82a8803b60d8:function:default:obsTrigger-Test1:latest"}],"functionname": "test","requestId": "7c307f6a-cf68-4e65-8be0-4c77405a1b2c","timestamp": "Wed Nov 15 2017 12:00:00 GMT+0800 (CST)"} - API Gateway example eventNote
When a function is invoked due to an API Gateway event, the request body is encrypted by default.
{"httpMethod": "GET", //Request method"path": "/test/hello", //Request path"pathParameters": { //Path parameters"proxy": "hello"},"queryStringParameters": { //Query parameters"name": "me"},"headers": { //Request header"x-stage": "RELEASE","Host": "3f96e175-d5e4-4d4b-ae7e-f6d264e63b23-apigw.xx-xxx-x.xxx.com","User-Agent": "lua-resty-http/0.10 (Lua) ngx_lua/10008",...},"body": "...", //Request body"isBase64Encoded":false/true, //Indicates whether the request body is encoded using Base64."requestContext": {"stage": "test", //Environment name"requestId": "dd4337362c02c7d77299e78781beb4b1","apiId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9"},}The function returns characters strings by using the following structure.
{"isBase64Encoded": true|false,"statusCode": httpStatusCode,"headers": {"headerName":"headerValue",...},"body": "..."} - DIS example event
In the following example, the stream name is dis-swtest. This example shows the format of a request received by a function associated with the DIS trigger.
{"ShardID": "shardId-0000000000","Message": {"next_partition_cursor": "eyJnZXRJdGVyYXRvclBhcmFtIjp7InN0cmVhbS1uYW1lIjoiZGlzLXN3dGVzdCIsInBhcnRpdGlvbi1pZCI6InNoYXJkSWQtMDAwMDAwMDAwMCIsImN1cnNvci10eXBlIjoiVFJJTV9IT1JJWk9OIiwic3RhcnRpbmctc2VxdWVuY2UtbnVtYmVyIjoiNCJ9LCJnZW5lcmF0ZVRpbWVzdGFtcCI6MTUwOTYwNjM5MjE5MX0","records": [{"partition_key": "shardId_0000000000","data": "PEJ1ZmZlcj48L0J1ZmZlcj4=","sequence_number": "0"},{"partition_key": "shardId_0000000000","data": "PEJ1ZmZlcj48L0J1ZmZlcj4=","sequence_number": "1"},{"partition_key": "shardId_0000000000","data": "PEJ1ZmZlcj48L0J1ZmZlcj4=","sequence_number": "2"},{"partition_key": "shardId_0000000000","data": "PEJ1ZmZlcj48L0J1ZmZlcj4=","sequence_number": "3"}],"millis_behind_latest": ""},"Tag": "latest","StreamName": "dis-swtest"} - Timer example event{"version": "v1.0","time": "2006-01-02T15:04:05-07:00", // Local time"trigger_type": "TIMER", // Trigger type"trigger_name": "Trigger name""user_event": "User-defined event" //Event configured when the timer trigger is created}
- LTS example event{"lts": {"data": "eyJsb2dzIjpbIntcIm1lc3NhZ2VcIjpcIjIwMTgtMDYtMjYvMTg6NDA6NTMgW0lORl0gW2NvbmZpZy5nbzo3Ml0gU3VjY2Vzc2Z1bGx5IGxvYWRlZCBnZW5lcmFsIGNvbmZpZ3VyYXRpb24gZmlsZVxcclxcblwiLFwidGltZVwiOjE1MzAwMDk2NTMwNTksXCJob3N0X25hbWVcIjpcImVjcy10ZXN0YWdlbnQubm92YWxvY2FsXCIsXCJpcFwiOlwiMTkyLjE2OC4xLjk4XCIsXCJwYXRoXCI6XCIvdXNyL2xvY2FsL3RlbGVzY29wZS9sb2cvY29tbW9uLmxvZ1wiLFwibG9nX3VpZFwiOlwiNjYzZDY5MzAtNzkyZC0xMWU4LThiMDgtMjg2ZWQ0ODhjZTcwXCIsXCJsaW5lX25vXCI6NjE1fSIsIntcIm1lc3NhZ2VcIjpcIjIwMTgtMDYtMjYvMTg6NDA6NTMgW1dSTl0gW2NvbmZpZy5nbzo4Ml0gVGhlIHByb2plY3RJZCBvciBpbnN0YW5jZUlkIG9mIGNvbmZpZy5qc29uIGlzIG5vdCBjb25zaXN0ZW50IHdpdGggbWV0YWRhdGEsIHVzZSBtZXRhZGF0YS5cXG5cIixcInRpbWVcIjoxNTMwMDA5NjUzMDU5LFwiaG9zdF9uYW1lXCI6XCJlY3MtdGVzdGFnZW50Lm5vdmFsb2NhbFwiLFwiaXBcIjpcIjE5Mi4xNjguMS45OFwiLFwicGF0aFwiOlwiL3Vzci9sb2NhbC90ZWxlc2NvcGUvbG9nL2NvbW1vbi5sb2dcIixcImxvZ191aWRcIjpcIjY2M2Q2OTMwLTc5MmQtMTFlOC04YjA5LTI4NmVkNDg4Y2U3MFwiLFwibGluZV9ub1wiOjYxNn0iLCJ7XCJtZXNzYWdlXCI6XCIgSW4gY29uZi5qc29uLCBwcm9qZWN0SWQgaXMgW10sIGluc3RhbmNlSWQgaXMgW10uIE1ldGFEYXRhIGlzIHs0NTQzMjkzYS01YjJjLTQ0YzQtYjdhMC1kZTIxOGY3ZjJmYTYgNjI4MGUxNzBiZDkzNGY2MGE0ZDg1MWNmNWNhMDUxMjkgIH1cXHJcXG5cIixcInRpbWVcIjoxNTMwMDA5NjUzMDU5LFwiaG9zdF9uYW1lXCI6XCJlY3MtdGVzdGFnZW50Lm5vdmFsb2NhbFwiLFwiaXBcIjpcIjE5Mi4xNjguMS45OFwiLFwicGF0aFwiOlwiL3Vzci9sb2NhbC90ZWxlc2NvcGUvbG9nL2NvbW1vbi5sb2dcIixcImxvZ191aWRcIjpcIjY2M2Q2OTMwLTc5MmQtMTFlOC04YjBhLTI4NmVkNDg4Y2U3MFwiLFwibGluZV9ub1wiOjYxN30iXSwib3duZXIiOiI2MjgwZTE3MGJkOTM0ZjYwYTRkODUxY2Y1Y2EwNTEyOSIsImxvZ19ncm91cF9pZCI6Ijk3YTlkMjg0LTQ0NDgtMTFlOC04ZmE0LTI4NmVkNDg4Y2U3MCIsImxvZ190b3BpY19pZCI6IjFhOTY3NWE3LTc4NGQtMTFlOC05ZjcwLTI4NmVkNDg4Y2U3MCJ9"}}
- CTS example event{"cts": {"time": "2018/06/26 08:54:07 GMT+08:00", //Timestamp of the sender"user": { //Information about the user that initiates the request"name": "userName","id": "5b726c4fbfd84821ba866bafaaf56aax","domain": {"name": "domainName","id": "b2b3853af40448fcb9e40dxj89505ba"}},"request": {}, //Content of the trace request"response": {}, //Content of the trace response"code": 204, //Trace response codes, such as, 200 or 400"service_type": "FunctionGraph", //Name of the sender in abbreviated form, such as VPC and ECS"resource_type": "graph", //Resource type of the sender, such as VM and VPN"resource_name": "workflow-2be1", //Resource name, for example, the name of a VM on Elastic Cloud Server (ECS)"resource_id": "urn:fgs:xx-xxx-x:2d1d891d93054bbaa69b9e866c0971ac:graph:workflow-2be1", //Resource ID, for example, the ID of a VM on ECS"trace_name": "deleteGraph", //Trace name, such as startServer and shutDown"trace_type": "ConsoleAction", //Type of the trace source, such as ApiCall"record_time": "2018/06/26 08:54:07 GMT+08:00", //Time when CTS receives the trace"trace_id": "69be64a7-0233-11e8-82e4-e5d37911193e", //Trace ID"trace_status": "normal"}}
- Kafka example event{"event_version": "v1.0","event_time": 1576737962,"trigger_type": "KAFKA","region": "xx-xxxx-x","messages": ["kafka message1","kafka message2","kafka message3","kafka message4","kafka message5"],"instance_id": "81335d56-b9fe-4679-ba95-7030949cc76b","topic_id": "topic-test"}
- RabbitMQ example event{"event_version": "v1.0","event_time": 1576737962,"trigger_type": "RABBITMQ","region": "{region}","records": [{"messages": ["rabbitmq message1","rabbitmq message2","rabbitmq message3","rabbitmq message4","rabbitmq message5"],"instance_id": "81335d56-b9fe-4679-ba95-7030949cc76b","exchange": "exchange-test"}]}
Table 2 Parameters Parameter
Type
Example Value
Description
event_version
String
v1.0
Event version
Region
String
ru-moscow-1
Region where a RabbitMQ instance resides
instance_id
String
81335d56-b9fe-4679-ba95-7030949cc76b
RabbitMQ instance ID
- SMN
- API Gateway
- OBS
- DIS
- Timer
- LTS
- CTS
- DMS for Kafka
- Cloud Eye
- DMS for RabbitMQ
- Example Events