Help Center> FunctionGraph> Developer Guide> Overview> Supported Event Sources

Supported Event Sources

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.

DMS

Distributed Message Service (DMS) is a message queuing service that enables communication between distributed applications. If you create a function with a DMS trigger, messages automatically polled from a specified queue will be passed as a parameter (DMS example event) to invoke the function. For details, see Using a DMS 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.

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 Using a DIS Trigger.

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.

DDS

Document Database Service (DDS) is a MongoDB-compatible database service that provides a variety of functions including DB instance creation with a few clicks, scaling, disaster recovery, backup, restoration, and monitoring. If you create a DDS trigger for a function, any updates to the specified database table will trigger the function. For details, see Using a DDS 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.

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)"
    }

  • DMS example event

    In the following example, the function name is test. Messages is the message body, which includes Body and Attributes. The event also includes a queue ID and consumer group ID.

    {
        "Tag": "latest",
        "QueueID": "48d11a53-e498-4964-84a2-aaa56442d5ca",
        "ConsumerGroupID": "g-61d9d290-7dae-4144-9ce7-00b9f159cdbe",
        "Messages": [{
            "Body": "This is dms trigger body",
            "Attributes": {
                "dmstrigger": "dmstrigger",
                "dmstrigger2": "dmstrigger"
            }
        }],
        "functionname": "test",
        "requestId": "57453335-ccf7-4d43-8639-79d108158749",
        "timestamp": "Wed Nov 15 2017 14:26:10 GMT+0800 (CST)"
    }
  • API Gateway example event

    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": "eyJsb2dzIjpbIntcIm1lc3NhZ2VcIjpcIjIwMTgtMDYtMjYvMTg6NDA6NTMgW0lORl0gW2NvbmZpZy5nbzo3Ml0gU3VjY2Vzc2Z1bGx5IGxvYWRlZCBnZW5lcmFsIGNvbmZpZ3VyYXRpb24gZmlsZVxcclxcblwiLFwidGltZVwiOjE1MzAwMDk2NTMwNTksXCJob3N0X25hbWVcIjpcImVjcy10ZXN0YWdlbnQubm92YWxvY2FsXCIsXCJpcFwiOlwiMTkyLjE2OC4xLjk4XCIsXCJwYXRoXCI6XCIvdXNyL2xvY2FsL3RlbGVzY29wZS9sb2cvY29tbW9uLmxvZ1wiLFwibG9nX3VpZFwiOlwiNjYzZDY5MzAtNzkyZC0xMWU4LThiMDgtMjg2ZWQ0ODhjZTcwXCIsXCJsaW5lX25vXCI6NjE1fSIsIntcIm1lc3NhZ2VcIjpcIjIwMTgtMDYtMjYvMTg6NDA6NTMgW1dSTl0gW2NvbmZpZy5nbzo4Ml0gVGhlIHByb2plY3RJZCBvciBpbnN0YW5jZUlkIG9mIGNvbmZpZy5qc29uIGlzIG5vdCBjb25zaXN0ZW50IHdpdGggbWV0YWRhdGEsIHVzZSBtZXRhZGF0YS5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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"
    	}
    }
  • DDS example event
    {
    	"records": [
    		{
    			"event_source": "dds",
    			"event_name": "insert",
    			"region": "xx-xxxxx-x",
    			"event_version": "1.0",
    			"dds": {
    				"size_bytes": "100",
    				"token": {
                        "_data": "825D8C2F4D0000001529295A100474039A3412A64BA89041DC952357FB4446645F696400645D8C2F8E5BECCB6CF5370D6A0004"
                    },
    				"full_document": {
    					"_id": {
    						"$oid": "5d8c2f8e5beccb6cf5370d6a"
    					},
    					"name": "dds",
    					"age": {
    						"$numberDouble": "52.0"
    					}
    				},
    				"ns": {
    				   "db": "functiongraph",
    				   "coll": "person"
    				}
    			},
    			"event_source_id": "e6065860-f7b8-4cca-80bd-24ef2a3bb748"
    		}
    	]
    }
  • 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"
    }