All Products
Search
Document Center

EventBridge:Analyze events in custom event buses

Last Updated:Mar 11, 2026

When you publish custom events to EventBridge, you may need to query, filter, and trace those events across your system. Event analysis lets you run structured queries against all events in a custom event bus using key-value pair retrieval, GUI-based analysis, event tracing, and event source tracing.

To enable event analysis, bind a schema to your custom events. The schema describes the event structure and maps event fields to the analysis platform for structured queries and visualizations.

How it works

You can create and query only event schemas that conform to the OpenAPI 3.0 specification. The schema defines the fields in your event payload so the analysis platform can index and query them.

Bind a schema to custom events using one of two methods:

MethodHow it worksWhen to use
Rule mappingBind the schema URI through an event rule in the EventBridge console.You want a no-code setup through the console.
Push mappingSet the dataschema parameter in the PutEvents API call to bind the schema URI at publish time.You publish events programmatically and want to control schema binding in code.
How event analysis works

Prerequisites

Before you begin, make sure you have:

Create a custom schema

  1. Log on to the EventBridge console. In the left-side navigation pane, click Schemas.

  2. In the top navigation bar, select the region.

  3. On the Schemas page, click the Custom Schema Groups tab, then click Create Schema.

  4. In the Create Schema panel, configure the following parameters and click OK.

    ParameterDescriptionExample
    Schema IDName of the schema.test
    Schema DescriptionDescription of the schema.demo
    Schema ContentCreate Directly: Automatically generates JSON text that conforms to the OpenAPI 3.0 specification. Create Based on JSON: Generates a schema from a JSON sample that you provide.Create Directly
    Compatible TypeWhether to enable compatibility checks between schema versions. Default: no compatibility check.No Compatibility Check

After the schema is created, verify the URI, version, format, and compatibility type on the Custom Schema Groups tab of the Schemas page.

Schema details

Map the schema to events

Bind the schema to your custom events using one of the following methods.

Rule mapping

  1. On the Event Buses page, click the custom event bus to manage. In the left-side navigation pane, click Event Rules, then click Create Rule.

  2. In the Create Rule panel, complete the following steps:

    1. In the Configure Basic Info step, set the Name and Description parameters and click Next Step.

    2. In the Configure Event Pattern step, specify the custom event source to query and click Next Step.

    3. In the Configure Targets step, set Service Type to Event Analysis and Mapping Method to Rule Mapping. Select the same Group Name, Schema ID, and Schema Version as the schema created in the previous step.

  3. Click Create.

Push mapping

  1. Add the dataschema parameter and the schema URI from the previous step to your SDK code, then push events. The following Java example shows the complete flow:

       import com.aliyun.eventbridge.EventBridge;
       import com.aliyun.eventbridge.EventBridgeClient;
       import com.aliyun.eventbridge.models.CloudEvent;
       import com.aliyun.eventbridge.models.Config;
       import com.aliyun.eventbridge.models.PutEventsResponse;
       import com.aliyun.eventbridge.util.EventBuilder;
       import com.google.gson.Gson;
    
       import java.net.URI;
       import java.util.ArrayList;
       import java.util.Date;
       import java.util.List;
    
       public class PutEventsSample {
    
           private EventBridge eventBridgeClient;
    
           public PutEventsSample() {
               Config authConfig = new Config();
               // Obtain the AccessKey ID from environment variables.
               authConfig.accessKeyId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
               // Obtain the AccessKey secret from environment variables.
               authConfig.accessKeySecret = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");
               // Specify the endpoint. For more information, see Regions and endpoints.
               authConfig.endpoint = "<your-endpoint>";
               eventBridgeClient = new EventBridgeClient(authConfig);
           }
    
           public void putEventsSample() {
               List<CloudEvent> cloudEventList = new ArrayList<>();
               CloudEvent cloudEvent = EventBuilder.builder()
                   .withId("a5074581-7e74-4e4c-868f-47e7afdf****")
                   .withSource(URI.create("acs.oss"))
                   .withType("oss:ObjectCreated:PostObject")
                   .withSubject("acs:oss:cn-hangzhou:{yourAccountId}:xls-papk/game_apk/123.jpg")
                   .withTime(new Date())
                   .withJsonStringData("{ \"E-Mail\": \"${email}\" }")
                   .withAliyunEventBus("demo-bus")
                   .build();
               // Set the schema URI obtained from the Create a custom schema step.
               cloudEvent.setDataschema("<schema-uri>");
               cloudEventList.add(cloudEvent);
               PutEventsResponse putEventsResponse = eventBridgeClient.putEvents(cloudEventList);
               System.out.println(new Gson().toJson(putEventsResponse));
           }
    
           public static void main(String[] args) {
               PutEventsSample sample = new PutEventsSample();
               try {
                   sample.putEventsSample();
               } catch (Throwable e) {
                   e.printStackTrace();
               }
           }
       }

    Replace the following placeholders with actual values:

    PlaceholderDescriptionExample
    <your-endpoint>EventBridge endpoint for your region-
    <schema-uri>Schema URI from the previous step-
  2. On the Event Buses page, click the custom event bus to manage. In the left-side navigation pane, click Event Rules, then click Create Rule.

  3. In the Create Rule panel, complete the following steps:

    1. In the Configure Basic Info step, set the Name and Description parameters and click Next Step.

    2. In the Configure Event Pattern step, specify the custom event source to query and click Next Step.

    3. In the Configure Targets step, set Service Type to Event Analysis and Mapping Method to Push Mapping.

  4. Click Create.

Query events

  1. Log on to the EventBridge console. In the left-side navigation pane, choose Event Center > Event Analysis.

  2. In the top navigation bar, select the region.

  3. On the Event Analysis page, set the query parameters and click Query.

Event Analysis page

Required parameters

ParameterDescription
Event BusName of the event bus to query.
SchemaSchema of the event type to query. For more information about Alibaba Cloud service event types, see Alibaba Cloud service event sources.

Optional parameters

ParameterDescription
Key-value MatchFilter events by key-value pairs. Specify one or more conditions using the operators listed below. Select AND or OR to the right of the Key-value Match parameter to specify the relationship between multiple key-value pairs.
Aggregate FunctionAggregate functions for data visualization. Each function maps to a line chart. Required for chart-based results.
Grouped ByField by which to group events. Enter one or more event property fields.
Ordered ByField by which to sort events in ascending or descending order, based on aggregate function results. You can enter one or more fields.
Time RangeTime range for the query.
Number of EventsMaximum number of events to return.

Key-value match operators

OperatorBehavior
=Matches events where the key equals the value.
!=Matches events where the key does not equal the value.
existsMatches events where the key exists, regardless of value.
does-not-existMatches events where the key does not exist.

Analyze the results

View query results on the Aggregate Function and Table tabs of the Event Analysis page.

For details about event parameters in the results, see Analysis of the events in the system event bus.