|
1 | 1 | # Create Rules
|
2 | 2 |
|
3 |
| -This page mainly introduces how to create a rule for data processing and attach an action to the rule using the EMQX Dashboard. Log in to the EMQX Dashboard and click **Integration** -> **Rules** in the left navigation menu. Then click the **Create** button, which directs you to the **Rules** page. Here, you can define the data source for your rule and determine the subsequent actions for the filtered messages. |
| 3 | +This page provides guidance on how to create rules for data processing and attach an action to a rule using the EMQX Dashboard. It also introduces how to test rules and view rules after the rule creation. |
4 | 4 |
|
5 | 5 | The demonstration on this page takes the republish action as an example, describing how to create a rule that processes messages received on the topic `t/#` and republishes the message to the topic `a/1`. However, the actions "printing the result to the Console" and "forwarding with Sinks" are also mentioned in [Add Action](#add-action).
|
6 | 6 |
|
7 | 7 | ## Define a Data Source
|
8 |
| -On the **Rules** page, enter a name for your rule and add a note to facilitate future management. |
| 8 | +Log in to the EMQX Dashboard and click **Integration** -> **Rules** in the left navigation menu. |
9 | 9 |
|
10 |
| -In the **SQL Editor**, you can customize the statements to add a data source that suits your business needs. For this tutorial, keep the default setting, which selects and returns all messages under topics that follow the `"t/#"` pattern (e.g., `t/a`, `t/a/b`, `t/a/b/c`, etc.). |
| 10 | +Click the **Create** button on the **Rule** page and you will be directed to the **Create Rule** page. Here, you can define the data source for your rule and determine the subsequent actions for the filtered messages. |
| 11 | + |
| 12 | +Enter a name for your rule and add a note to facilitate future management. In the **SQL Editor**, you can customize the statements to add a data source that suits your business needs. For this tutorial, keep the default setting, which selects and returns all messages under topics that follow the `"t/#"` pattern (e.g., `t/a`, `t/a/b`, `t/a/b/c`, etc.). |
11 | 13 |
|
12 | 14 | ::: tip
|
13 | 15 |
|
14 |
| -This tutorial assumes the payload is JSON. If the payload is formatted in some other way, you can convert the data type, for example, with the [Schema Registry](./schema-registry.md). |
| 16 | +This tutorial assumes the message payload is JSON. If the payload is formatted in some other way, you can convert the data type, for example, with the [Schema Registry](./schema-registry.md). |
15 | 17 |
|
16 | 18 | EMQX has embedded rich SQL statement samples to help you get started, you can click the **SQL Example** button under the **SQL Editor** to explore. For more details about the SQL syntax and usages, see [SQL Syntax](./rule-sql-syntax.md).
|
17 | 19 |
|
18 | 20 | :::
|
19 | 21 |
|
20 | 22 | <img src="./assets/rules/create-rules.png" alt="image-20230417211146211" style="zoom:40%;" />
|
21 | 23 |
|
22 |
| -## Test SQL Statement |
| 24 | +### Test SQL Statement |
23 | 25 |
|
24 | 26 | You can use simulated data to execute SQL statements. Before adding actions and creating rules, you can verify whether the SQL execution results meet expectations. This is an optional step, but it is recommended if you are new to EMQX rules. If you want to test the execution of the entire rule, refer to [Test Rule](#test-rule).
|
25 | 27 |
|
@@ -72,7 +74,7 @@ Select **Republish** from the drop-down menu under **Action**, and configure the
|
72 | 74 |
|
73 | 75 | 
|
74 | 76 |
|
75 |
| -On the **Create Rules** page, click the **Create** button at the bottom to complete the rule creation. This rule will be added to as a new entry in the **Rules** page. You can view the rule ID, Source, Enable status, and Action Count. You can also click **Settings** to modify the data source or add more action, or click the **More** button to duplicate or delete the rule. |
| 77 | +On the **Create Rule** page, click the **Create** button at the bottom to complete the rule creation. This rule will be added as a new entry on the **Rule** page. |
76 | 78 |
|
77 | 79 | ::: tip
|
78 | 80 | The republishing action does not prevent the delivery of the original message. For example, according to the rule, messages under topic "t/1" will be republished under topic "a/1", in the meantime "t/1" message will still be delivered to the clients subscribed to topic "t/1".
|
@@ -145,13 +147,34 @@ For more usage guides on testing rules, you can refer to the blog [Enhancing Dat
|
145 | 147 |
|
146 | 148 | ## View Rules
|
147 | 149 |
|
148 |
| -EMQX 5.0 introduced the Flows editor to provide a visualized view of the rules you created. Click **Integration** -> **Flow Designer** to access it. The window shows that you have created two rules for all messages with topics following the "t/#" pattern: "rule_4xjx" publishes the messages and streams data into Kafka, and "rule_z97h" prints the messages to the console. |
| 150 | +The **Rule** page provides a comprehensive list of all the rules you have created. |
| 151 | + |
| 152 | +Each entry in the list displays basic information, including the rule ID, associated source, enable status, and the number of actions. Hovering over the source reveals the corresponding SQL statement details. To modify a rule's configuration, click **Settings** in the **Actions** column. You can also use the **More** button to duplicate or delete a rule. |
149 | 153 |
|
150 |
| - |
| 154 | + |
151 | 155 |
|
152 |
| -You can click the rule ID on the **Flows** page or **Rules** page to view the execution and action statistics parsed by the rule. |
| 156 | +You can also view rules in the [Flow Designer](../flow-designer/introduction.md) by navigating to **Integration** -> **Flow Designer**. Rules created on the **Rules** page and those created through the Flow Designer are fully interoperable. |
153 | 157 |
|
154 |
| -Note: If you update the rule action or redefine the data source, the statistics listed on the page below will reset and start fresh. |
| 158 | +To view the execution and action statistics for a rule, click the rule ID on **Rule** page or the rule name on the **Flows** page. |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | +::: tip |
| 163 | + |
| 164 | +If you update the rule action or redefine the data source, the statistics listed on the page below will reset and start fresh. |
| 165 | + |
| 166 | +::: |
155 | 167 |
|
156 | 168 | 
|
157 | 169 |
|
| 170 | +### View Actions (Sink) and Sources |
| 171 | + |
| 172 | +The **Actions (Sink)** and **Sources** tabs on the **Rule** page display all created actions (sinks) and sources. You can view essential details, such as names, connection statuses, associated rules, and enable statuses. Clicking the number of associated rules will take you to a list of rules containing that specific action (sink) or source, making it easier to manage your data integration settings. |
| 173 | + |
| 174 | +You can reconnect or modify the settings of an action (sink) or source through the **Action** column. By clicking **More**, you can delete the action (sink) or source, or create a new rule using it. |
| 175 | + |
| 176 | +### Search Rules |
| 177 | + |
| 178 | +When there are many rules in the list, you can use the filter to narrow down your search and display the rules you want to view. You can filter rules by rule ID, incoming message topic or wildcard, enable status, rule notes, and the actions or sources associated with the rule. |
| 179 | + |
| 180 | + |
0 commit comments