introduction

Event-driven architecture (EDA) is an asynchronous architecture design model that uses events as a link to decouple different systems. In EDA, the event-driven operation process naturally divides the business semantics of each system, and users can flexibly customize events and responses to the events according to their needs, which makes it easy to build high scalability based on the EDA architecture. application. According to the Daitan Group's research report, as early as 2017, companies such as UBER, Deliveroo, Monzo and others have adopted EDA to design their systems.
在这里插入图片描述

In order to make it easier for users to develop applications based on EDA, Alibaba Cloud officially launched EventBridge at the 2020 Yunqi Conference. EventBridge is a serverless event bus service that routes events between applications using the standardized CloudEvents 1.0 protocol. At present, EventBridge has integrated many mature Alibaba Cloud products, users can complete the connection between various Alibaba Cloud products and applications with low code or even zero code, and build a distributed event-driven architecture easily and efficiently.

Event source is the cornerstone of event-driven, and how to obtain more event sources is also the direction that EventBridge has been exploring and trying. For other cloud vendors and Saas services in vertical fields in the market, EventBridge has released the HTTP Source capability to provide simple and easy-to-integrate three-party event push, helping customers to realize cloud business more efficiently and conveniently.

HTTP Source overview

There are various situations for accessing EventBridge applications: user-defined applications, Alibaba Cloud services, other cloud vendor services, or other SaaS products.

• For user-defined applications, users can use EventBridge's official API interface, multilingual client and open source client from the CloudEvents community to complete the access.

• For Alibaba Cloud's cloud products, EventBridge supports natively, and users can select the corresponding cloud product and its related trigger events in the default event bus.

• For other cloud vendors and SaaS products, EventBridge also provides convenient access methods for users to integrate. HTTP Source event source is a typical access method.

在这里插入图片描述

Specifically, the HTTP Source event source is one of the event sources supported by EventBridge. It exposes the HTTP request address for publishing events in the form of Webhook. Users can configure the HTTP Source event source in scenarios with URL callbacks, or directly use the simplest HTTP client to complete event publishing. The HTTP Source event source provides Webhook URLs that support HTTP and HTTPS, public network and Alibaba Cloud VPC and other request methods and different network environments, so that users can integrate it into various applications. There is no need to use a client when accessing, and it only needs to ensure that the application can access the corresponding Webhook URL, which makes the access process simple and efficient.

When converting an HTTP request into a CloudEvent, EventBridge will place the request header and message body in the CloudEvent field, and the rest of the fields will be filled according to the user's EventBridge resource attributes and system default rules. Users can filter and extract the required content in the event rules, and finally assemble the required message content according to the template and deliver it to the event target.

在这里插入图片描述

The HTTP Source event source currently supports 3 types of security settings, namely request method, source IP and request source domain name.

• Request method: The user can configure the legal HTTP request method when requesting this event source. If the method type does not meet the configuration rules, the request will be filtered and will not be sent to the event bus.

• Source IP: The user can set the valid source IP (support IP range and IP) to allow access to this event source. When the request source IP is not within the set range, the request will be filtered and will not be sent to the event bus.

• Request source domain name: the referer field of the HTTP request. When the requested referer does not match the user configuration, the request will be filtered and will not be delivered to the event bus.

Let's talk about how to use HTTP Source to build the best practice of SaaS application integration, to help you quickly get started with the SaaS integration solution.

SaaS Integration Best Practices

DingTalk monitors GitHub code push events

GitHub provides a Webhook function. When certain specific operations (push, fork, etc.) occur in the code repository, callbacks can be used to help users complete specific functions. For projects developed by multiple people, pushing GitHub events to a specific DingTalk group can help members effectively pay attention to code changes and improve collaboration efficiency.

In this section, we show the best practices on how to monitor GitHub code push events through DingTalk, which mainly includes the following steps:

• Create a DingTalk robot;
• Create EventBridge related resources: event bus, event source (HTTP Source type), event rule, event target (DingTalk);
• Create custom event bus;
• Select GitHub repository to create Webhook;
• Push code changes to the GitHub repository;
• Dingding group receives information about this code push.

1) Create a DingTalk robot

Refer to official document [1] to create a group robot. When creating a group robot, please check "Sign" in the security settings and keep the key and the robot webhook address generated later.

2) Create EventBridge related resources

Create the EventBus event bus

在这里插入图片描述

Create an event source. After the event source configuration is complete, click Skip, and we will configure the event rules and targets next.

在这里插入图片描述

After the creation is complete, go to the event source details page and save the webhook URL just generated.

在这里插入图片描述

On the EventBridge console page, click to enter the newly created EventBus details page, and select "Create Rule" in "Event Rules" in the left column.
在这里插入图片描述

在这里插入图片描述

Create time goals. Select DingTalk, and fill in the webhook address and key of the DingTalk robot. The push content side can be designed as required.

在这里插入图片描述

We fill in the template variables as:
{"repo":"$.data.body.repository.full_name","branch":"$.data.body.ref","pusher":"$.data.body.pusher.name"}

The template is:
{"msgtype": "text","text": {"content": "Github push event is triggered. repository: ${repo}, git reference: ${branch}, pusher: ${pusher}." } }

3) Create a Webhook in the GitHub code repository

Log in to GitHub, select "Webhooks" on the left in the "setting" of the GitHub code repository, and select New Webhook.

Fill in the Webhook address of the HTTP Source event source in the configuration item for creating a Webhook, select "application/json" in the Content type section, select "Just the push event." for the trigger event type below, and then click "Add Webhook" to complete the creation.
在这里插入图片描述

4) Push code changes to the GitHub code repository

Make certain changes to the local repository, and push them to GitHub after committing.

5) Dingding group receives the relevant information of this code push

在这里插入图片描述

Asynchronous consumption monitoring alarm information

There are scenarios of asynchronous consumption of alarm information in the business, such as backup of alarm content, adaptive adjustment of alarm thresholds according to alarm frequency, etc. Moreover, for users of multi-cloud services, how to integrate the alarm information of cross-cloud services is also a troublesome problem. Relying on HTTP Source, users can integrate different cloud vendors (Tencent Cloud, Huawei Cloud, etc.) and different monitoring products (Grafana, Zabbix, Nagios, etc.) into the EventBridge platform to facilitate asynchronous consumption of alarm information.
在这里插入图片描述

In this section, we introduce how to use EventBridge to integrate Grafana to realize asynchronous consumption monitoring and alarm information. Grafana is an open source data visualization tool that also has monitoring and alarm functions. For details, please refer to the official document [2] . This section mainly includes the following steps:

• Create MNS queues;
• Create EventBridge related resources;
• Configure Webhook on Grafana;
• Test reception results.

Create MNS queue

In the MNS console, select Queue List - Create Queue.

在这里插入图片描述

Create EventBridge related resources

As mentioned above, here is only an example of the relevant configuration when creating an event target.

在这里插入图片描述

Configure Webhook on Grafana

Click "Alerting-Notification channels" on the left side of the Grafana console and select "Add channel".

在这里插入图片描述

Select "Webhook" in the "type" column, fill in the Webhook address of the HTTP Source event source for url, and click "Test" below.

Test reception result

Log in to the MNS console, enter the queue details page, and click "Send and Send Messages" in the upper right corner of the page. You can see that MNS has received the message just sent by Grafana.

在这里插入图片描述

Click the corresponding message details to see the content of the message, indicating that the message has been successfully consumed.
在这里插入图片描述

more integrations

Three-party integrations supported by HTTP Source include SaaS applications such as Prometheus, Zabbix, Skywalking, Grafana, Open-Falcon, Cacti, Nagios, Dynatrace, Salesforce, Shopify, Gitee, etc. The event receiving capability can be achieved without development by simply configuring the Webhook.

Summarize

This article focuses on a new feature of EventBridge: HTTP Source event source. As a serverless event bus service, EventBridge has integrated Alibaba Cloud product management and control link data and message product business data into the event source ecosystem, improving the convenience of cloud user business integration. Support, it provides convenience for customers to access EventBridge for their own business.

On this basis, the HTTP Source event source goes a step further and opens up the integration capabilities for other cloud vendors and SaaS applications in the form of Webhook. It does not require code changes, and only requires simple configuration to complete the EventBridge integration operation.

Related Links

[1] DingTalk official documentation
https://open.dingtalk.com/document/group/custom-robot-access

[2] Grafana official documentation
https://grafana.com/docs/


阿里云云原生
1k 声望302 粉丝