Updated on 2025-11-10 GMT+08:00

EG-based Event Notifications

Scenarios

If you want operations performed on a bucket or its objects to be promptly detected and trigger subsequent operations, you can configure EventGrid (EG) event notifications.

For example, you can configure EG event notifications to automatically add watermarks to images uploaded to the source bucket and store the watermarked images to the target bucket.

How OBS Works with EG

OBS can store data such as files, images, and videos. Operations such as uploading, modifying, or deleting these objects can generate OBS events. After capturing OBS events, EventGrid (EG) automatically triggers subsequent operations or processes based on the configured rules. OBS automatically sends notifications, and EG automatically dispatches tasks, eliminating the need for manual intervention.

EG consists of the event source, channel, and event target:

  • Event source: cloud service events generated when users request to operate cloud service resources
  • Channel: the transfer station that receives events from cloud services
  • Event target: the destination that processes events. Cloud service events from the channel can trigger other cloud services to perform operations. (For example, FunctionGraph can be triggered to add watermarks to images and store the images to OBS buckets.)

Figure 1 shows how OBS works with EG.

Figure 1 EG-enabled event notification

The process of using OBS together with EG is as follows:

  1. An administrator creates an EG notification rule and configures the event source, channel, and event target.
  2. When the administrator or other users perform operations on objects in OBS buckets, OBS events are generated as the event source.
  3. EG pushes the event source to the event target through the channel, and the event target triggers other cloud services to perform subsequent operations.

Event Types Supported by OBS

EG notifications support two types of OBS event sources: OBS Application Servicve and Object Storage Service (OBS).

  • OBS Application Service: events about specific operations on bucket objects from OBS
  • Object Storage Service (OBS): events about bucket and system operations from OBS
Table 1 OBS event types supported by EG notifications

OBS Event Source Type

EG Event Type

Description

OBS Application Service

OBS:DWR:ObjectCreated:PUT

Uploading an object using PUT

OBS:DWR:ObjectCreated:POST

Uploading an object using POST

OBS:DWR:ObjectCreated:COPY

Copying an object

OBS:DWR:ObjectCreated:CompleteMultipartUpload

Assembling parts in a multipart upload

Object Storage Service (OBS)

OBS:CloudTrace:ApiCall

Audit log events generated due to operations triggered by calling API Gateway

OBS:CloudTrace:ObsSDK

Audit log events generated due to operations on OBS buckets triggered by calling OBS SDKs

OBS:CloudTrace:ConsoleAction

Audit log events generated due to operations performed on the console

OBS:CloudTrace:SystemAction

Audit log events generated due to operations triggered internally

OBS:CloudTrace:Others

Audit log events generated due to operations except those on OBS buckets triggered by calling SDKs

OBS Event Notification Message Structure

After an OBS event is generated due to an operation on a bucket's object, OBS sends an event notification in a fixed message structure (JSON format) to EG. Upon receiving the notification, EG triggers other cloud services to perform operations.

An event notification sent by OBS to EG is a message in the following JSON structure:

{
    channel_id: "a1b2c3d4e5f678901234567890abcdef",
    events: [
        {
            specversion: "1.0",
            id: "17793124-84s5-5e1c-9s20-8fes5s8b54wf",
            source: "HC.OBS.DWR",
            type: "OBS:DWR:ObjectCreated:PUT",
            datacontenttype: "application/json",
            dataschema: "",
            subject: "exampleobject",
            time: "Fri, 04 Jul 2025 06:08:01 GMT",
            ttl: "4000",
            data: {                             
                eventVersion: "3.0",
                eventSource: "OBS",
                eventRegion: "cn-east-3",
                eventTime: "2025-7-04T06:08:01.957Z",
                eventName: "ObjectCreated:PUT",
                userIdentity: {
                    ID: "08b4efe0fc00d3ce0f17c01b948f6e80"
                },
                requestParameters: {
                    sourceIPAddress: "x.x.x.x"
                },
                responseElements: {
                    x-obs-request-id: "000001980D3CC5B5024FE333FEB97E7F",
                    x-obs-id-2: "",
                },
                obs: {
                    Version: "1.0",
                    configurationId: "test-trigger",
                    bucket: {
                        name: "examplebucket",
                        ownerIdentity: {
                            ID: "08b4efe0fc00d3ce0f17c01b948f6e80",
                        },
                        bucket: "examplebucket"
                    },
                    object: {
                        key: "exampleobject",
                        eTag: "65a8e27d8879283831b664bd8b7f0ad4",
                        size: "1024",
                        versionId: 9876543210987654321,
                        sequencer: "1",
                        oldpsxpth: ""
                    }
                }
            }
        },
    ]
}

The fields are as follows:

Table 2 Fields in an EG event notification message

Field

Description

channel_id

Unique identifier of the EG event channel

events[].specversion

Version of the EG event specification

events[].id

Unique identifier of the EG event

events[].source

Source service name of the EG event. The value is fixed at HC.OBS.DWR.

events[].type

EG event type. The value is a character string separated by commas (,).

events[].datacontenttype

Content type of the EG event data. The value is fixed at application/json.

events[].dataschema

Pattern of the EG event data

events[].subject

Object name

events[].time

Time when the EG event occurs. The UTC time format is used.

events[].ttl

Validity period of the EG event. The default value is 4 seconds.

events[].data.eventVersion

Version of the OBS message

events[].data.eventSource

Message source. The value is fixed at OBS.

events[].data.eventRegion

Region where the event occurs

events[].data.eventTime

Event time. The ISO-8601 format is used.

events[].data.eventName

Name of the event that triggers the notification

events[].data.userIdentity.ID

Billing ID of the user who triggers the event

events[].data.requestParameters.sourceIPAddress

Request source IP address

events[].data.responseElements.x-obs-request-id

Request ID

events[].data.responseElements.x-obs-id-2

Special symbol that helps troubleshoot faults

events[].data.obs.Version

OBS version

events[].data.obs.configurationId

Name of the OBS event trigger that matches the event

events[].data.obs.bucket.name

Bucket name

events[].data.obs.bucket.ownerIdentity.ID

Account ID of the bucket owner

events[].data.obs.bucket.bucket

Bucket name

events[].data.obs.object.key

Object name

events[].data.obs.object.eTag

Object ETag

events[].data.obs.object.size

Object size

events[].data.obs.object.versionId

Object version ID

events[].data.obs.object.sequencer

Identifier that determines the event sequence of a specific object

events[].data.obs.object.oldpsxpth

Path of the file before being renamed in the parallel file system

  • Uploading an object
    {
        channel_id: "a1b2c3d4e5f678901234567890abcdef",
        events: [
            {
                specversion: "1.0",
                id: "17793124-84s5-5e1c-9s20-8fes5s8b54wf",
                source: "HC.OBS.DWR",
                type: "OBS:DWR:ObjectCreated:PUT",
                datacontenttype: "application/json",
                dataschema: "",
                subject: "exampleobject",
                time: "Fri, 04 Jul 2025 06:08:01 GMT",
                ttl: "4000",
                data: {                             
                    eventVersion: "3.0",
                    eventSource: "OBS",
                    eventRegion: "cn-east-3",
                    eventTime: "2025-7-04T06:08:01.957Z",
                    eventName: "ObjectCreated:PUT",
                    userIdentity: {
                        ID: "08b4efe0fc00d3ce0f17c01b948f6e80"
                    },
                    requestParameters: {
                        sourceIPAddress: "x.x.x.x"
                    },
                    responseElements: {
                        x-obs-request-id: "000001980D3CC5B5024FE333FEB97E7F",
                        x-obs-id-2: "",
                    },
                    obs: {
                        Version: "1.0",
                        configurationId: "test-trigger",
                        bucket: {
                            name: "examplebucket",
                            ownerIdentity: {
                                ID: "08b4efe0fc00d3ce0f17c01b948f6e80",
                            },
                            bucket: "examplebucket"
                        },
                        object: {
                            key: "exampleobject",
                            eTag: "65a8e27d8879283831b664bd8b7f0ad4",
                            size: "1024",
                            versionId: 9876543210987654321,
                            sequencer: "1",
                            oldpsxpth: ""
                        }
                    }
                }
            },
        ]
    }
  • Deleting an object (manually)
    {
        channel_id: "a1b2c3d4e5f678901234567890abcdef",
        events: [
            {
                specversion: "1.0",
                id: "17793124-84s5-5e1c-9s20-8fes5s8b54wf",
                source: "HC.OBS.DWR",
                type: "OBS:DWR:ObjectRemoved:Delete",
                datacontenttype: "application/json",
                dataschema: "",
                subject: "exampleobject",
                time: "Fri, 04 Jul 2025 06:08:01 GMT",
                ttl: "4000",
                data: {                             
                    eventVersion: "3.0",
                    eventSource: "OBS",
                    eventRegion: "cn-east-3",
                    eventTime: "2025-7-04T06:08:01.957Z",
                    eventName: "ObjectRemoved:Delete",
                    userIdentity: {
                        ID: "08b4efe0fc00d3ce0f17c01b948f6e80"
                    },
                    requestParameters: {
                        sourceIPAddress: "x.x.x.x"
                    },
                    responseElements: {
                        x-obs-request-id: "000001980D3CC5B5024FE333FEB97E7F",
                        x-obs-id-2: "",
                    },
                    obs: {
                        Version: "1.0",
                        configurationId: "test-trigger",
                        bucket: {
                            name: "examplebucket",
                            ownerIdentity: {
                                ID: "08b4efe0fc00d3ce0f17c01b948f6e80",
                            },
                            bucket: "examplebucket"
                        },
                        object: {
                            key: "exampleobject",
                            eTag: "65a8e27d8879283831b664bd8b7f0ad4",
                            size: "1024",
                            versionId: 9876543210987654321,
                            sequencer: "1",
                            oldpsxpth: ""
                        }
                    }
                }
            },
        ]
    }
  • Deleting an object (using a lifecycle rule)
    {
        channel_id: "a1b2c3d4e5f678901234567890abcdef",
        events: [
            {
                specversion: "1.0",
                id: "17793124-84s5-5e1c-9s20-8fes5s8b54wf",
                source: "HC.OBS.DWR",
                type: "OBS:DWR:ObjectRemoved:Delete",
                datacontenttype: "application/json",
                dataschema: "",
                subject: "exampleobject",
                time: "Fri, 04 Jul 2025 06:08:01 GMT",
                ttl: "4000",
                data: {                             
                    eventVersion: "3.0",
                    eventSource: "OBS",
                    eventRegion: "cn-east-3",
                    eventTime: "2025-7-04T06:08:01.957Z",
                    eventName: "ObjectRemoved:Delete",
                    userIdentity: {
                        ID: "08b4efe0fc00d3ce0f17c01b948f6e80"
                    },
                    requestParameters: {
                        sourceIPAddress: "x.x.x.x"
                    },
                    responseElements: {
                        x-obs-request-id: "000001980D3CC5B5024FE333FEB97E7F",
                        x-obs-id-2: "",
                    },
                    obs: {
                        Version: "1.0",
                        configurationId: "test-trigger",
                        bucket: {
                            name: "examplebucket",
                            ownerIdentity: {
                                ID: "08b4efe0fc00d3ce0f17c01b948f6e80",
                            },
                            bucket: "examplebucket"
                        },
                        object: {
                            key: "exampleobject",
                            eTag: "65a8e27d8879283831b664bd8b7f0ad4",
                            size: "1024",
                            versionId: 9876543210987654321,
                            sequencer: "1",
                            oldpsxpth: ""
                        }
                    }
                }
            },
        ]
    }

Constraints

Table 3 Constraints

Constraint

Description

OBS buckets

  • A bucket can have a maximum of 10 EG notification rules configured.
  • EG notification rules configured for the same bucket cannot overlap with each other. If the notification rule you are creating overlaps with an existing one, the rule creation will fail.

Permissions

If you select OBS Application Service as the event source, your account must have the Tenant Administrator permission. For details, see Assigning Dependency Roles.

Creation of EG notification rules

  • A subscription can be bound with up to five targets.
  • An event can be transmitted three times in an EG channel.
  • Event subscriptions cannot be used across accounts.

Editing of EG notification rules

  • The event source provider cannot be changed.
  • The bound custom event channel cannot be changed.

EG Notification Billing

You need to pay for using EG. For details, seeEG Billing.

Prerequisites

Creating an EG Notification Rule

You can create EG notification rules on OBS Console.

Disabling, Enabling, Modifying, or Deleting EG Notification Rules

You can disable, enable, modify, or delete EG notification rules on OBS Console.

Exporting EG Notification Rules

You can export EG notification rules on OBS Console.