tencent cloud

Feedback

Quickly Delivering Custom Events

Last updated: 2024-01-22 20:52:28

    Overview

    Cloud service monitoring events and Cloud Audit events generated by official Tencent Cloud services are delivered to the Tencent Cloud service event bus. Events generated by your own applications are delivered to custom event buses. You can create custom event buses and configure event connectors to deliver custom events. Alternatively, you can use an API/SDK to deliver custom events. This document describes how to deliver custom events by using an event connector.
    Note
    In addition to using an event connector, you can call an API to deliver custom events.

    Delivering Custom Events

    Step 1. Create a custom event bus

    1. Log in to the EventBridge console and click Create event bus.
    
    2. Enter the event bus name and description.
    
    3. Click OK.

    Step 2. Create an event connector

    1. On the Event Bus page, click the name of the custom event bus to enter the event bus details page.
    
    2. On the event bus details page, click Add in the Event connector section.
    
    3. Set parameters as prompted. A CKafka event connector is taken as an example in the following figure:
    
    
    
    Set Connector type to CMQ (Kafka), set other parameters as needed, and click OK. For more information about how to configure other types of connectors, see Overview.
    4. Click OK. After the configuration is completed, the event connector can pull a message from CKafka, generate an event based on the message content, and deliver the event to the event bus. Taking the message "Hello from Ckafka again!" as an example, the event connector generates the following event:
    {
    "specversion":"1.0",
    "id":"13a3f42d-7258-4ada-da6d-******3b4662",
    "type":"connector:kafka",
    "source":"ckafka.cloud.tencent",
    "subject": "qcs::ckafka:ap-guangzhou:uin/1250000000:ckafkaId/uin/1250000000/ckafka-123456",
    "time":"1615430559146",
    "region":"ap-guangzhou",
    "datacontenttype":"application/json;charset=utf-8",
    "data":{
    "topic":"test-topic",
    "Partition":1,
    "offset":37,
    "msgKey":"test",
    "msgBody":"Hello from Ckafka again!"
    }
    }
    For more information about the event format, see Event Structure.
    Note
    Currently, only delivery for Tencent Cloud CKafka instances is supported. Confirm that no username or password is configured for your CKafka instances. Otherwise, the connector may fail to get messages.

    Step 3. Create an event rule

    1. Click Event rule in the left sidebar.
    2. At the top of the Event rule page, select the created event bus from the Event Bus drop-down list and click Create event rule.
    3. Set parameters as prompted.
    
    
    
    This event pattern means to receive all messages that are from CKafka. For more information about how to create an event pattern, see Event Pattern.
    4. Click Next and configure the event target, which can be Serverless Cloud Function (SCF), Cloud Log Service (CLS), message pushing service, or CKafka Target. SCF is taken as an example in the following figure. Event content will be delivered to SCF as parameters.
    
    
    
    The test function here is to print the events received, and you can write your function based on the actual business scenario. Alternatively, you can quickly deliver events to CKafka or a downstream SaaS service through a template function provided by the platform. For more information, see SCF Target.

    Step 4. Test an event

    After sending a message to the target topic, you can see the following information on the corresponding SCF log page:
    START RequestId:79e6d53e-7a98-11ec-8f0d-******4284e2
    Received event: {
    "data": {
    "Partition": 1,
    "msgBody": "Hello from Ckafka again!",
    "msgKey": "test",
    "offset": 37,
    "topic": "target-topic"
    },
    "datacontenttype": "application/json;charset=utf-8",
    "id": "13a3f42d-7258-4ada-da6d-******3b4662",
    "region": "ap-guangzhou",
    "source": "ckafka.cloud.tencent",
    "specversion": "0",
    "status": "",
    "subject": "qcs::ckafka:ap-guangzhou:uin/1250000000:ckafkaId/uin/1250000000/ckafka-123456",
    "tags": null,
    "time": 1615430559146,
    "type": "connector:kafka"
    }

    Step 5. Trace the event delivery history

    EventBridge provides the event tracing capability. After enabling linkage tracing, you can view the event delivery history on the event query page of an event bus. If the event tracing mode is set to Default, only the matched events that failed to be delivered to the downstream can be queried. If you want to query all events, choose Event Bus > Event Tracking, set the delivery type to All logs, and select Always report logs of rule matching failures.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support