Updated on 2025-12-12 GMT+08:00

EG-based Event Notifications

Scenarios

You can configure EventGrid (EG) event notifications to promptly detect operations on a bucket and its objects and trigger follow-up actions.

For example, you can define an EG event notification that automatically adds watermarks to images uploaded to a specific bucket and stores the watermarked images in a target bucket.

How OBS Works with EG

OBS stores objects such as files, images, and videos. Uploading, modifying, or deleting these objects generate OBS events. After capturing the OBS events, EG automatically triggers follow-up actions or processes based on the predefined rules. In this process, OBS sends notifications, and EG delivers tasks, removing the need for manual intervention.

An EG event notification rule consists of an event source, channel, and event target:

  • Event source: a source that generates events. For a cloud service, there will be events when users send requests to it.
  • Channel: a transfer station that receives events from cloud services
  • Event target: a destination that processes events. Cloud service events from the channel can trigger other cloud services to perform actions. (For example, FunctionGraph can be triggered to add watermarks to images and store the images in OBS buckets.)

Figure 1 shows how OBS works with EG.

Figure 1 EG event notification flowchart

The following describes how OBS works with EG in detail:

  1. An administrator creates an EG notification rule that includes 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.
  3. EG pushes the events to the event target through the channel. The event target then triggers other cloud services to perform follow-up operations.

Supported OBS Event Types

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

  • OBS Application Service: this source pushes events for specific operations performed on objects in OBS buckets
  • Object Storage Service (OBS): this source pushes audit log events for operations performed on OBS buckets and objects and operations triggered by the system itself
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 for operations triggered by API Gateway calls

OBS:CloudTrace:ObsSDK

Audit log events for OBS bucket operations triggered by OBS SDK calls

OBS:CloudTrace:ConsoleAction

Audit log events for operations performed on the console

OBS:CloudTrace:SystemAction

Audit log events for operations triggered by the system itself

OBS:CloudTrace:Others

Audit log events for operations except those on OBS buckets triggered by OBS SDK calls

Structure of the Event Notification Messages Sent by OBS

Once there is an OBS event, OBS sends an event notification message in a fixed JSON structure to EG. After receiving the notification, EG triggers other cloud services to perform actions.

The following gives an example of the JSON notification message OBS sends to EG:

{
    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 following table describes the fields that the message includes.

Table 2 Fields in an EG event notification message

Field

Description

channel_id

The unique identifier of the EG event channel

events[].specversion

The version of the EG event specification

events[].id

The unique identifier of the EG event

events[].source

The service name of the EG event source. The value is always HC.OBS.DWR.

events[].type

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

events[].datacontenttype

The content type of the EG event data. The value is always application/json.

events[].dataschema

The schema of the EG event data

events[].subject

The object name

events[].time

The UTC time when the EG event occurs

events[].ttl

How long the EG event remains valid. The default value is 4 seconds.

events[].data.eventVersion

The version of the OBS message

events[].data.eventSource

The message source. The value is always OBS.

events[].data.eventRegion

The region where the event occurs

events[].data.eventTime

The event time in ISO-8601 format

events[].data.eventName

The name of the event that triggers the notification

events[].data.userIdentity.ID

The billing ID of the user who triggers the event

events[].data.requestParameters.sourceIPAddress

The request's source IP address

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

The request ID

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

The special symbols that help locate problems

events[].data.obs.Version

The OBS version

events[].data.obs.configurationId

The name of the OBS event trigger that matches the event

events[].data.obs.bucket.name

The bucket name

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

The account ID of the bucket owner

events[].data.obs.bucket.bucket

The bucket name

events[].data.obs.object.key

The object name

events[].data.obs.object.eTag

The object ETag

events[].data.obs.object.size

The object size

events[].data.obs.object.versionId

The object version ID

events[].data.obs.object.sequencer

The identifier that determines the sequence of a specific object event

events[].data.obs.object.oldpsxpth

The path of the file before being renamed in the parallel file system

  • Object upload
    {
        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: ""
                        }
                    }
                }
            },
        ]
    }
  • Manual object deletion
    {
        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: ""
                        }
                    }
                }
            },
        ]
    }
  • Object deletion 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

Category

Description

OBS buckets

  • A bucket can have a maximum of 10 EG notification rules.
  • EG notification rules for the same bucket cannot overlap. An event can only match one rule. If the rule you are creating conflicts 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.

Edit of EG notification rules

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

Billing for EG Notifications

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

Prerequisites

Creating an EG Notification Rule

You can use OBS Console to create EG notification rules.

Disabling, Enabling, Modifying, or Deleting EG Notification Rules

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

Exporting EG Notification Rules

You can use OBS Console to export EG notification rules.