Copy a Logstore

Updated at:

If you need to keep multiple copies of data from a Logstore, you can use the data transformation feature. This topic describes its use cases and procedure.

Use cases

A company's access logs are collected and stored in multiple projects under the same Alibaba Cloud account. You need to copy the access logs from project-a in logstore-a to logstore-b in a new project-b to centralize queries and analysis in project-b. The data transformation feature of Log Service provides a replication function that can copy data from logstore-a to logstore-b.

image

Prerequisites

  • You have created logstore-a and written data to it. For more information, see Manage a Logstore.

  • You have created logstore-b and planned its capacity, such as the number of shards, based on your performance requirements. For more information, see Performance guide.

Procedure

  1. Log on to the Simple Log Service console.

  2. In the project list, click project-a.

  3. On the Log Storage > Logstores tab, click logstore-a.

  4. Click Data Transformation to open the data transformation editor.

  5. In the editor, leave the SPL statement empty or enter *.

  6. Preview the data.

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

  7. Create a data transformation job.

    1. Click Save as Transformation Job (New).

    2. In the Create Data Transformation Job (New) panel, configure the following parameters and click OK.

    Note

    For more information about the parameters, see Create a data transformation job (new version).

    Parameter

    Description

    Job name

    The name of the data transformation job. Use the default value.

    Display name

    A custom name for the job. For example, enter test.

    Authorization method

    Grants Log Service permission to read data from logstore-a. For this example, select Default Role.

    Storage target name

    The name of the storage target. Enter test.

    Destination region

    The region where the destination project resides. Select China (Hangzhou).

    Destination project

    The name of the project to which Logstore-b belongs. Enter project-b.

    Destination logstore

    The name of the destination Logstore. Enter logstore-b.

    Authorization method

    Grants Log Service permission to write data to logstore-b.

    For this example, select Default Role.

    Time range

    The time range for data transformation. The job continuously processes data from the beginning of the source Logstore until manually stopped. Select All.

Verify the result

  1. Check the status of the data transformation job. For more information about the parameters on the job page, see Manage data transformation jobs.

    In the left-side navigation pane, choose Job Management > Data Transformation. Click the name of the job to view its status and other basic information in the Data Transformation Overview panel on the right.

  2. Go to the project-b project. On the Log Storage > Logstores tab, select logstore-b to open the query and analysis page.

  3. In the upper-right corner of the page, click Enable Index. For more information about indexes, see Create indexes.

  4. View the data copied from logstore-a. The query result shows that the logs are successfully copied to logstore-b. The value of the __source__ field is actiontrail_internal, and the value of the __topic__ field is actiontrail_audit_event.