All Products
Search
Document Center

Simple Log Service:Import OSS data

Last Updated:Jan 28, 2026

You can import log files from an OSS bucket to Simple Log Service for querying, analysis, and processing. Simple Log Service supports importing OSS files up to 5 GB. The size of a compressed file is its size after compression.

Billing description

Simple Log Service does not charge for the data import feature. However, this feature accesses OSS APIs, which incurs OSS traffic fees and request fees. For more information about the pricing of billable items, see OSS Pricing. The formula to calculate the daily OSS fees for importing OSS data is as follows:

image..png

Description of fee parameters

Field

Description

N

The number of files imported per day.

T

The total data volume imported per day, in GB.

p_read

The traffic fee per GB of data.

  • When you import data within the same region, outbound traffic over the internal network is generated from OSS. This traffic is free of charge.

  • When you import data across regions, outbound traffic over the Internet is generated from OSS.

p_put

The fee per 10,000 PUT requests.

Simple Log Service uses the ListObjects API operation to obtain the list of files in the destination bucket. OSS charges for this operation as PUT requests. This operation returns a maximum of 1,000 data entries at a time. Therefore, if you have 1,000,000 new files, you need to make 1,000,000/1000 = 1,000 requests.

p_get

The fee per 10,000 GET requests.

M

The interval to check for new files, in minutes.

You can set the Check for New Files Interval parameter when you create a data import configuration.

Prerequisites

  • Log files have been uploaded to an OSS bucket. For more information, see Upload files in the console.

  • A project and a Logstore have been created. For more information, see Manage a project and Create a basic Logstore.

  • You have completed the cloud resource access authorization. This authorization allows Simple Log Service to access your OSS resources using the AliyunLogImportOSSRole role.

  • Your account has the oss:ListBuckets permission to access OSS buckets. For more information, see Grant custom policies to a RAM user.

    If you use a Resource Access Management (RAM) user, you must also grant the PassRole permission to the RAM user. The following is an example of the authorization policy. For more information, see Create a custom policy and Manage RAM user permissions.

    {
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "ram:PassRole",
          "Resource": "acs:ram:*:*:role/aliyunlogimportossrole"
        },
        {
          "Effect": "Allow",
          "Action": "oss:GetBucketWebsite",
          "Resource": "*"
        },
        {
          "Effect": "Allow",
          "Action": "oss:ListBuckets",
          "Resource": "*"
        }
      ],
      "Version": "1"
    }    

Create a data import configuration

Important

If an OSS file that was already imported is updated, such as by appending new content, the data import task re-imports the entire file.

  1. Log on to the Simple Log Service console.

  2. In the Data Ingestion area, on the Data Import tab, select OSS-Data Import.

  3. Select the destination project and Logstore, and then click Next.

  4. Set the import configuration.

    1. In the Import Configuration step, set the following parameters.

      Parameter settings

      Parameter

      Description

      Task Name

      The unique name of the SLS task.

      Display Name

      The display name of the task.

      Task Description

      The description of the import task.

      OSS Region

      The region where the bucket that stores the OSS files to be imported is located.

      If the OSS bucket and the Simple Log Service project are in the same region, you can save Internet traffic and benefit from faster data transfer.

      Bucket

      The bucket that stores the OSS files to be imported.

      Filter by File Path Prefix

      Filter OSS files by file path prefix to locate the files to be imported. For example, if all files to be imported are in the csv/ directory, you can specify the prefix as csv/.

      If you do not set this parameter, the entire OSS bucket is traversed.

      Note

      Set this parameter. If a bucket contains many files, traversing the entire bucket significantly reduces data import efficiency.

      Filter by File Path Regular Expression

      Filter OSS files by a regular expression for the file path to locate the files to be imported. Only files whose names (including file paths) match the regular expression are imported. By default, this parameter is empty, which means no filtering is performed.

      For example, if the OSS file is testdata/csv/bill.csv, you can set the regular expression to (testdata/csv/)(.*).

      For more information about how to debug a regular expression, see How do I test a regular expression?.

      Filter by File Modification Time

      Filter OSS files by file modification time to locate the files to be imported.

      • All: Select this option if you want to import all eligible files.

      • From a Specific Time: Select this option if you want to import files modified after a specific point in time.

      • Specific Time Range: Select this option if you want to import files modified within a specific time range.

      Data Format

      The file is parsed in the following format.

      • CSV: A text file that uses a separator. You can specify the first line of the file as field names or manually specify field names. Each line except for the field names is parsed as the values of log fields.

      • Single-line JSON: Reads the OSS file line by line and parses each line as a JSON object. After parsing, the fields in the JSON object correspond to the fields in the log.

      • JSON array: Reads the entire OSS file at once. The content is an array that contains one or more JSON objects.

      • Cloudtrail: Reads the entire OSS file at once. The content is in the standard CloudTrail data structure format.

      • Single-line Text Log: Parses each line in the OSS file as a log entry.

      • Multi-line Text Log: Multi-line mode. You can specify a regular expression for the first or last line to parse logs.

      • ORC: ORC file format. No configuration is required. The file is automatically parsed into a log format.

      • Parquet: Parquet format. No configuration is required. The file is automatically parsed into a log format.

      • Alibaba Cloud OSS Access Log: Alibaba Cloud OSS access log format. For more information, see Log storage.

      • Alibaba Cloud CDN Download Log: Alibaba Cloud CDN download log format. For more information, see Quick Start.

      Compression Format

      The compression format of the OSS files to be imported. Simple Log Service decompresses and reads the data based on the corresponding format.

      Encoding Format

      The encoding format of the OSS files to be imported. Only UTF-8 and GBK are supported.

      Check for New Files Interval

      If new files are continuously generated in the destination OSS file path, you can set the Check for New Files Interval as needed. After you set the interval, the import task runs in the background and periodically discovers and reads new files. The background process ensures that data from the same OSS file is not repeatedly written to Simple Log Service. For example, if you create a task at 12:00 with a new file check interval of 30 minutes, the import task runs for the first time at 12:00. If new files are generated later, the task runs for the second time at 12:30.

      If no new files are generated in the destination OSS file path, change the interval to Never. The import task will automatically exit after reading all eligible files.

      Import Archived Objects

      If the OSS files to be imported are of the standard Archive Storage or Cold Archive storage class, they must be restored before they can be read. If you enable this feature, archived objects are automatically restored. Deep Cold Archive is not supported.

      Note
      • Restoring a standard archived object takes about 1 minute. This may cause the first preview to time out. If a timeout occurs, wait for a period of time and try again.

      • Restoring a Cold Archive object takes about 1 hour. If the preview times out, you can skip the preview or wait 1 hour and try again.

        When a Cold Archive object is restored, the restoration is valid for 7 days by default to ensure that you have enough time to import the Cold Archive object.

      Log Time Configuration

      Time Field

      When you set Data Format to CSV, Single-line JSON, JSON array, Cloudtrail, ORC, Parquet, Alibaba Cloud OSS Access Log, or Alibaba Cloud CDN Download Log, set a time field. This is the column name in the OSS file that represents time, used to specify the time when logs are imported to Simple Log Service.

      Time Extraction Regex

      When you set Data Format to Single-line Text Log or Multi-line Text Log, you need to use a regular expression to extract the time from the logs.

      For example, if the log sample is 127.0.0.1 - - [10/Sep/2018:12:36:49 +0800] "GET /index.html HTTP/1.1", you can set Time Extraction Regex to [0-9]{0,2}\/[0-9a-zA-Z]+\/[0-9\: +]+.

      Note

      For other data formats, you can also use a regular expression to extract only part of the content from the time field.

      Time Field Format

      Specify the time format to parse the value of the time field.

      • Time formats that follow the Java SimpleDateFormat syntax are supported, such as yyyy-MM-dd HH:mm:ss. For more information about the time format syntax, see Class SimpleDateFormat. For common time formats, see Time formats.

      • Epoch formats are supported, including epoch, epochMillis, epochMicro, and epochNano.

      Time Field Time Zone

      Select the time zone corresponding to the time field. When the time field format is an epoch type, you do not need to set the time zone.

      To consider daylight saving time when parsing the log time, select a UTC format. Otherwise, select a GMT format.

      Advanced Configuration

      Use OSS Metadata Index

      If the number of OSS files exceeds one million, enable this feature. Otherwise, the efficiency of discovering new files is very low. After you use the OSS metadata index, new files in the OSS bucket can be discovered within seconds, enabling near-real-time import of data from newly written files in the bucket.

      Before you use the OSS metadata index, you must first enable the OSS metadata index management feature in OSS. For more information, see Scalar retrieval.

      You must set additional parameters when you set Data Format to CSV or Multi-line Text Log. The following table describes these parameters.

      CSV

      Parameter

      Description

      Separator

      Set the separator for the logs. The default value is a comma (,).

      Quote Character

      The quote character used for CSV strings.

      Escape Character

      Configure the escape character for the logs. The default value is a backslash (\).

      Maximum Lines per Log

      When a log entry spans multiple lines, you need to specify the maximum number of lines. The default value is 1.

      Use First Line as Field Names

      After you turn on the Use First Line as Field Names switch, the first line of the CSV file is used as the field names. For example, the first line in the following figure is extracted as the names of the log fields.首行

      Custom Field List

      After you turn off the Use First Line as Field Names switch, customize the log field names as needed. Separate multiple field names with commas (,).

      Lines to Skip

      Specify the number of log lines to skip. For example, if you set this to 1, log collection starts from the second line of the CSV file.

      Cross-text logs

      Parameter

      Description

      Regex Match Position

      Set the position for the regular expression match. The following options are available:

      • First Line Regex: Use a regular expression to match the first line of a log entry. The unmatched part is considered part of that log entry, up to the maximum number of lines.

      • Last Line Regex: Use a regular expression to match the last line of a log entry. The unmatched part is considered part of the next log entry, up to the maximum number of lines.

      Regular Expression

      Set the correct regular expression based on the log content.

      For more information about how to debug a regular expression, see How do I test a regular expression?.

      Maximum Lines

      The maximum number of lines for a single log entry.

    2. Click Preview to view the import results.

    3. After confirming the settings, click Next.

  5. Create indexes and preview data. Then, click Next. By default, full-text indexing is enabled in Simple Log Service. You can also manually create field indexes for the collected logs or click Automatic Index Generation. Then, Simple Log Service generates field indexes. For more information, see Create an index.

    Important

    If you want to query all fields in logs, we recommend that you use full-text indexes. If you want to query only specific fields, we recommend that you use field indexes. This helps reduce index traffic. If you want to analyze fields, you must create field indexes. You must include a SELECT statement in your query statement for analysis.

  6. Click Query Logs to open the query and analysis page and confirm that the OSS data was successfully imported.

    Wait for about 1 minute. The import is successful if the data is available in the target OSS location.

Related operations

After you create an import configuration, you can view the configuration and its statistical reports in the console.

  1. In the Projects section, click the destination project.

  2. In the navigation pane, choose Log Storage > Logstores. For the destination Logstore, choose Data Access > Data Import, and then click the configuration name.

  3. View a task

    On the Import Configuration Overview page, you can view basic information and statistical reports.

    导入任务概览

    Modify a task

    Click Modify Configuration to modify the import configuration. For more information, see Set the import configuration.

    Delete a task

    To delete the import configuration, click Delete Configuration.

    Warning

    This operation cannot be undone. Proceed with caution.

    Stop a task

    To stop the import task, click Stop.

    Start a task

    Click Start to begin the import task.

FAQ

Problem

Possible cause

Solution

No data is displayed in the preview when I import files from the HDFS directory of a bucket.

Importing files from the HDFS directory is not supported.

If the HDFS service is enabled for a bucket, a .dlsdata directory is created by default in the OSS directory that you can use to import files.

No data is displayed in the preview.

There are no files in the OSS bucket, the files contain no data, or no files match the filter conditions.

  • Check whether there are non-empty files in the bucket. For example, a CSV file may contain only a header row. If no files with data exist, wait until data is available before you import the files.

  • You can adjust configuration items such as Filter by File Path Prefix, Filter by File Path Regular Expression, and Filter by File Modification Time.

The data contains garbled text.

The data format, compression format, or encoding format is not configured correctly.

Check the actual format of the OSS files and adjust the relevant configuration items, such as Data Format, Compression Format, or Encoding Format.

To fix existing garbled data, you must create a new Logstore and a new import configuration.

The data timestamp displayed in Simple Log Service is inconsistent with the actual time of the data.

The log time field was not specified, or the time format or time zone was set incorrectly in the import configuration.

Specify the log time field and set the correct time format and time zone. For more information, see Create a data import configuration.

After importing data, I cannot query and analyze the data.

  • The data is out of the query range.

  • An index is not configured.

  • The index has not taken effect.

  • Check whether the data you want to query is within the specified time range.

    If not, adjust the time range and try the query again.

  • Check whether an index is configured for the Logstore.

    If not, you must configure an index. For more information, see Create an index and Reindex.

  • If an index has been set and the successfully imported data volume in the Data Processing Traffic Monitor dashboard meets expectations, the index may not have taken effect. You can try to reindex. For more information, see Reindex.

The number of imported data entries is less than expected.

Some files contain single lines of data that exceed 3 MB. This data is discarded during the import process. For more information, see Collection limits.

When you write data to OSS files, make sure that no single line of data exceeds 3 MB.

The data import speed is slower than the expected speed of 80 MB/s, even though the number of files and total data volume are large.

The number of Logstore shards is too small. For more information, see Performance limits.

If the number of Logstore shards is small, increase the number of shards to 10 or more and monitor the latency. For more information, see Manage shards.

When creating an import configuration, I cannot select an OSS bucket.

The authorization for the AliyunLogImportOSSRole role is incomplete.

Complete the authorization as described in the prerequisites section of this topic.

Some files were not imported.

The filter conditions are set incorrectly, or some files are larger than 5 GB. For more information, see Collection limits.

  • Check whether the files you want to import meet the filter conditions. If not, modify the filter conditions.

  • Make sure that the size of each file to be imported is less than 5 GB.

    If a file is larger than 5 GB, you must reduce its size.

Archived objects were not imported.

The Import Archived Objects switch is off. For more information, see Collection limits.

  • Method 1: Modify the import configuration by enabling the Import Archived Objects switch.

  • Method 2: Recreate an import configuration and enable the Import Archived Objects switch.

Multi-line text logs are parsed incorrectly.

The first line regular expression or last line regular expression is set incorrectly.

Verify that the first line regular expression or last line regular expression is correct.

The latency for importing new files is high.

The number of existing files that match the file path prefix filter is too large, and the Use OSS Metadata Index switch is disabled in the import configuration.

If more than 1 million files match the file path prefix, enable the Use OSS Metadata Index switch in the import configuration. Otherwise, the file discovery process will be highly inefficient.

An STS-related permission error is reported during creation.

The RAM user does not have sufficient permissions.

  1. Check whether the AccessKey pair of the RAM user is valid. Make sure that the AccessKey pair is correct and enabled. For more information, see AccessKey pair.

  2. Check whether the Security Token Service (STS) token configured for the RAM user has expired. If the temporary access credential has expired, extend its validity period. For more information, see Use an STS token to access OSS.

  3. Make sure that you have completed the cloud resource access authorization. This authorization allows Simple Log Service to access your OSS resources using the AliyunLogImportOSSRole role.

Error handling mechanism

Error

Description

Failed to read a file

When reading a file, if an incomplete file error occurs (due to network exceptions, file corruption, etc.), the import task automatically retries. If the read operation fails after three retries, the task skips the file.

The retry interval is the same as the new file check interval. If the new file check interval is set to Never, the retry interval is 5 minutes.

Compression format parsing error

When decompressing a file, if an invalid compression format error occurs, the import task skips the file.

Data format parsing error

  • If parsing data in a binary format (ORC, Parquet) fails, the import task skips the file.

  • If parsing data in other formats fails, the import task stores the original text content in the content field of the log.

The OSS bucket does not exist

The import task retries periodically. This means that after the bucket is recreated, the import task automatically resumes the import.

Permission error

If a permission error occurs when reading data from an OSS bucket or writing data to a Simple Log Service Logstore, the import task retries periodically. This means that after the permission issue is fixed, the task automatically resumes.

When a permission error occurs, the import task does not skip any files. Therefore, after the permission issue is fixed, the task automatically imports data from the unprocessed files in the bucket to the Simple Log Service Logstore.

OSS delivery API operations

Operation

Interface

Create an OSS import task

CreateOSSIngestion

Modify an OSS import task

UpdateOSSIngestion

Obtain an OSS import task

GetOSSIngestion

Delete an OSS import task

DeleteOSSIngestion

Start an OSS import task

StartOSSIngestion

Stop an OSS import task

StopOSSIngestion