Updated on 2024-05-09 GMT+08:00

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.

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.

Table 1 Event types supported by OBS

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.

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.

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
    {
        "record": [
            {
                "event_version": "1.0",
                "smn": {
                    "topic_urn": "urn:smn:{region}:0162c0f220284698b77a3d264376343a:{function_name}",
                    "timestamp": "2018-01-09T07:11:40Z",
                    "message_attributes": null,
                    "message": "this is smn message content",
                    "type": "notification",
                    "message_id": "a51671f77d4a479cacb09e2cd591a983",
                    "subject": "this is smn message subject"
                },
                "event_subscription_urn": "urn:fss:{region}:0162c0f220284698b77a3d264376343a:function:default:read-smn-message:latest",
                "event_source": "smn"
            }
    ],
        "functionname": "test",
        "requestId": "7c307f6a-cf68-4e65-8be0-4c77405a1b2c",
        "timestamp": "Wed Nov 15 2017 12:00:00 GMT+0800 (CST)"
    }
    Table 2 Parameter description

    Parameter

    Type

    Example Value

    Description

    event_version

    String

    1.0

    Event version

    topic_urn

    String

    See the example.

    ID of an SMN event

    type

    String

    notification

    Event type

    RequestID

    String

    7c307f6a-cf68-4e65-8be0-4c77405a1b2c

    Request ID. The ID of each request is unique.

    message_id

    String

    a51671f77d4a479cacb09e2cd591a983

    Message ID. The ID of each message is unique.

    Message

    String

    this is smn message content

    Message content

    event_source

    String

    smn

    Event source

    event_subscription_urn

    String

    See the example.

    Subscription ID

    timestamp

    String

    Wed Nov 15 2017 12:00:00 GMT+0800 (CST)

    Time when an event occurs

  • OBS example event
    {
        "Records": [
            {
                "eventVersion": "2.0",
                "eventTime": "2018-01-09T07:50:50.028Z",
                "requestParameters": {
                    "sourceIPAddress": "103.218.216.125"
                },
                "s3": {
                    "configurationId": "UK1DGFPYUKUZFHNQ00000160CC0B471D101ED30CE24DF4DB",
                    "object": {
                        "eTag": "9d377b10ce778c4938b3c7e2c63a229a",
                        "sequencer": "00000000160D9E681484D6B4C0000000",
                        "key": "job.png",
                        "size": 777835
                    },
                    "bucket": {
                        
                        "name": "functionstorage-template",
                        "ownerIdentity": {
                            "PrincipalId": "0ed1b73473f24134a478962e631651eb"
                        }
                    }
                },
                "Region": "{region}",
                "eventName": "ObjectCreated:Post",
                "userIdentity": {
                    "principalId": "9bf43789b1ff4b679040f35cc4f0dc05"
                }
            }
        ]
    }
    Table 3 Parameter description

    Parameter

    Type

    Example Value

    Description

    eventVersion

    String

    2.0

    Event version

    eventTime

    String

    2018-01-09T07:50:50.028Z

    Time when an event occurs. The ISO-8601 time format is used.

    sourceIPAddress

    String

    103.218.216.125

    Source IP address

    s3

    Map

    See the example.

    OBS event content

    object

    Map

    See the example.

    object parameter description

    bucket

    Map

    See the example.

    bucket parameter description

    ownerIdentity

    Map

    See the example.

    ID of the user who creates the bucket

    Region

    String

    -ae-ad-1

    Region where the bucket is located

    eventName

    String

    ObjectCreated:Post

    Event name

    userIdentity

    Map

    See the example.

    ID of the account that initiates the request

  • Timer example event
    {
        "version": "v1.0",
        "time": "2018-06-01T08:30:00+08:00",
        "trigger_type": "TIMER",
        "trigger_name": "Timer_001",
        "user_event": "User Event"
    }
    Table 4 Parameter description

    Parameter

    Type

    Example Value

    Description

    version

    String

    V1.0

    Event version

    time

    String

    2018-06-01T08:30:00+08:00

    Time when an event occurs.

    trigger_type

    String

    TIMER

    Trigger type

    trigger_name

    String

    Timer_001

    Trigger name

    user_event

    String

    User Event

    Additional information of the trigger

  • LTS example event
    {
        "lts": {
            "data": "ICB7CiAgICAibG9ncyI6W3sKICAgICAgICAgIm1lc3NhZ2UiOiIyMDE4LTA4LTA4LzA4OjA4OjA4IFtXUk5dIFt0ZXN0LmdvOjA4XVRoaXMgaXMgYSB0ZXN0IG1lc3NhZ2UuIiwKICAgICAgICAgInRpbWUiOjE1MzAwMDk2NTMwNTksCiAgICAgICAgICJob3N0X25hbWUiOiJlY3MtdGVzdCIsCiAgICAgICAgICJpcCI6IjE5Mi4xNjguMS4xIiwKICAgICAgICAgInBhdGgiOiJ2YXIvbG9nL3Rlc3QubG9nIiwKICAgICAgICAgImxvZ191aWQiOiI2NjNkNjkzMC03OTJkLTExZTgtOGIwOC0yODZlZDQ4OGNlNzAiLAogICAgICAgICAibGluZV9ubyI6MQogICAgIH1dLAogICAgIm93bmVyIjogIjYyODBlMTcwYmQ5MzRmNjBhNGQ4NTFjZjVjYTA1MTI5IiwKICAgICJsb2dfZ3JvdXBfaWQiOiAiOTdhOWQyODQtNDQ0OC0xMWU4LThmYTQtMjg2ZWQ0ODhjZTcwIiwKICAgICJsb2dfdG9waWNfaWQiOiAiMWE5Njc1YTctNzg0ZC0xMWU4LTlmNzAtMjg2ZWQ0ODhjZTcwIgogfQ=="
        }
    }
    Table 5 Event parameter description

    Parameter

    Type

    Example Value

    Description

    data

    Sting

    See the example.

    Base64-encoded data

  • Kafka example event
    {
        "event_version": "v1.0",
        "event_time": 1576737962,
        "trigger_type": "KAFKA",
        "region": "{region}",
        "instance_id": "81335d56-b9fe-4679-ba95-7030949cc76b",
        "records": [
            {
                "messages": [
                    "kafka message1",
                    "kafka message2",
                    "kafka message3",
                    "kafka message4",
                    "kafka message5"
                ],
                "topic_id": "topic-test"
            }
        ]
    }
    Table 6 Parameter description

    Parameter

    Type

    Example Value

    Description

    event_version

    String

    v1.0

    Event version

    event_time

    String

    2018-01-09T07:50:50.028Z

    Time when an event occurs

    trigger_type

    String

    KAFKA

    Event type

    region

    String

    ae-ad-1

    Region where a Kafka instance resides

    instance_id

    String

    81335d56-b9fe-4679-ba95-7030949cc76b

    Kafka instance ID

    messages

    String

    See the example.

    Message content

    topic_id

    String

    topic-test

    Message ID

  • 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 7 Parameter description

    Parameter

    Type

    Example Value

    Description

    event_version

    String

    v1.0

    Event version

    Region

    String

    ae-ad-1

    Region where a RabbitMQ instance resides

    instance_id

    String

    81335d56-b9fe-4679-ba95-7030949cc76b

    RabbitMQ instance ID