Process historical data (new version)

Updated at:

Log Service supports processing historical data. This topic describes the procedure and provides solutions for common issues.

Prerequisites

Create a data transformation job

  1. Log on to the Log Service console.

  2. Go to the data transformation page.

    1. In the project list, click the target project.

    2. On the Logstores tab, click the target Logstore.

    3. On the query and analysis page, click Data Transformation.

  3. In the upper-right corner of the page, select a time range for the data.

    After you select a time range, make sure that logs appear on the Raw Logs tab.

  4. In the editor, enter an SPL statement. For more information about the syntax, see SPL syntax.

  5. Preview data.

    • On the Raw Data tab, click Add Test Data, or manually enter test data on the Test Data tab.

    • If the transformation results are correct, proceed to the next step.

  6. Click Save Data Transformation (New) to create a data transformation job.

    For more information, see Create a data transformation job (new version). You must set the Time Range for Data Transformation based on the time range of the data that you want to process.

    Parameter

    Description

    All

    Processes data from the first log entry received until the job is manually stopped.

    From Specific Time

    Processes data from the specified start time until the job is manually stopped.

    Specific Time Range

    Processes data only within the specified start and end times.

Transformation results

If no data appears in the target Logstore, use the following methods to troubleshoot the issue.

Query time range

If you do not set the time field in a data transformation statement, the timestamp of a log in the destination Logstore is the same as its timestamp in the source Logstore. When you query the destination Logstore, the default query time range is the last 15 minutes. As a result, you may not find the transformation results for historical data. In this case, you can expand the query time range.

For example, suppose a historical log has a timestamp of 2023-04-11 10:00:00 and the data transformation job runs at 2023-04-12 09:00:00. After the log is written to the target Logstore, its timestamp remains 2023-04-11 10:00:00. If you open the target Logstore at 2023-04-12 09:01:00, the default query time range is 15 Minutes (Relative), and this log will not appear in the results. You can change the time range to 1 Day (Relative) to find the log. On the query and analysis page, click the time range selector in the upper-right corner and set the time range to 1 Day (Relative) or a larger range to view the transformation results for historical data.

Index creation

If you receive an error when opening the target Logstore, you likely need to create an index. You must create an index to query the transformed data. For more information, see Create an Index. If indexing is not enabled for the Logstore, the Logstore returns the IndexConfigNotExist error code. The error message is "Index is not configured for this logstore. Please configure it. (You can query the latest data in about 1 minute after you enable it)".

Index rebuild

Creating an index affects only new data written to the target Logstore. If you create an index for the target Logstore after you create the data transformation job, you cannot query data written before the index was created. In this case, you must rebuild the index for this existing data. For more information, see Rebuild an Index.

Improve historical data transformation efficiency

Processing large volumes of historical data with a single job can be slow and cause persistent consumption latency. To improve performance, split the historical data across multiple jobs and create a separate job for real-time data.

For example, on January 16, 2023, you need to create a data transformation job to process all data written to the source Logstore since January 1, 2023, 00:00:00. You can divide the historical data from January 1, 2023, 00:00:00 to January 15, 2023, 23:59:59 into three separate jobs. Then, create a fourth job to process real-time data written on or after January 16, 2023, 00:00:00, as shown in the following figure.提升加工效率

Job 1

Create Job 1 to process historical data from January 1, 2023, 00:00:00 to January 5, 2023, 23:59:59.

In the Processing Time Range section, select Specific Time Range, and then configure the Processing Start Time and Processing End Time.

Job 2

Create Job 2 to process historical data from January 6, 2023, 00:00:00 to January 10, 2023, 23:59:59.

In the Processing Time Range section, select Specific Time Range, and then configure the Processing Start Time and Processing End Time.

Job 3

Create Job 3 to process historical data from January 11, 2023, 00:00:00 to January 15, 2023, 23:59:59.

In the Processing Time Range section, select Specific Time Range, and then configure the Processing Start Time and Processing End Time.

Job 4

Create Job 4 to process real-time data written on or after January 16, 2023, 00:00:00.

In the Processing Time Range section, select Start from a Specific Time, and then configure the Processing Start Time.