All Products
Search
Document Center

Simple Log Service:Collect text logs from servers

Last Updated:Nov 05, 2025

Business, application, or system logs that are scattered across different servers are difficult to retrieve, monitor, and analyze centrally. You can use LoongCollector (Logtail) from Simple Log Service to collect text logs in real time and incrementally from ECS instances, self-managed data centers, or hosts from other cloud providers. The logs are sent to a Logstore for centralized management and analysis. To collect full logs, you can import historical log files.

Scope

  • Supported operating systems and architectures

    LoongCollector currently supports only Linux systems. For Windows hosts, you must use Logtail. We recommend using LoongCollector for new collection scenarios.

    LoongCollector is the new-generation log collection agent for Simple Log Service and is an upgrade to Logtail. You only need to install either LoongCollector or Logtail. Do not install both.
  • Computing resource requirements

    • CPU: A minimum of 0.4 cores.

    • Memory: A minimum of 300 MB.

    • Recommended usage: To ensure stable operation, keep the actual resource usage of LoongCollector (Logtail) below 80% of the limit. Actual usage depends on factors such as collection speed, the number of monitored directories and files, and any sending blockages.

  • Permission requirements

    If you use a RAM user, you must grant the AliyunLogFullAccess and AliyunECSFullAccess permissions. For more fine-grained control, see Appendix: Custom Permission Policies.

Collection configuration process

  1. Create a Project and a Logstore: A Project is a resource management unit used to isolate logs from different services. A Logstore is the basic unit for log storage.

  2. Configure a machine group (Install LoongCollector): Install LoongCollector based on the server type and add the server to a machine group. Machine groups are used to manage collection nodes, distribute configurations, and monitor server status.

  3. Create and configure log collection rules:

    • Step 1: Global and Input Configuration: Defines the name of the collection configuration, the log source, and the collection scope.

    • Step 2: Log processing and structuring: Configure data processing based on the log format.

      • Multi-line logs: This applies to single log entries that span multiple lines, such as Java exception stack traces or Python tracebacks. Use a regular expression to match the first line of each log entry.

      • Structured parsing: Configure a parsing plugin, such as a regular expression, delimiter, or NGINX pattern plugin, to extract raw strings into structured key-value pairs. This facilitates subsequent queries and analysis.

    • Step 3: Log Filtering and Classification: You can configure topics, blacklists, and content filtering rules to enable fine-grained log classification and filtering. This lets you effectively isolate sensitive information and reduce redundant data, which in turn lowers storage costs.

    • Step 4: Configure queries and analysis: By default, the full-text index is enabled for keyword searches. We recommend that you also enable the field index to perform term queries and analysis on structured fields and improve retrieval efficiency.

  4. Verification and troubleshooting: After the configuration is complete, verify that logs are being collected. For troubleshooting issues such as no data collection, heartbeat failures, or parsing errors, see Troubleshooting FAQ.

1. Create a project and a Logstore

Before you can collect logs, you must plan and create a project and a Logstore to manage and store them.

  • Project: A resource management unit of Simple Log Service, used to isolate and manage logs for different projects or services.

  • Logstore: A storage unit for logs.

If you have already created a machine group, you can skip this step and proceed directly to Configure a machine group (Install LoongCollector).

  1. Log on to the Simple Log Service console.

  2. Click Create Project and configure the following parameters:

    • Region: Select a region based on your log source. This parameter cannot be changed after the project is created.

    • Project Name: The name must be globally unique within Alibaba Cloud and cannot be changed after the project is created.

    • Leave the other parameters at their default values and click Create. For more information about the other parameters, see Manage a project.

  3. Click the project name to go to the project details page.

  4. In the navigation pane on the left, select imageLog Storage, and click +.

  5. On the Create Logstore page, configure the following parameters:

    • Logstore Name: A unique name for the Logstore within the Project that cannot be changed after creation.

    • Logstore Type: Select Standard or Query based on their specifications.

    • Billing Method:

      • Pay-by-feature: Resources such as storage, indexes, and read/write operations are billed independently. This billing method is suitable for small-scale scenarios or scenarios with unpredictable usage.

      • Pay-by-ingested-data: You are charged only for the volume of raw data written. This billing method includes a 30-day free storage period and free features, such as data transformation and delivery. This simple cost model is suitable for scenarios where the storage period is approximately 30 days or where the data processing pipeline is complex.

    • Data Retention Period: The number of days to retain logs. The value can be an integer from 1 to 3650. A value of 3650 indicates permanent storage. The default value is 30 days.

    • Leave the other parameters at their default values and click OK. For more information about other parameters, see Manage a Logstore.

2. Configure a machine group (install LoongCollector)

After you create a Project and a Logstore, install LoongCollector on your servers and add them to a machine group.

Click the target project. On the Logstores image page:

  1. Click the image icon next to the name of the target Logstore to expand the details.

  2. Click the image after Data Ingestion,

  3. In the dialog box, select the text log ingestion template, and click Ingest Now.

All text log access templates differ only in their parsing plugins. The rest of the configuration process is the same, and you can modify the plugins later.

image

Scenario 1: Alibaba Cloud ECS instances

This method applies when the log source is an Alibaba Cloud ECS instance that is in the same Alibaba Cloud account and region as the Simple Log Service project. If the ECS instance and the project are not in the same account or region, see Scenario 2: Self-managed servers (Linux/Windows) to perform a manual installation.

Procedure

  1. On the Machine Group Configuration page, configure the following parameters:

    • Scenario: Host Scenario

    • Installation Environment: ECS

  2. Configure Machine Group: Based on the LoongCollector installation status and machine group configuration of the target server, choose one of the following operations:

    • If a machine group already has LoongCollector installed, you can select it from the Source Machine Group list and add it to the Application Machine Group list. You do not need to create a new one.

    • If LoongCollector is not installed, click Create Machine Group:

      The following steps guide you through the automatic installation of LoongCollector and the creation of a new machine group.
      1. The system automatically lists the ECS instances that are in the same region as the project. Select one or more instances from which to collect logs.

      2. Click Install And Create As Machine Group. The system automatically installs LoongCollector on the selected ECS instances.

      3. Configure the machine group Name and click OK.

      Note

      If the installation fails or remains in a waiting state, verify that the ECS instance is in the same region as the project.

    • To add a server with LoongCollector installed to an existing machine group, see the FAQ: How do I add a server to an existing machine group?

Scenario 2: Self-managed servers (Linux/Windows)

If your log source is a self-managed server, such as a physical server in a local data center or a host from another cloud provider, you must install LoongCollector manually and configure a machine group to connect to Simple Log Service. Follow the steps below based on your operating system and network environment.

Procedure

  1. On the Machine Group Configuration page, configure the following parameters:

    • Scenario: Host Scenario

    • Installation Environment: Select Self-managed Machine - Linux or Self-managed Machine - Windows

  2. Configure Machine Group: Based on the LoongCollector installation status and machine group configuration of the target server, choose one of the following operations:

    • If LoongCollector is already installed and has been added to a machine group, you can directly select the machine group from the Source Machine Group list and add it to the Application Machine Group list. You do not need to create the machine group again.

    • If LoongCollector is not installed, click Create Machine Group:

      The following steps guide you through the manual installation of LoongCollector and the creation of a new machine group.
      1. Install LoongCollector (Logtail):

        Self-managed Machine - Linux

        1. Copy and run the installation command based on your network environment:

          • Alibaba Cloud Internal Network: Suitable for scenarios where you connect to the internal network from your self-managed servers.

          • Internet: This option is suitable for most scenarios and uploads log data to the target Logstore over the Internet.

          • Global Accelerator: If your server is in a mainland China region and your Simple Log Service project is in an overseas region, we recommend that you select transfer acceleration to avoid issues such as high network latency and instability when you transfer data over the Internet. However, additional charges apply to the traffic.

            Before you run the Global Accelerator installation command, you must first enable the cross-domain log transfer acceleration feature for the project.
        2. After the installation is complete, run the following command to check the status:

          sudo /etc/init.d/loongcollectord status

          If the command returns loongcollector is running, the startup was successful.

        Self-managed Machine - Windows

        1. Download the installation package for your region.

        2. Unzip logtail_installer.zip to the current directory.

        3. Run Windows PowerShell or cmd as an administrator and navigate to the logtail_installer directory.

        4. Copy and run the installation command for your network type:

          • Alibaba Cloud Internal Network: Suitable for scenarios where you connect to the internal network from your self-managed servers.

          • Internet: This option is suitable for most scenarios and uploads log data to the target Logstore over the Internet.

          • Global Accelerator: If your server and Simple Log Service project are located in regions in mainland China and outside China, we recommend that you select transfer acceleration to avoid issues such as high latency and instability over the Internet. However, traffic is billed separately.

            Before you run the Global Accelerator installation command, you must first enable the cross-domain log transfer acceleration feature for the project.
      2. Configure the user identifier (AliUid): Obtain the Alibaba Cloud account ID that owns the Simple Log Service project. Create a file named after the account ID in the specified directory.

        Replace ${AliUid} with your Alibaba Cloud account ID. If the specified directory does not exist, you must create it manually.
        • Linux: /etc/ilogtail/users/${AliUid}

        • Windows: C:\LogtailData\users\${AliUid} 

      3. Configure a custom identifier: To ensure precise machine group binding, we recommend that you use a custom identifier for machine group identification.

        Write a custom string to the specified file. If the directory does not exist, you must create it manually. The file path and name are fixed by Simple Log Service and cannot be customized.

        Note

        A machine group cannot contain both Linux and Windows servers. Do not configure the same custom identifier on both Linux and Windows servers. A server can be configured with multiple custom identifiers, separated by line feeds.

        • For Linux: write a custom string to the /etc/ilogtail/user_defined_id file, such as user-defined-test-1.

          echo "user-defined-test-1" > /etc/ilogtail/user_defined_id 
        • Windows: In C:\LogtailData\user_defined_id, write a custom string, such as user-defined-test-1.

      4. Configure a machine group: In the Machine Group Settings section of the console, configure the following:

        • Name: The name of the machine group, which must be unique within the project. The name must start and end with a lowercase letter or a digit, contain only lowercase letters, digits, hyphens (-), and underscores (_), and be 3 to 128 characters in length.

        • Machine Group Identifier: You can use a Custom Identifier or an IP Address. We recommend that you use a custom identifier. The identifier must match the custom string in the user_defined_id file on the server.

          If you want to configure an IP address as the machine group identifier, see the FAQ How do I obtain the server's IP address to use as a machine group identifier?.
  3. Click Next. The Machine Group Heartbeat Status page appears. If the Heartbeat status is OK, the machine group is connected. Click Next to proceed to the Logtail configuration page.

    If the status is FAIL, the initial heartbeat may take some time to establish. Wait for about two minutes and then refresh the heartbeat status. If the status is still FAIL after you refresh, see the FAQ topic Machine group heartbeat connection fails for troubleshooting.

3. Create and configure log collection rules

After you complete the LoongCollector installation and machine group configuration, go to the Logtail Configuration page to define log collection and processing rules.

Step 1: Global and input configuration

In this step, you define the name of the collection configuration and the source and scope of log collection.

Global Configurations:

  • Configuration Name: The name must be unique within the project and cannot be modified after creation. Naming conventions:

    • Can contain only lowercase letters, digits, hyphens (-), and underscores (_).

    • Must start and end with a lowercase letter or a digit.

Input Configuration:

  • Type: Text Log Collection.

  • File Path: The path from which to collect logs.

    • Linux: Must start with a forward slash (/). For example, /data/mylogs/**/*.log matches all files with the .log extension in the /data/mylogs directory.

    • Windows: Must start with a drive letter. For example, C:\Program Files\Intel\**\*.Log.

  • Maximum Directory Monitoring Depth: The maximum depth of subdirectories that the ** wildcard character in the File Path can match. The default value is 0, which means that only the current directory is monitored.


Step 2: Log processing and structuring

By configuring log processing rules, you can transform raw, unstructured logs into structured, searchable data. This improves the efficiency of log queries and analysis.
Before you configure processing rules, we recommend that you add a sample of the log that you want to collect. A log sample helps you accurately identify the log format and set processing parameters, such as the regular expression for multi-line logs and parsing plugins. This simplifies the configuration process. To add a sample log, perform the following operations:

On the Logtail Configuration page, in the Processing Configuration area, click Add Sample Log and enter a sample log.

Scenario 1: Process multi-line logs (such as Java stack traces)

Problem: Logs such as Java exception stack traces and JSON objects often span multiple lines. The default single-line collection mode splits them into multiple incomplete logs, which causes a loss of context.

Solution: Enable Multi-line Mode to merge multiple lines that belong to the same log entry into a single entry using a regular expression to match the first line.

Configuration steps: In the Processing Configuration area on the Logtail Configuration page, do the following:

  1. Enable Multi-line Mode:

  • Type: Select Custom or Multi-line JSON.

    • Custom: If the raw log format is not fixed, configure a Regex To Match First Line to identify the first line of each log entry.

      • Regex To Match First Line: Specifies a regular expression to match a complete line of data. You can automatically generate the expression or enter it manually. For example, the regular expression that matches the sample log is \[\d+-\d+-\w+:\d+:\d+,\d+]\s\[\w+]\s.*.

        • Automatic generation: Click Auto-generate Regular Expression. In the Sample Log text box, highlight the log content to extract and click Generate.

        • Manual entry: Click Manually Enter Regular Expression. After you enter the expression, click Validate.

    • Multi-line JSON: If all your raw logs are in standard JSON format, select this option to allow Simple Log Service to automatically handle line breaks within a single JSON log.

  • Split Failure Handling:

    • Discard: Discards text segments that do not match the first-line rule.

    • Retain Single Line: Unmatched text is split into individual lines and retained.

Raw log:

[2023-10-01T10:30:01,000] [INFO] java.lang.Exception: exception happened at TestPrintStackTrace.f(TestPrintStackTrace.java:3) at TestPrintStackTrace.g(TestPrintStackTrace.java:7) at TestPrintStackTrace.main(TestPrintStackTrace.java:16)

Single-line mode: Each line is treated as a separate log. The stack trace is broken up and the context is lost.

image

Multi-line mode: A regular expression for the first line identifies the complete log and preserves the full semantic structure.

content:[2023-10-01T10:30:01,000] [INFO] java.lang.Exception: exception happened at TestPrintStackTrace.f(TestPrintStackTrace.java:3) at TestPrintStackTrace.g(TestPrintStackTrace.java:7) at TestPrintStackTrace.main(TestPrintStackTrace.java:16)

Scenario 2: Structure logs (such as NGINX access logs)

Problem: Although logs such as NGINX access logs are single-line, all the information is packed into a single string. This makes it difficult to perform precise queries based on fields such as IP address or status code.

Solution: Use a parsing plugin, such as a regular expression, JSON, or delimiter plugin, to extract the string into key-value pairs.

Procedure (NGINX example):

  1. Add Parsing Plugin: Click Add Processing Plugin, select Native Processing Plugin > NGINX pattern parsing:

  2. NGINX Log Configuration: Copy the log_format definition from the Nginx server configuration file (nginx.conf) in its entirety and paste it into this text box.

    Example:

    log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$request_time $request_length ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent"';
    Important

    The format definition here must be exactly the same as the format used to generate logs on the server. Otherwise, log parsing fails.

Raw log:

192.168.*.* - - [15/Apr/2025:16:40:00 +0800] "GET /nginx-logo.png HTTP/1.1" 0.000 514 200 368 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.*.* Safari/537.36"

Parse into key-value pairs based on the log_format main definition:

body_bytes_sent: 368 http_referer: - http_user_agent : Mozi11a/5.0 (Nindows NT 10.0; Win64; x64) AppleMebKit/537.36 (KHTML, like Gecko) Chrome/131.0.x.x Safari/537.36 remote_addr:192.168.*.* remote_user: - request_length: 514 request_method: GET request_time: 0.000 request_uri: /nginx-logo.png status: 200 time_local: 15/Apr/2025:16:40:00

Other parsing plugins: For logs that are not in the Nginx format, you can configure plugins such as regular expression parsing, separator-based parsing, and JSON parsing based on their actual format. For detailed configuration instructions, see Appendix: Native parsing plug-ins in detail.


Step 3: Log filtering and categorization

Use fine-grained controls to collect and store only the data you need. This ensures security and reduces costs.

Configure log topics

Problem: When multiple applications or instances have logs with the same format but different paths, such as /apps/app-A/run.log and /apps/app-B/run.log, it is difficult to distinguish their sources after they are collected together.

Solution: Configure log topics to flexibly distinguish log data from different machine groups, directory paths, or business sources within the same Logstore. This improves log management efficiency and query and analysis capabilities.

Procedure:

Global Configuration > Other Global Configurations > Log Topic Type: Select the method for generating topics. The following three types are supported:

Type

Description

Machine Group Topic

When a collection configuration is applied to multiple machine groups, LoongCollector automatically uses the name of the server's machine group as the value for the __topic__ field. This is suitable for scenarios where logs are divided by host cluster.

Custom

The format is customized://<custom subject name>, for example, customized://app-login. This format applies to scenarios where static subjects have fixed business identities.

File Path Extraction

Extracts key information from the full path of a log file to dynamically tag the log source. This is suitable for cases where multiple users or applications share the same log file name but have different paths.

Details of file path extraction

When multiple users or services write logs to different top-level directories but the subdirectory paths and file names are the same, you cannot distinguish the source by file name alone. For example:

/data/logs ├── userA │ └── serviceA │ └── service.log ├── userB │ └── serviceA │ └── service.log └── userC └── serviceA └── service.log

In this case, you can configure File Path Extraction and use a regular expression to extract key information from the full path. The matched result is then uploaded to the Logstore as the log topic.

Extraction rules: Based on regular expression capturing groups

When you configure a regular expression, the system automatically determines the output field format based on the number and naming of capturing groups. The rules are as follows:

  • Single capturing group: Generates the __topic__ field.

  • Named multiple capturing groups: Generates a tag field __tag__:{name}.

  • Multiple unnamed capturing groups: generates the tag field __tag__:__topic_{i}__, where {i} is the ordinal number of the capturing group.

In the regular expression for the file path, you must escape the forward slash (/).

Capturing group type

Scenario

Regex example

Matching path example

Generated field

Single capturing group (only one (.*?))

Only one dimension is needed to distinguish the source (such as username or environment).

\/logs\/(.*?)\/app\.log

/logs/userA/app.log

__topic__: userA

Multiple unnamed capturing groups (multiple (.*?))

Multiple dimensions are needed, but no semantic labels.

\/logs\/(.*?)\/(.*?)\/app\.log

/logs/userA/svcA/app.log

__tag__:__topic_1__userA.

__tag__:__topic_2__svcA

Multiple named capturing groups ((?P<name>.*?))

Multiple dimensions are needed, and you want the field meanings to be clear for easy querying and analysis.

\/logs\/(?P<user>.*?)\/(?P<service>.*?)\/app\.log

/logs/userA/svcA/app.log

__tag__:user:userA.

__tag__:service:svcA


Reduce costs by filtering content

Problem: The volume of DEBUG or INFO level logs is huge, but daily troubleshooting requires only WARNING or ERROR level logs. Collecting all logs creates unnecessary costs.

Solution: Add a Data Filtering plugin to collect only logs that meet specified conditions.

Procedure

Click Add Processor, and select Native Processor > Data Filtering:

  • Field Name: The log field to filter by.

  • Field Value: The regular expression used for filtering. Only full-text matching is supported.

Raw log:

{"level":"WARNING","timestamp":"2025-09-23T19:11:40+0800","cluster":"yilu-cluster-0728","message":"Disk space is running low","freeSpace":"15%"} {"level":"ERROR","timestamp":"2025-09-23T19:11:42+0800","cluster":"yilu-cluster-0728","message":"Failed to connect to database","errorCode":5003} {"level":"INFO","timestamp":"2025-09-23T19:11:47+0800","cluster":"yilu-cluster-0728","message":"User logged in successfully","userId":"user-123"}

Filter logs: Set the Field Name to level and the Field Value to WARNING|ERROR. This will collect only logs where the level field is WARNING or ERROR.

{"level":"WARNING","timestamp":"2025-09-23T19:11:40+0800","cluster":"yilu-cluster-0728","message":"Disk space is running low","freeSpace":"15%"} {"level":"ERROR","timestamp":"2025-09-23T19:11:42+0800","cluster":"yilu-cluster-0728","message":"Failed to connect to database","errorCode":5003}

Control collection scope with a blacklist

Problem: In a production environment, some directories or files may contain debug logs, temporary data, or sensitive information such as user privacy or configuration files. Collecting this content indiscriminately leads to log redundancy, increased storage costs, and the risk of a data breach.

Solution: Enable the collection blacklist feature to proactively exclude specified directories or files. This prevents irrelevant or sensitive logs from being uploaded.

Procedure:

Input Configurations > Other Input Configurations: Enable Collection Blacklist, click Add, and configure the blacklist.

Supports full matching and wildcard matching for directories and filenames. Wildcard characters only support the asterisk (*) and the question mark (?).
  • File Path Blacklist: The file path to be ignored. Example:

    • /home/admin/private*.log: During collection, ignore all files in the /home/admin/ directory that start with "private" and end with ".log".

    • /home/admin/private*/*_inner.log: During collection, ignore files ending with "_inner.log" within directories that start with "private" under the /home/admin/ directory.

  • File Blacklist: Configure the filenames to be ignored during collection. Example:

    • app_inner.log: During collection, ignore all files named app_inner.log.

  • Directory Blacklist: The directory path cannot end with a forward slash (/). Example:

    • /home/admin/dir1/: The directory blacklist will not take effect.

    • /home/admin/dir*: During collection, ignore files in subdirectories that start with "dir" under the /home/admin/ directory.

    • /home/admin/*/dir: During collection, ignore all files in subdirectories named "dir" at the second level under the /home/admin/ directory. For example, files in the /home/admin/a/dir directory are ignored, while files in the /home/admin/a/b/dir directory are collected.

Step 4: Configure query and analysis

After you configure log processing and plug-ins, click Next. The Query And Analysis Configuration page appears.

  • By default, the full-text index is enabled. This lets you search raw log content by keyword.

  • To perform term queries by field, click Auto Generate Index after the Preview Data loads. Simple Log Service then generates a field index based on the first log entry in the preview data.

After you complete the configuration, click Next to finish the collection setup.

4. Verification and troubleshooting

After you complete the configuration, apply it to the machine group and save it. Wait a few moments, and then use the following checklist to verify the setup.

Verification checklist

  1. Confirm that new content is added to the log file: LoongCollector collects only incremental logs. Run the tail -f /path/to/your/log/file command and trigger a business operation to make sure that new logs are being written.

  2. Check the LoongCollector status: sudo /etc/init.d/loongcollectord status.

  3. Check the machine group heartbeat: Go to the imageResources > Machine Groups page. Click the name of the target machine group. In the Machine Group Settings > Machine Group Status section, check the Heartbeat status.

    • If the heartbeat status is OK, the machine group is connected to the Simple Log Service project.

    • If the heartbeat status is FAIL, see The machine group heartbeat is FAIL for troubleshooting.

  4. Query logs: Go to the query and analysis page of the target Logstore to check if new data is reported.

FAQ

The machine group heartbeat is FAIL

  1. Check the user identifier: If your server is not an ECS instance, or if the ECS instance and the project belong to different Alibaba Cloud accounts, check the specified directory for the correct user identifier as shown in the following table.

    System

    Specified directory

    Solution

    Linux

    /etc/ilogtail/users/

    Run the cd /etc/ilogtail/users/ && touch <uid> command to create the user identifier file.

    Windows

    C:\LogtailData\users\

    Go to the C:\LogtailData\users\ directory and create an empty file named <uid>.

    If a file named after the Alibaba Cloud account ID of the project exists in the specified path, the user identifier is configured correctly.

  2. Check the machine group identifier: If you use a machine group with a custom identifier, check if the user_defined_id file exists in the specified directory. If the file exists, check if its content matches the custom ID configured for the machine group.

    System

    Specified directory

    Solution

    Linux

    /etc/ilogtail/user_defined_id

    # Configure the custom identifier. If the directory does not exist, create it manually. echo "user-defined-1" > /etc/ilogtail/user_defined_id

    Windows

    C:\LogtailData\user_defined_id

    In the C:\LogtailData directory, create a user_defined_id file and write the custom identifier in it. If the directory does not exist, create it manually.

  3. If both the user identifier and the machine group identifier are configured correctly, see Troubleshoot LoongCollector (Logtail) machine group issues for more information.


No data is collected from logs

  1. Check for incremental logs: After you configure LoongCollector (Logtail) for collection, it does not collect data from a log file if no new logs are added.

  2. Check the machine group heartbeat status: Go to the imageResources > Machine Groups page. Click the name of the target machine group. In the Machine Group Settings > Machine Group Status section, check the Heartbeat status.

    • If the heartbeat status is OK, the machine group is connected to the Simple Log Service project.

    • If the heartbeat status is FAIL, see The machine group heartbeat is FAIL for troubleshooting.

  3. Confirm that the LoongCollector (Logtail) collection configuration is applied to the machine group: Logs cannot be collected if the LoongCollector (Logtail) collection configuration is not applied to the machine group, even if the configuration is created.

    1. Go to the imageResources > Machine Groups page. Click the name of the target machine group to go to the Machine Group Settings page.

    2. On the page, find Manage Configurations. The All Logtail Configurations list is on the left, and the Applied Logtail Configurations list is on the right. If the target LoongCollector (Logtail) collection configuration is in the list on the right, it is successfully applied to the machine group.

    3. If the target LoongCollector (Logtail) collection configuration is not in the list on the right, click Modify. In the All Logtail Configurations list on the left, select the target LoongCollector (Logtail) configuration. Click image to move it to the list on the right, then click Save.


Log collection errors or incorrect format

Troubleshooting: This type of issue indicates that your network connectivity and basic configuration are correct. The problem is usually a mismatch between the log content and the parsing rules. Check the specific error message to identify the cause of the problem:

  1. On the Logtail Configurations page, click the name of the LoongCollector (Logtail) configuration that has errors. On the Log Collection Errors tab, click Time Range to set the time range for the query.

  2. In the Collection Error Monitoring > Full Error Information area, view the Alarm Metric for the error log and find the corresponding solution in Common error types for data collection.

Quotas and limits

Limit

Description

Single log length

The default limit is 512 KB. You can adjust this limit using the max_read_buffer_size startup parameter. The maximum size cannot exceed 8 MB. For more information, see Logtail network types, startup parameters, and configuration files.

After a multi-line log is split by the regular expression that matches the start of a line, each resulting log entry is still limited to 512 KB. If a log entry exceeds 512 KB, it is split into multiple entries for collection. For example, if a log entry is 1025 KB, Logtail processes 512 KB, then another 512 KB, and finally 1 KB. This results in multiple incomplete log entries.

File encoding

Logtail supports log files encoded in UTF-8 or GBK. Use UTF-8 encoding for better performance.

Warning

If a log file uses a different encoding format, issues such as garbled characters and data loss may occur.

Log file rotation

The default size of the log rotation queue is 20. You can adjust this size using the logreader_max_rotate_queue_size startup parameter. For more information, see Logtail network types, startup parameters, and configuration files.

You can set the collection path to either xxx.log or xxx.log*.

Important

Do not mix these two formats in the same Logtail instance. This can cause a single file to match multiple Logtail collection configurations, which results in duplicate data collection.

If more than 20 files are waiting to be processed, newly generated logs are lost. If this happens, first check whether the Logstore shard write quota is exceeded. Then, adjust the Logtail concurrency level. For more information, see Logtail network types, startup parameters, and configuration files.

Collection behavior when log parsing is blocked

If log parsing is blocked, Logtail keeps the log file descriptor open. This prevents the file from being deleted and avoids data loss.

If log files are rotated while parsing is blocked, Logtail adds the files to the rotation queue.

Regular expression

Logtail supports Perl-compatible regular expressions.

JSON

Logtail fully supports standard JSON (RFC7159 and ECMA-404). Non-standard JSON, such as {"name": "\xE5\xAD\xA6"}, is not supported.

File open behavior

Logtail keeps collected files and files in the rotation queue open to ensure data integrity. A file is closed in the following situations:

  • The file has not been modified for more than 5 minutes.

  • The file is rotated and collection is complete.

  • The Logtail collection configuration changes.

To release a file handle within a specific time after the file is deleted, use the force_release_deleted_file_fd_timeout startup parameter to set a timeout. This occurs regardless of whether collection is complete or logs are still being written to the file. For more information, see Logtail network types, startup parameters, and configuration files.

Initial log collection behavior

Logtail collects only incremental changes to log files. When Logtail detects a modified file for the first time, it starts collection from a specific point. If the file is larger than 1 MB (512 KB for container standard output), collection starts from the last 1 MB of the file. Otherwise, collection starts from the beginning of the file.

You can adjust the initial collection size for new files using the tail_size_kb parameter in the Logtail configuration. For more information, see Logtail configuration (Legacy).

If a log file is not modified after you apply a Logtail collection configuration, Logtail does not collect data from that file. To collect data from historical files, see Import historical log files.

Behavior when a file is overwritten

Logtail identifies a file by its inode and a hash of its first 1024 bytes. If a file is overwritten and its inode or the hash of its first 1024 bytes changes, Logtail treats it as a new file and collects it from the beginning. Otherwise, the file is not collected.

Behavior when a file is moved

If a file is moved, Logtail treats it as a new file and collects it from the beginning if it matches a Logtail collection configuration that has not previously matched the file. Otherwise, the file is not collected.

File collection history

Logtail stores the collection progress for files in memory. This ensures that only incremental changes are collected when a file is modified. If data is written to a file that is outside the retention scope, duplicate collection occurs.

  • By default, history for files modified within the last month is retained.

  • If a folder contains more than 5,000 historical files, only records from the last week are kept.

  • If a folder contains more than 10,000 historical files, only records from the last day are kept.

Non-standard text logs

For log entries that contain the \0 character, versions >2.1.10 and >3.0.12 retain only the \0 characters in the middle of the entry and discard the \0 characters that are used as prefixes or suffixes. Other versions may truncate the entry at the first \0 character or retain all null characters. We recommend that you upgrade. For other escape characters, such as ASCII codes that are used to represent colors or non-printable characters, Logtail sends the characters directly.

Billing

  • Installing LoongCollector or Logtail is free of charge.

  • You are charged for log writing, storage, indexing, querying, processing, and delivery based on the Logstore billing model.

  • If you use the Global Accelerator feature during installation or configuration, you incur additional traffic fees for data transmitted over the accelerated network.

FAQ

How do I send logs from an ECS server to a Project in another Alibaba Cloud account?

If you have not installed LoongCollector, see Install LoongCollector (Linux) and select the appropriate cross-account scenario for installation.

If you have already installed LoongCollector, follow these steps to configure a custom identifier. This identifier grants the server permission to be accessed by the Alibaba Cloud account that owns the Simple Log Service project, which allows log collection.

You only need to configure a custom identifier when collecting logs from an ECS instance that is not under your account, a self-managed IDC, or a server from another cloud provider.
  1. Copy the ID of the Alibaba Cloud account that owns Simple Log Service. Hover your mouse over your profile picture in the upper-right corner. You can view and copy the account ID from the tab that appears.

  2. Log on to the server from which you want to collect logs and create an Alibaba Cloud account ID file to configure the custom identifier:

    touch /etc/ilogtail/users/{Alibaba Cloud account ID} # If the /etc/ilogtail/users folder does not exist, create it manually. The custom identifier configuration file only needs a file name, not a file extension.

How do I send logs from an ECS server to a Project in a different region under the same account?

If you have not installed LoongCollector, see Install LoongCollector (Linux) and select the appropriate cross-region scenario for installation.

If LoongCollector is already installed, you need to modify its configuration.

  1. Run the sudo /etc/init.d/ilogtaild stop command to stop LoongCollector.

  2. Modify the LoongCollector startup configuration file ilogtail_config.json. Choose one of the following two methods based on your network requirements:

    Configuration file path: /usr/local/ilogtail/ilogtail_config.json

    • Method 1: Use the Internet for transmission

      See Region IDs and replace the region in the configuration file with the region where Simple Log Service is located. The fields to modify include the following:

      • primary_region

      • The region part in config_servers

      • The region and the region part of endpoint_list in data_servers

    • Method 2: Use transfer acceleration

      Replace the endpoint line in the data_server_list parameter with log-global.aliyuncs.com. For the file path, see Logtail network types, startup parameters, and configuration files.

    Configuration file example

    { "primary_region" : "cn-shanghai", "config_servers" : [ "http://logtail.cn-shanghai.log.aliyuncs.com" ], "data_servers" : [ { "region" : "cn-shanghai", "endpoint_list": [ "cn-shanghai.log.aliyuncs.com" ] } ], "cpu_usage_limit" : 0.4, "mem_usage_limit" : 384, "max_bytes_per_sec" : 20971520, "bytes_per_sec" : 1048576, "buffer_file_num" : 25, "buffer_file_size" : 20971520, "buffer_map_num" : 5 }
  1. Run the sudo /etc/init.d/ilogtaild start command to start LoongCollector.

How do I add a server to an existing machine group?

If you have a configured machine group and want to add a new server, such as a newly deployed ECS instance or a self-managed server, to inherit its collection configurations, you can attach it by following these steps.

Prerequisites:

  • A configured machine group already exists.

  • LoongCollector is installed on the new server. For more information, see Install LoongCollector.

Procedure:

  1. View the identifier of the target machine group:

    1. On the page of the target Project, in the navigation pane on the left, click imageResource > Machine Groups.

    2. On the Machine Groups page, click the name of the target machine group.

    3. On the machine group configuration page, view the machine group identifier.

  2. Perform the corresponding operation based on the identifier type:

    Note

    A machine group cannot contain both Linux and Windows servers. Do not configure the same custom identifier on both Linux and Windows servers. A server can have multiple custom identifiers, separated by line feeds.

    • Type 1: The machine group identifier is an IP address

      1. On the server, run the following command to open the app_info.json file and view the ip value.

        cat /usr/local/ilogtail/app_info.json
      2. On the target machine group configuration page, click Modify. Enter the IP address of the server. Separate multiple IP addresses with line feeds.

      3. After the configuration is complete, click Save and confirm the heartbeat status. If the status is OK, the server automatically applies the collection configurations of the machine group.

        If the heartbeat status is FAIL, see the FAQ The heartbeat of a machine group is FAIL for troubleshooting.
    • Type 2: The machine group identifier is a custom identifier

      Based on the operating system, write the custom identifier string that matches the target machine group to the specified file:

      If the folder does not exist, you must create it manually. The file path and name are fixed by Simple Log Service and cannot be customized.
      • Linux: Write the custom string to the /etc/ilogtail/user_defined_id file.

      • Windows: Write the custom string to C:\LogtailData\user_defined_id.

How do I import collection configurations from another Project?

After you create a Project and a Logstore and configure a machine group, you can quickly import collection configurations from an existing project to the current Logstore. This avoids reconfiguration and improves efficiency.

Procedure:

  1. After you configure the machine group, click Next to go to the Logtail Configuration page.

  2. In the upper-right corner of the page, click Import Other Configurations.

  3. Select the Project and the collection configuration under that Project to import.

  4. Click OK. The system automatically loads the selected configuration.

  5. After you check that the imported configuration information is correct, click Next to go to the Query and Analysis Configuration page and complete the subsequent configurations.

How do I get the IP address of a server to use as a machine group identifier?

On a server where LoongCollector (Logtail) is installed, open the /usr/local/ilogtail/app_info.json file to view the ip value.

The server IP address that Logtail automatically obtains is recorded in the ip field of the app_info.json file, as shown below.IP地址

Important
  • If you have multiple servers, you must manually enter their IP addresses. Separate the IP addresses with line feeds.

  • A machine group cannot contain both Linux and Windows servers. Do not add the IP addresses of both Windows and Linux servers to the same Machine Group.

How can I have the same log file collected by multiple collection configurations at the same time?

By default, to avoid data duplication, Simple Log Service allows a text log file to be collected by only one Logtail configuration. To have the same log file collected by multiple configurations simultaneously, you must manually enable the feature that allows a file to be collected multiple times.

Procedure:

Important

When a file is collected multiple times, the file read I/O, computing resources, and network I/O all increase linearly.

  1. Log on to the Simple Log Service console and go to the target Project.

  2. In the navigation pane on the left, choose imageLogstores and find the target Logstore.

  3. Click image next to its name to expand the Logstore.

  4. Click Logtail Configurations. In the configuration list, find the target Logtail configuration and click Manage Logtail Configuration in the Actions column.

  5. On the Logtail configuration page, click Edit:

    • Choose Input Configurations > Other Input Configurations and enable Allow Multiple Collections For A File.

  6. After the configuration is complete, click Save.

Why is the last log segment reported after a long delay? Why is it sometimes truncated?

Cause analysis: Log truncation usually occurs when a log file is missing a line feed at the end, or when a multi-line log, such as an exception stack, has not been fully written. Because the collector cannot determine whether the log entry is complete, the last segment might be split prematurely or reported with a delay. Different versions of LoongCollector (Logtail) handle this differently:

  • Versions earlier than 1.8:
    If the last line of a log does not have a line feed (carriage return), or if a multi-line log paragraph is not finished, the collector waits for the next write to trigger an output. This can cause the last log entry to be held for a long time and not sent until a new log is written.

  • Versions 1.8 and later:
    A timeout refresh mechanism was introduced to prevent logs from getting stuck. When an incomplete log line is detected, the system starts a timer. After the timeout, it automatically submits the current content to ensure the log is eventually collected.

    • Default timeout: 60 seconds (This ensures integrity in most scenarios).

    • You can adjust this value as needed, but setting it to 0 is not recommended because doing so may cause log truncation or partial data loss.

Solution:

You can extend the waiting time to ensure the complete log is written before it is collected:

  1. Log on to the Simple Log Service console and go to the target Project.

  2. In the navigation pane on the left, choose imageLogstores and find the target Logstore.

  3. Click image next to its name to expand the Logstore.

  4. Click Logtail Configurations. In the configuration list, find the target Logtail configuration and click Manage Logtail Configuration in the Actions column.

  5. On the Logtail configuration page, click Edit:

    • Choose Input Configurations > Other Input Configurations > Advanced Parameters. Add the following JSON configuration to customize the timeout period:

      { "FlushTimeoutSecs": 1 }
      • Default value: Determined by the startup parameter default_reader_flush_timeout (usually a few seconds).

      • Unit: Seconds.

      • Recommended value: ≥1 second. Setting it to 0 is not recommended because it may cause log truncation or partial data loss.

  6. After the configuration is complete, click Save.

Why does LoongCollector (Logtail) switch from an internal endpoint to a public endpoint during operation? Can it automatically switch back?

During operation, if LoongCollector (Logtail) detects an issue with communication over the internal endpoint, such as a network failure or connection timeout, it automatically switches to the public endpoint to send data. This switch ensures the continuity and reliability of log collection and prevents logs from stacking up or being lost.

  • LoongCollector: Automatically switches back to the internal network after it recovers.

  • Logtail: Does not automatically switch back. You must restart it manually to resume communication over the internal network.

Appendix: Native parsing plug-ins in detail

On the Logtail Configuration page, in the Processor Configurations section, you can add processing plugins to structure raw logs. To add a processing plugin to an existing collection configuration, perform the following steps:

  1. In the navigation pane on the left, choose imageLogstores and find the destination Logstore.

  2. Click image next to its name to expand the Logstore.

  3. Click Logtail Configurations. In the list of configurations, find the target Logtail configuration and click Manage Logtail Configuration in the Actions column.

  4. On the Logtail Configuration page, click Edit.

This section introduces common processing plug-ins for typical log processing scenarios. For more features, see Extension processing plug-ins.
Important

Rules for combining plug-ins (for LoongCollector / Logtail 2.0 and later):

  • Native processing plug-ins and extension processing plug-ins can be used independently or combined as needed.

  • Prioritize native processing plug-ins because they offer better performance and greater stability.

  • If native features do not meet your needs, append extension processing plug-ins after the configured native plug-ins for additional processing.

Order constraint:

All plug-ins form a processing chain and are executed in the order they are configured. Note: All native processing plug-ins must precede any extension processing plug-ins. After you add an extension processing plug-in, you can no longer add native processing plug-ins.

Regular expression parsing

Use regular expressions to extract log fields and parse logs into key-value pairs.

Configure Regular expression parsing. To add one, click Add Processing Plug-in and choose Native Processing Plug-in > Regular Expression Parsing. The parameters are described as follows:

  • Regular Expression: Used to match logs. You can generate it automatically or enter it manually:

    • Automatic generation:

      • Click Automatically Generate Regular Expression.

      • In the Sample Log, highlight the log content to extract.

      • Click Generate Regular Expression.

        image

    • Manual entry: Manually Enter A Regular Expression based on the log format.

    After configuration, click Validate to test if the regular expression can correctly parse the log content.

  • Log Extraction Fields: Set the corresponding field name (Key) for the extracted log content (Value).

Raw log:

127.0.0.1 - - [16/Aug/2024:14:37:52 +0800] "GET /wp-admin/admin-ajax.php?action=rest-nonce HTTP/1.1" 200 41 "http://www.example.com/wp-admin/post-new.php?post_type=page" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0"

Custom regular expression parsing: Regular expression (\S+)\s-\s(\S+)\s\[([^]]+)]\s"(\w+)\s(\S+)\s([^"]+)"\s(\d+)\s(\d+)\s"([^"]+)"\s"([^"]+).*.

body_bytes_sent: 41 http_referer: http://www.example.com/wp-admin/post-new.php?post_type=page http_user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; ×64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0 remote_addr: 127.0.0.1 remote_user: - request_method: GET request_protocol: HTTP/1.1 request_uri: /wp-admin/admin-ajax.php?action=rest-nonce status: 200 time_local: 16/Aug/2024:14:37:52 +0800

Separator parsing

Use a separator to structure log content and parse it into multiple key-value pairs. Single-character and multi-character separators are supported.

Configure Separator parsing. To add one, click Add Processing Plug-in and choose Native Processing Plug-in > Separator Parsing. The parameters are described as follows:

  • Separator: Specify the character used to split the log content.

    Example: For a CSV file, select Custom and enter a comma (,).

  • Quote: If a field value contains the separator, specify a quote character to enclose the field to prevent incorrect splitting.

  • Log Extraction Fields: Set the corresponding field name (Key) for each column in the order they are separated. The rules are as follows:

    • Field names can contain only letters, digits, and underscores (_).

    • They must start with a letter or an underscore (_).

    • Maximum length: 128 bytes.

Raw log:

05/May/2025:13:30:28,10.10.*.*,"POST /PutData?Category=YunOsAccountOpLog&AccessKeyId=****************&Date=Fri%2C%2028%20Jun%202013%2006%3A53%3A30%20GMT&Topic=raw&Signature=******************************** HTTP/1.1",200,18204,aliyun-sdk-java

Split fields by the specified character ,:

ip:10.10.*.* request:POST /PutData?Category=YunOsAccountOpLog&AccessKeyId=****************&Date=Fri%2C%2028%20Jun%202013%2006%3A53%3A30%20GMT&Topic=raw&Signature=******************************** HTTP/1.1 size:18204 status:200 time:05/May/2025:13:30:28 user_agent:aliyun-sdk-java

Standard JSON parsing

Structure Object-type JSON logs and parse them into key-value pairs.

Configure JSON parsing. To add one, click Add Processing Plug-in and choose Native Processing Plug-in > JSON Parsing. The parameters are described as follows:

  • Source Field: The default value is content. This field stores the raw log content to be parsed.

  • Keep the default settings for other configurations.

Raw log:

{"url": "POST /PutData?Category=YunOsAccountOpLog&AccessKeyId=U0Ujpek********&Date=Fri%2C%2028%20Jun%202013%2006%3A53%3A30%20GMT&Topic=raw&Signature=pD12XYLmGxKQ%2Bmkd6x7hAgQ7b1c%3D HTTP/1.1", "ip": "10.200.98.220", "user-agent": "aliyun-sdk-java", "request": {"status": "200", "latency": "18204"}, "time": "05/Jan/2025:13:30:28"}

Automatic extraction of standard JSON key-value pairs:

ip: 10.200.98.220 request: {"status": "200", "latency" : "18204" } time: 05/Jan/2025:13:30:28 url: POST /PutData?Category=YunOsAccountOpLog&AccessKeyId=U0Ujpek******&Date=Fri%2C%2028%20Jun%202013%2006%3A53%3A30%20GMT&Topic=raw&Signature=pD12XYLmGxKQ%2Bmkd6x7hAgQ7b1c%3D HTTP/1.1 user-agent:aliyun-sdk-java

Nested JSON parsing

Parse nested JSON logs into key-value pairs by specifying an expansion depth.

Click Add Processing Plug-in and choose Extension Processing Plug-in > Unfold JSON Field. The parameters are described as follows:

  • Source Field: The name of the source field to unfold, for example, content.

  • JSON Unfold Depth: The expansion level for the JSON object. A value of 0 indicates full expansion (default), 1 indicates the current level, and so on.

  • JSON Unfold Connector: The connector for field names during JSON expansion. The default is an underscore (_).

  • JSON Unfold Field Prefix: Specify a prefix for the field names after JSON expansion.

  • Unfold Array: Enable this option to expand an array into key-value pairs with indexes.

    Example: {"k":["a","b"]} is expanded to {"k[0]":"a","k[1]":"b"}.

    To rename the expanded fields (for example, to change prefix_s_key_k1 to new_field_name), you can then add a Rename Field plugin to complete the mapping.

Raw log:

{"s_key":{"k1":{"k2":{"k3":{"k4":{"k51":"51","k52":"52"},"k41":"41"}}}}}

Unfold depth: 0, using the unfold depth as the prefix.

0_s_key_k1_k2_k3_k41:41 0_s_key_k1_k2_k3_k4_k51:51 0_s_key_k1_k2_k3_k4_k52:52

Unfold depth: 1, using the unfold depth as the prefix.

1_s_key:{"k1":{"k2":{"k3":{"k4":{"k51":"51","k52":"52"},"k41":"41"}}}}

JSON array parsing

Use the json_extract function to extract JSON objects from a JSON array.

Switch Processing Method to SPL:

  • SPL Statement: Use the json_extract function to extract JSON objects from a JSON array.

    Example: Extract elements from the JSON array in the content log field and store the results in new fields named json1 and json2.

    * | extend json1 = json_extract(content, '$[0]'), json2 = json_extract(content, '$[1]')

Raw log:

[{"key1":"value1"},{"key2":"value2"}]

Extracted JSON array structure:

json1:{"key1":"value1"} json2:{"key2":"value2"}

Apache log parsing

Structure log content and parse it into multiple key-value pairs based on the definitions in the Apache log configuration file.

Configure APACHE Pattern Parsing. To add one, click Add Processing Plug-in and choose Native Processing Plug-in > APACHE Pattern Parsing. The parameters are described as follows:

  • Log Format: combined

  • APACHE Configuration Fields: The system automatically fills in the configuration based on the Log Format.

    Important

    Verify the auto-filled content to ensure it exactly matches the LogFormat defined in the Apache configuration file on your server, which is typically located at /etc/apache2/apache2.conf.

Raw log:

1 192.168.1.10 - - [08/May/2024:15:30:28 +0800] "GET /index.html HTTP/1.1" 200 1234 "https://www.example.com/referrer" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.X.X Safari/537.36"

Apache Common Log Format combined parsing:

http_referer:https://www.example.com/referrer http_user_agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.X.X Safari/537.36 remote_addr:192.168.1.10 remote_ident:- remote_user:- request_method:GET request_protocol:HTTP/1.1 request_uri:/index.html response_size_bytes:1234 status:200 time_local:[08/May/2024:15:30:28 +0800]

IIS log parsing

Structure log content and parse it into multiple key-value pairs based on the IIS log format definition.

Configure IIS Pattern Parsing. To add one, click Add Processing Plug-in and choose Native Processing Plug-in > IIS Pattern Parsing. The parameters are described as follows:

  • Log Format: Select the log format used by your IIS server logs.

    • IIS: Microsoft IIS log file format.

    • NCSA: NCSA Common Log Format.

    • W3C: W3C Extended Log File Format.

  • IIS Configuration Fields: When you select IIS or NCSA, Simple Log Service sets the IIS configuration fields by default. When you select W3C, set this to the content of the logExtFileFlags parameter in your IIS configuration file. For example:

    logExtFileFlags="Date, Time, ClientIP, UserName, SiteName, ComputerName, ServerIP, Method, UriStem, UriQuery, HttpStatus, Win32Status, BytesSent, BytesRecv, TimeTaken, ServerPort, UserAgent, Cookie, Referer, ProtocolVersion, Host, HttpSubStatus"

Raw log:

#Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken

Adaptation for Microsoft IIS server-specific format:

c-ip: cs-username cs-bytes: sc-substatus cs-method: cs-method cs-uri-query: cs-uri-query cs-uri-stem: cs-uri-stem cs-username: s-port date: #Fields: s-computername: s-sitename s-ip: s-ip s-sitename: time sc-bytes: sc-status sc-status: c-ip sc-win32-status: cs (User-Agent) time: date time-taken: sc-win32-status

Data masking

Mask sensitive data in logs.

Click Add Processing Plug-in and choose Native Processing Plug-in > Data Masking. The parameters are described as follows:

  • Source Field: The source field that stores the log content before parsing.

  • Masking Method:

    • const: Replace sensitive content with a specified string.

    • md5: Replace sensitive content with its corresponding MD5 hash.

  • Replacement String: If you set Masking Method to const, enter a string to replace the sensitive content.

  • Expression Before Content To Be Replaced: Used to find sensitive content. Configure it using RE2 syntax.

  • Expression For Content To Be Replaced: The expression for the sensitive content. Configure it using RE2 syntax.

Raw log:

[{'account':'1812213231432969','password':'04a23f38'}, {'account':'1812213685634','password':'123a'}]

Masking result:

[{'account':'1812213231432969','password':'********'}, {'account':'1812213685634','password':'********'}]

Time parsing

Parse the time field in a log and set the parsing result as the log's __time__ field.

Click Add Processing Plug-in and choose Native Processing Plug-in > Time Parsing. The parameters are described as follows:

  • Source Field: The source field that stores the log content before parsing.

  • Time Format: Set the corresponding time format based on the time content in the log.

  • Time Zone: Select the time zone of the log's time field. By default, the machine's time zone is used, which is the time zone of the environment where the LoongCollector (Logtail) process is running.

Raw log:

{"level":"INFO","timestamp":"2025-09-23T19:11:47+0800","cluster":"yilu-cluster-0728","message":"User logged in successfully","userId":"user-123"}

Time parsing:

image

Appendix: Access policy reference

Alibaba Cloud account: By default, an Alibaba Cloud account has full permissions and can perform all operations.

RAM user: An Alibaba Cloud account must grant a corresponding access policy to the RAM user.

Custom policies (fine-grained control)

If system policies do not meet the principle of least privilege, you can create a custom policy. Use the following example policy, which includes the following primary permissions:

  • View projects: View the list of projects and the details of a specific project.

  • Manage Logstores: Create, modify, or delete Logstores in a project.

  • Manage collection configurations: Create, delete, and modify collection configurations.

  • View logs: Query and analyze data in a specific Logstore within a specific project.

Replace ${regionName}, ${uid}, ${projectName}, and ${logstoreName} with the actual region, Alibaba Cloud account ID, target project, and Logstore name.

Example policy

{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "log:ListProject", "log:GetAcceleration", "log:ListDomains", "log:GetLogging", "log:ListTagResources" ], "Resource": "acs:log:${regionName}:${uid}:project/*" }, { "Effect": "Allow", "Action": "log:GetProject", "Resource": "acs:log:${regionName}:${uid}:project/${projectName}" }, { "Effect": "Allow", "Action": [ "log:ListLogStores", "log:*LogStore", "log:*Index", "log:ListShards", "log:GetCursorOrData", "log:GetLogStoreHistogram", "log:GetLogStoreContextLogs", "log:PostLogStoreLogs" ], "Resource": "acs:log:${regionName}:${uid}:project/${projectName}/*" }, { "Effect": "Allow", "Action": "log:*", "Resource": [ "acs:log:${regionName}:${uid}:project/${projectName}/logtailconfig/*", "acs:log:${regionName}:${uid}:project/${projectName}/machinegroup/*" ] }, { "Effect": "Allow", "Action": "log:ListSavedSearch", "Resource": "acs:log:${regionName}:${uid}:project/${projectName}/savedsearch/*" }, { "Effect": "Allow", "Action": "log:ListDashboard", "Resource": "acs:log:${regionName}:${uid}:project/${projectName}/dashboard/*" }, { "Effect": "Allow", "Action": "log:GetLogStoreLogs", "Resource": "acs:log:${regionName}:${uid}:project/${projectName}/logstore/${logstoreName}" }, { "Effect": "Allow", "Action": [ "ecs:DescribeTagKeys", "ecs:DescribeTags", "ecs:DescribeInstances", "ecs:DescribeInvocationResults", "ecs:RunCommand", "ecs:DescribeInvocations", "ecs:InvokeCommand" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "oos:ListTemplates", "oos:StartExecution", "oos:ListExecutions", "oos:GetExecutionTemplate", "oos:ListExecutionLogs", "oos:ListTaskExecutions" ], "Resource": "*" } ] }

Permission

Operations

Resource

Read-only access to projects

  • GetAcceleration

  • GetLogging

  • ListProject

  • ListDomains

  • ListTagResources

acs:log:${regionName}:${uid}:project/*

Get a specific project

GetProject

acs:log:${regionName}:${uid}:project/${projectName}

Manage Logstores

  • ListLogStores

  • *LogStore

  • *Index

  • ListShards

  • GetCursorOrData

  • GetLogStoreHistogram

  • GetLogStoreContextLogs

  • PostLogStoreLogs

acs:log:${regionName}:${uid}:project/${projectName}/*

Manage Logtail data collection

*

  • acs:log:${regionName}:${uid}:project/${projectName}/logtailconfig/*

  • acs:log:${regionName}:${uid}:project/${projectName}/machinegroup/*

Query saved searches

ListSavedSearch

acs:log:${regionName}:${uid}:project/${projectName}/savedsearch/*

Query dashboards

ListDashboard

acs:log:${regionName}:${uid}:project/${projectName}/dashboard/*

Query logs of a specific Logstore

GetLogStoreLogs

acs:log:${regionName}:${uid}:project/${projectName}/logstore/${logstoreName}

ECS operation permissions

  • DescribeTagKeys

  • DescribeTags

  • DescribeInstances

  • DescribeInvocationResults

  • RunCommand

  • DescribeInvocations

  • InvokeCommand

*

OOS operation permissions (Optional)

Required only to automatically install Logtail using OOS when the Simple Log Service project and the ECS instance are in the same account and region.

  • ListTemplates

  • StartExecution

  • ListExecutions

  • GetExecutionTemplate

  • ListExecutionLogs

  • ListTaskExecutions

*

System policies

When using system-defined policies, add the following permissions:

  • AliyunLogFullAccess: Grants permissions to manage Simple Log Service.

  • AliyunECSFullAccess: Grants permissions to manage ECS.

  • (Optional) AliyunOOSFullAccess: Required to install Logtail from OOS with a single click.

More information

Global configuration parameters

Parameter

Description

Configuration Name

The name of the LoongCollector (Logtail) configuration. The name must be unique within the project. You cannot change the name after the configuration is created.

Topic Type

Select how to generate a topic. Options include Machine Group Topic, File Path, and Custom.

Advanced Parameters

Other optional advanced parameters related to the global configuration. For more information, see CreateLogtailPipelineConfig.

Input configuration parameters

Parameter

Description

File Path

Set the log folder and file name based on the log location on the host, such as an ECS instance:

Both folder names and file names support full paths and wildcard characters. For more information about file name rules, see Wildcard matching. The log path supports only the asterisk (*) and question mark (?) wildcard characters.

Logtail searches for log files across multiple folder levels. This means all files that match the criteria in the specified folder, including all its subdirectories, are found. For example:

  • /apsara/nuwa/**/*.log represents files with the .log suffix in the /apsara/nuwa directory and its recursive subdirectories.

  • /var/logs/app_*/**/*.log represents all files with the .log suffix in all directories that match the app_* format (including their recursive subdirectories) under the /var/logs directory.

  • /var/log/nginx/**/access* represents files that start with access in the /var/log/nginx directory and its recursive subdirectories.

Maximum Directory Monitoring Depth

Set the maximum monitoring depth for the log folder. This is the maximum folder depth that the ** wildcard character in the File Path can match. A value of 0 means only the current folder is monitored.

File Encoding

Select the encoding format of the log file.

First Collection Size

When the configuration first takes effect, this parameter specifies the starting collection position relative to the end of the file. The default value is 1024 KB.

  • During the initial collection, if a file is smaller than 1024 KB, collection starts from the beginning of the file.

  • During the initial collection, if a file is larger than 1024 KB, collection starts 1024 KB from the end of the file.

You can change the First Collection Size. The value can range from 0 KB to 10,485,760 KB.

Collection Blacklist

Enable Collection Blacklist to configure a blacklist. This lets you ignore specified folders or files during collection. The blacklist supports full paths and wildcard characters for folder and file names. Only the asterisk (*) and question mark (?) wildcard characters are supported.

Important
  • If you use a wildcard character in the File Path but need to filter out some of the matching paths, you must enter the corresponding full path in the Collection Blacklist for the blacklist to take effect.

    For example, if you set File Path to /home/admin/app*/log/*.log but want to filter out all subdirectories under /home/admin/app1*, select Folder Blacklist and set the folder to /home/admin/app1*/**. If you set it to /home/admin/app1*, the blacklist will not take effect.

  • Matching against a blacklist creates computational overhead. Keep the number of blacklist entries to 10 or fewer.

  • A folder path cannot end with a forward slash (/). For example, if you set the path to /home/admin/dir1/, the folder blacklist will not take effect.

Set a blacklist by file path, file name, or folder. The details are as follows:

File Path Blacklist

  • Select File Path Blacklist and set the path to /home/admin/private*.log. This ignores all files in the /home/admin/ folder that start with private and end with .log.

  • Select File Path Blacklist and set the path to /home/admin/private*/*_inner.log. This ignores files that end with _inner.log in folders that start with private under the /home/admin/ folder. For example, the file /home/admin/private/app_inner.log is ignored, but the file /home/admin/private/app.log is collected.

File blacklist

Select File Blacklist and set the file name to app_inner.log. This ignores all files named app_inner.log.

Folder blacklist

  • Select Folder Blacklist and set the folder to /home/admin/dir1. This ignores all files in the /home/admin/dir1 folder.

  • Select Folder Blacklist and set the folder to /home/admin/dir*. This ignores all files in subdirectories that start with dir under the /home/admin/ folder.

  • Select Folder Blacklist and set the folder to /home/admin/*/dir. This ignores all files in subdirectories named dir at the second level under the /home/admin/ folder. For example, files in the /home/admin/a/dir folder are ignored, but files in the /home/admin/a/b/dir folder are collected.

Allow File to Be Collected Multiple Times

By default, a log file can match only one LoongCollector (Logtail) configuration. If logs from a file need to be collected multiple times, enable Allow File To Be Collected For Multiple Times.

Advanced Parameters

Other optional advanced parameters related to the file input plugin. For more information, see CreateLogtailPipelineConfig.

Processor configuration parameters

Parameter

Description

Log Sample

A sample of the log to be collected. Make sure to use a log from a real-world scenario. The log sample helps you configure log processing parameters and simplifies the configuration. You can add multiple samples. The total length cannot exceed 1500 characters.

[2023-10-01T10:30:01,000] [INFO] java.lang.Exception: exception happened at TestPrintStackTrace.f(TestPrintStackTrace.java:3) at TestPrintStackTrace.g(TestPrintStackTrace.java:7) at TestPrintStackTrace.main(TestPrintStackTrace.java:16)

Multi-line Mode

  • Type: A multiline log is a single log entry that spans multiple consecutive lines. Each log entry must be distinguished from the log content.

    • Custom: Use a Regex To Match First Line to distinguish each log entry.

    • Multi-line JSON: Each JSON object is expanded into multiple lines. For example:

      { "name": "John Doe", "age": 30, "address": { "city": "New York", "country": "USA" } }
  • Processing Method If Splitting Fails:

    Exception in thread "main" java.lang.NullPointerException at com.example.MyClass.methodA(MyClass.java:12) at com.example.MyClass.methodB(MyClass.java:34) at com.example.MyClass.main(MyClass.java:½0)

    For the log content above, if Simple Log Service fails to split it:

    • Discard: Discards this log segment.

    • Retain Single Line: Retains each line of text as a separate log entry. This results in four log entries.

Processing Method

Processors, including Native Processing Plugins and Extended Processing Plugins. For more information about processing plugins, see Using native and extended processing plugins.

Important

For the limits on processing plugins, refer to the prompts on the console page.

  • Logtail 2.0:

    • Combine native processing plugins in any order.

    • Use native and extended processing plugins at the same time. However, extended processing plugins must be placed after all native processing plugins.

  • Logtail earlier than 2.0:

    • You cannot add native and extended plugins at the same time.

    • Native plugins can only be used to collect text logs. When you use native plugins, the following requirements apply:

      • The first processing plugin must be a regular expression parsing plugin, separator-based parsing plugin, JSON parsing plugin, Nginx-pattern parsing plugin, Apache-pattern parsing plugin, or IIS-pattern parsing plugin.

      • From the second to the last processing plugin, include at most one time parsing plugin, one filter plugin, and multiple data masking plugins.

    • For the Retain Original Field If Parsing Fails and Retain Original Field If Parsing Succeeds parameters, only the following combinations are valid. Other combinations are invalid.

      • Upload only logs that are parsed successfully:

        image

      • Upload parsed logs on success and raw logs on failure:

        image

      • On success, upload the parsed log and append the raw log field. On failure, upload the raw log.

        For example, if the raw log "content": "{"request_method":"GET", "request_time":"200"}" is parsed successfully, appending the raw field adds a new field to the parsed log. The field name is specified by New Name Of Original Field (if left empty, the original field name is used), and the field value is the raw log {"request_method":"GET", "request_time":"200"}.

        image