You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Data transformation
How data transformation works
Copy page
Download PDF
How data transformation works
The data transformation feature provided by TLS consumes log data from the source topic through consumer groups. The data transformation feature automatically compiles specified DSL statements, parses them into processing rules, and applies these rules to transform and process log data. Then the feature writes the processed log data to the specified log topic via the log writing API. This topic describes the scheduling principles of transformation tasks and the working principles of processing rules.​
Scheduling principles​
The data transformation feature uses coordinated consumer groups to stream log data from the source log topic. Each transformation task corresponds to a consumer group, which launches one or more consumers. Then these consumers process the consumed log data. Each consumer processes one or more shards from the source log topic, and the maximum number of consumers matches the number of readable and writable shards in the source log topic.​
Processing rule principles​
TLS supports writing processing rules using built-in functions provided by the TLS DSL. Each statement in a processing rule represents a processing step. The rule engine executes these steps in the order that the statements appear. For example, the following four statements define four steps in order.​
​
f_set("user_type", "normal")​
f_drop("content")​
c_if(f_has("inner_user"), f_set("user_source", "inner"))​
c_if(op_eq(v("user_city"), "chengdu"), e_output("target"))​
​
Corresponding logic diagram:​
​​​
​
Rule​
Description​
Basic logic​
TLS executes each statement defined in the rule sequentially and processes every function in the statements based on semantic order. Each function modifies the log event during execution and returns the processed event.​
For example, f_set("user_type", "normal") adds a field user_type with value normal to every event. The next function receives the event after the new user_type field has been added.​
Conditional judgment​
The data transformation rules allow setting conditions for each step. Only events that meet these conditions will trigger the corresponding function execution.​
For example, in the statement c_if(f_has("inner_user"), f_set("user_source", "inner")), TLS first checks whether the field inner_user exists. If it does not exist, no action is taken. If it exists, a new field user_source will be added with the value set to inner.​
Output​
If the specified condition is met, the data is output; if not, no action will be taken. If no other rule processes the event, it will be deleted afterwards.​
For example, c_if(op_eq(v("user_city"), "chengdu"), e_output("target")). If the value of user_city is chengdu, the event will be output to the log topic with the alias target.​
​
​
Last updated: 2026.04.16 15:32:45