tencent cloud


Creating a Processing Task

Last updated: 2022-03-16 16:07:31


    Data processing provides capabilities to cleanse, filter, mask, enrich, and distribute log data and more. The service is free of charge before March 15, 2022.

    You can select a source log topic and write Domain Specific Language (DSL) processing function statements to process logs line by line and send logs that meet certain requirements to specified target log topics.

    Application Scenarios

    For most users, data processing can achieve the following:

    • Extract structured data to facilitate future operations such as search, analysis, and dashboard generation.
    • Simplify logs to reduce use costs. Unnecessary logs will be discarded to reduce storage and traffic costs.
    • Data masking for sensitive data such as users' ID numbers and phone numbers.
    • Ship logs by category. For example, logs are categorized by log levels ERROR, WARNING, and INFO and then distributed to different log topics.

    Common DSL Functions

    The following describes some DSL functions that are commonly used for data processing. The corresponding use cases can be viewed in DSL Statement Generator on the Create Data Processing Task > Edit Processing Statement page in the console. You can directly copy the sample code and modify parameters as needed for quick use.

    • Extracting structured data: ext_sep() for extracting by separator, ext_json or ext_json_jmes for extracting by JSON, and ext_regex() for extracting by regular expression
    • Simplifying logs: log_drop for discarding a line of log and fields_drop() for discarding log fields
    • Masking sensitive data: regex_replace()
    • Classifying logs: t_if_else() and t_switch() for determining conditions, and log_output() for distributing logs
    • Editing fields: fields_set() for adding/resetting fields, and fields_rename() for renaming fields
    • Determining the presence of a field or data in logs: has_field() for determining whether a field exists and regex_match() for determining whether certain data exists
    • Comparing numerical values in logs: op_gt() (greater than), op_ge() (greater than or equal to), and op_eq() (equal to); functions for addition, subtraction, multiplication, and division, such as op_mul() for multiplication and op_add() for addition
    • Processing text in logs: str_uppercase() for uppercase or lowercase switching and str_replace() for text replacement
    • Processing time values in logs: dt_to_timestamp() for converting a time value to a UTC timestamp

    The preceding are common DSL functions used in data processing scenarios. The DSL statement generator also provides other DSL functions for your reference. You can copy a desired function to the DSL function editing box, modify parameters, and use it.

    The following describes how to create a data processing task.


    • You have activated CLS, created a source log topic, and successfully collected log data.
    • You have created a target log topic, which is recommended to be empty to allow the writing of processed data.
    • The current account has the permission to configure data processing tasks.

    • Data processing can process only real-time log streams but not historical logs.
    • If the data processing console does not automatically load raw log data, the possible cause is that your log topic does not have real-time log streams. In that case, you need to manually add custom logs in JSON format to complete writing the data processing script.


    1. Log in to the CLS console.
    2. On the left sidebar, click Data Processing.
    3. Click Create Processing Task.
    4. On the Basic Info page, configure the following information:
    • Task Name: enter the custom task name.
    • Source Log Topic: select the source log topic.
    • Target Log Topic: enter a target name and select a log topic.
      A target name can be the alias of a target log topic and can be used as an input parameter of the written DSL function. You can configure up to 10 target log topics.
    1. Click Next.

    2. On the Edit Processing Statement page, perform the following operations:

    3. A DSL function can be tested by two types of data: raw log data and custom data. The system automatically loads raw log data, 100 records by default. If you don't think the raw log data is insufficient for testing the DSL function, you can directly enter custom data on the Custom Data tab page. Alternatively, you can click Add Custom Data on the Raw Data tab page, modify the data, and use it as your custom data.


      Custom data must be in JSON format.

      If there are multiple entries of custom data, add them in the following format:

         "content": "2021-10-07 13: 32: 21|100|Customer not checked in|Jack|Beijing|101123199001230123|"
         "content": "2021-10-07 13: 32: 21|500|Checked in successfully|Jane|Sanya|501123199001230123|"
         "content": "2021-10-07 13: 32: 21|1000|Checked out|Lily|Sanya|101123196001230123|"
    4. Click DSL Statement Generator.

    5. In the pop-up window, select a function, and click Insert Function.
      The DSL statement generator provides the descriptions and examples of multiple types of functions. You can copy and paste the examples to the processing statement editing box and modify parameters as needed to write your own DSL functions. You can also refer to Processing Example to quickly understand how to write a DSL function.

    6. After writing the DSL processing statement, click Preview or Checkpoint Debugging to run and debug the DSL function.
      The running result will be displayed at the bottom right of the page. You can adjust the DSL statement according to the running result until it meets your requirements.

    7. Click OK to submit the data processing task.

    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