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

Torch Log Service

Copy page
Download PDF
Data processing best practices
Data flow
Copy page
Download PDF
Data flow
You can use the data transformation feature in TLS to distribute logs from a source log topic to multiple target log topics according to certain rules. This topic provides typical examples of distribution and replication scenarios for data.​
In replication and distribution scenarios, you can send logs from a single source topic to multiple target topics.​
For example, an HTTP service may return status codes such as 200, 400, and 500. After collecting service operation logs into TLS, you may need to distribute logs with different status codes to different log topics for further analysis.​
Raw log​
​
[​
{​
"code":"200",​
"msg": "[2022-12-26 16:35:18,456][3c04c53d-ad24-4853-8603-a6e05f192c3b][INFO] URL: http://xxx.com/CreateTask, userID: 12345",​
},​
{​
"code":"400",​
"msg": "[2022-12-26 16:35:19,456][4eef6955-186a-47c6-9943-ec13fbd2f522][INFO] URL: http://xxx.com/CreateTask, userID: 12346",​
},​
{​
"code":"500",​
"msg": "[2022-12-26 16:35:20,456][63281184-098e-4d34-b2da-2dc258e6a3e5][INFO] URL: http://xxx.com/CreateTask, userID: 12347",​
}​
]​
​
Configure output target​
Set aliases for three target log topics as "topic-200", "topic-400", and "topic-500".​
​​​
​​​
​​​
DSL transformation rules​
​
Distribute logs with codes 200, 400, and 500 to different target log topics.​
c_if(op_eq(v("code"), "200"), e_output("topic-200"), op_eq(v("code"), "400"), e_output("topic-400"), op_eq(v("code"), "500"), e_output("topic-500"))​
​
Processing result​
The data written to the log topic with the alias topic-200 is as follows:​
​
[​
{​
"code":"200",​
"msg": "[2022-12-26 16:35:18,456][3c04c53d-ad24-4853-8603-a6e05f192c3b][INFO] URL: http://xxx.com/CreateTask, userID: 12345",​
}​
]​
​
The data written to the log topic with the alias topic-400 is as follows:​
​
[​
{​
"code":"400",​
"msg": "[2022-12-26 16:35:19,456][4eef6955-186a-47c6-9943-ec13fbd2f522][INFO] URL: http://xxx.com/CreateTask, userID: 12346",​
}​
]​
​
The data written to the log topic with the alias topic-500 is as follows:​
​
[​
{​
"code":"500",​
"msg": "[2022-12-26 16:35:20,456][63281184-098e-4d34-b2da-2dc258e6a3e5][INFO] URL: http://xxx.com/CreateTask, userID: 12347",​
}​
]​
​
​
Last updated: 2026.03.16 11:00:11