Data parsing plugins

更新时间:
复制 MD 格式

Log Service stores raw logs in the content field by default. Use a parsing plugin to extract structured key-value pairs for field-level querying, aggregation, and visualization. Parsing plugins work on any field—specify the target field and choose a plugin that matches the content format.

Data parsing example

A common application log before and after parsing:

Without a data parsing plugin

Without parsing, all information is stored in a single content field, making the data difficult to query and analyze by field.

Content:"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""

With a regex parsing plugin

A regex parsing plugin extracts named fields that can be queried and analyzed independently.

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

Data parsing plugin selection

  • Preferred: Dedicated log format parsing.
    For Nginx, Apache, or IIS logs, use the dedicated parsing mode (Nginx mode parsing, Apache mode parsing, IIS mode parsing). No manual rules needed.















  • Alternative: Structured data parsing (JSON / delimiter)
    For JSON objects or logs with a fixed delimiter (comma, pipe, etc.), use JSON parsing or delimiter mode parsing. Easy to configure and fast to parse.















  • Fallback: Regex parsing
    Use regex parsing for irregular, unstructured logs that other modes cannot handle. Regex is versatile but harder to write and debug, and may reduce throughput.















Procedure

Add a parsing plugin when you create or modify a Logtail configuration.

Modify an existing configuration

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the one you want.

    image

  3. On the Log Storage > Logstores tab, click > next to the target Logstore, and then choose Data Collection > Logtail Configurations.

  4. From the Logtail Configurations list, click Manage Logtail Configuration in the Actions column of the target configuration.

  5. Click Edit at the top of the page. In the Processor Configurations section at the bottom of the page, add a Logtail plugin, then click Save.

Create a new configuration

  1. Log on to the Simple Log Service console.

  2. Click the Quick Data Import card on the right side of the console.

  3. In the Import Data dialog box, click a data source card and follow the wizard. In the Logtail Configurations step, add a Logtail plugin in the Logtail Configurations section.

    Note

    The plugin settings are the same as when you modify a Logtail configuration.

Use data parsing plugins

Common parameters

These parameters apply to all data parsing plugins and are not repeated in subsequent sections.

Parameter

Description

Original Field

The source field that contains the log content to be parsed. By default, this is content, which stores the entire raw log entry.

Retain Original Field if Parsing Fails

Recommended. Retains the original content in the source field when parsing fails (for example, due to a format mismatch), preserving data for debugging.

Retain Original Field if Parsing Succeeds

Retains the original log content after successful parsing. Typically used for data verification.

New Name of Original Field

Renames the retained source field to prevent naming conflicts when either Keep source field on parse failure or Keep source field on parse success is enabled.

Regular expression parsing

Extracts fields from logs using a regular expression and parses them into key-value pairs. Highly flexible and adaptable to almost any text format.

Configuration

  • Parameter details

    In addition to the common parameters, this plugin has the following core parameters:

    Parameter

    Description

    Regular Expression

    The regular expression used to match the log content.

    • If you provide a log sample, you can auto-generate or manually enter a regular expression.

      • Click Generate. In the Log Sample text box, highlight the content to extract, then click Generate Regular Expression. Simple Log Service generates a regular expression based on your selection.

      • Click Manually Enter Regular Expression and enter a regular expression. After entering the expression, click Validate to confirm it correctly parses the log content. For more information, see How do I test a regular expression.

    • If you do not provide a log sample, you must manually enter a regular expression that matches your log format.

    Extracted Field

    Specifies field names (keys) for the extracted log content (values).

  • Configuration example

    • Input log

      127.0.0.1 - - [16/Oct/2023:12:36:49 +0800] "GET /index.html HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
    • Plugin configuration

      Follow the Procedure to configure the plugin. The regular expression is (\S+)\s-\s(\S+)\s\[([^]]+)]\s"(\w+)\s(\S+)\s([^"]+)"\s(\d+)(\s\d+)[^-]+([^"]+)"\s"([^"]+).*.

      Set Source field to content and enter an Nginx access log in the Log sample text box. Parsing the log with the regular expression populates the Extracted log fields section with key-value pairs, such as remote_addr, remote_user, time_local, request_method, request_uri, request_protocol, status, body_bytes_sent, http_referer, and http_user_agent. The Keep source field on parse failure and Keep source field on parse success options are not selected.

    • Parsing result

JSON parsing

Parses JSON objects into key-value pairs.

Limitations

The JSON plugin extracts only top-level key-value pairs from a JSON object. It does not parse JSON arrays directly. To handle complex JSON, use the How to Process Complex JSON approach.

Configuration

  • Parameters

    This plugin uses only the general configuration parameters.

  • Configuration example

    • Input 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/2020:13:30:28"}
    • Plugin configuration

      Follow the Procedure. Set processor type to JSON and source field to content. Clear the keep source field on failure and keep source field on success check boxes. Keep advanced parameters disabled, and then click OK.

    • Parsing result

      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/2020:13:30:28

Delimiter mode parsing

The delimiter mode parsing plugin uses a delimiter to structure log content, parsing it into multiple key-value pairs.

Configuration

  • Parameters

    In addition to the common parameters, this plugin has the following parameters:

    Parameter

    Description

    Delimiter

    Select the delimiter that matches your log content, such as a pipe (|).

    Note

    To specify a Non-printable Character as the delimiter, find its hexadecimal value in the ASCII code table and enter it in the format 0x<hexadecimal value>. For example, the non-printable character with an ASCII code of 1 is entered as 0x01.

    Quote

    If a log field contains the delimiter, you must wrap the field with a quote character. Simple Log Service parses content wrapped by the quote character as a single field. Select the quote character that matches your log format.

    Note

    To specify a Non-printable Character as the quote character, find its hexadecimal value in the ASCII code table and enter it in the format 0x<hexadecimal value>. For example, the non-printable character with an ASCII code of 1 is entered as 0x01.

    Extracted log fields

    • If you provide a log sample, Simple Log Service extracts log content based on the sample and the specified delimiter. Log Service extracts the content into Values. You must assign a Key to each Value.

    • If you do not provide a log sample, a Value list is not generated, and you must manually enter the Keys based on your log data and delimiter.

    A Key can contain only letters, digits, and underscores (_), and it must start with a letter or an underscore (_). The maximum length is 128 bytes.

    Allow Missing Field

    This setting determines whether to upload a log to Simple Log Service when the number of extracted Values is less than the number of specified Keys. Select Allow Missing Field to upload the log.

    For example, if the log is 11|22|33|44, the delimiter is a pipe (|), and the Keys are A, B, C, D, and E.

    • If you select Allow Missing Field, the Value for the E field is empty, and Simple Log Service uploads the log.

    • If you do not select Allow Missing Field, the log is discarded.

      Note

      The Allow Missing Field parameter for delimiter mode parsing is supported in Logtail for Linux 1.0.28 and later and Logtail for Windows 1.0.28.0 and later.

    Processing Method of Field to which Excess Part is Assigned

    Defines how to handle a log when the number of extracted Values exceeds the number of specified Keys.

    • Expand: Retains the excess Values and adds them to separate fields in the format __column$i__, where $i is the index of the excess field, starting from 0. For example, __column0__ and __column1__.

    • Retain: Adds all excess Values to a single field named __column0__.

    • Discard: Discards the excess Values.

  • Configuration examples

    • Example 1: Single-character delimiter

      • Input 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
      • Plugin configuration

        Follow the Procedure. Use a comma (,) as the delimiter and a double quotation mark (") as the quote character.

        Note

        Delimiter: You can use a single character to split logs, such as a tab (\t), pipe (|), space, comma (,), semicolon (;), or a non-printable character. The delimiter cannot be a double quotation mark (").

        If a double quotation mark (") appears in a field, you must escape it as "" in the log. Simple Log Service automatically restores "" to " when it parses the field. For example, if the delimiter is a comma (,) and the quote character is a double quotation mark ("), and a field contains both a comma and a double quotation mark, you must wrap the field with the quote character and escape the double quotation mark as "". The resulting log entry, Chevy,"Venture ""Extended Edition, Very Large""","", is parsed into three fields: Chevy, Venture "Extended Edition, Very Large", and an empty field.

        Quote character: If a log field contains the delimiter, you must wrap the field with a quote character. Log Service parses the wrapped content as a single field. The quote character can be a single character, such as a tab (\t), pipe (|), space, comma (,), semicolon (;), or a non-printable character.

        For example, if the delimiter is a comma (,) and the quote character is a double quotation mark ("), Log Service parses the log 1997,"ac,moon",3000.00 into three fields: 1997, ac,moon, and 3000.00.

      • Parsing result

        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
    • Example 2: Multi-character delimiter

      • Input log

        05/May/2022:13:30:28&&10.200.**.**&&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
      • Plugin configuration

        Follow the Procedure. Use && as the delimiter and keep the default quote character, which is a double quotation mark (").

        Important

        In multi-character mode, the delimiter can contain two or three characters, such as ||, &&&, or ^_^. Logtail parses logs based on delimiter matching, so you do not need to wrap fields with a quote character. Make sure that no field content contains a full match of the delimiter. Otherwise, Logtail may split the field incorrectly.

      • Parsing result

        ip:10.200.**.**
        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/2022:13:30:28
        user_agent:aliyun-sdk-java

Nginx mode parsing

The Nginx mode plugin parses log content into key-value pairs based on the log_format definition.

Nginx logs

Nginx servers generate access logs based on the log_format and access_log directives. The directives default to the following:

log_format main  '$remote_addr - $remote_user [$time_local] "$request" '
                 '$request_time $request_length '
                 '$status $body_bytes_sent "$http_referer" '
                 '"$http_user_agent"';
access_log /var/logs/nginx/access.log main

The log contains the following fields:

Field name

Description

remote_addr

The client IP address.

remote_user

The client username.

time_local

The server time. It must be enclosed in square brackets ([]).

request

The request URI and HTTP protocol.

request_time

The total time to process the request, in seconds.

request_length

The length of the request, including the request line, request header, and request body.

status

The request status code.

body_bytes_sent

The number of bytes sent to the client, excluding the size of the response header.

http_referer

The referrer.

http_user_agent

Information about the client, such as the browser type and version.

Configuration

  • Parameters

    In addition to the common parameters, this plugin has the following parameters:

    Parameter

    Description

    NGINX Log Configuration

    The log_format definition from your Nginx configuration file.

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

    Extracted Field

    The plugin automatically extracts the log fields (keys) based on the NGINX Log Configuration.

  • Configuration example

    • Input 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"
    • Plugin configuration

      Follow the Procedure. In production, the log_format must match the definition in your Nginx configuration file (typically /etc/nginx/nginx.conf).

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

      body_bytes_sent: 368
      http_referer: -
      http_user_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.*.* 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

Apache pattern parsing

The Apache pattern parsing plugin structures log content into key-value pairs based on the definitions in your Apache log configuration file.

Apache logs

An Apache server generates logs based on the log format, path, and name specified in its log configuration file. For example, the directive CustomLog "/var/log/apache2/access_log" combined writes logs in the combined format to /var/log/apache2/access_log.

  • Apache log formats

    • combined format

      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    • common format

      LogFormat "%h %l %u %t \"%r\" %>s %b" 
    • custom format

      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D %f %k %p %q %R %T %I %O" customized

    The following table describes the fields. Refer to mod_log_config for the full reference.

    Format

    Parameter

    Description

    %a

    client_addr

    The client IP address.

    %A

    local_addr

    The local IP address.

    %b

    response_size_bytes

    The response size in bytes. A hyphen (-) is logged for null values.

    %B

    response_bytes

    The response size in bytes. A 0 is logged for null values.

    %D

    request_time_msec

    The time taken to serve the request, in microseconds.

    %f

    filename

    The filename.

    %h

    remote_addr

    The remote hostname.

    %H

    request_protocol_supple

    The request protocol.

    %I

    bytes_received

    The bytes received by the server. Requires the mod_logio module.

    %k

    keep_alive

    The number of requests handled on this connection.

    %l

    remote_ident

    The remote logname from identd, if supplied.

    %m

    request_method_supple

    The request method.

    %O

    bytes_sent

    The bytes sent by the server. Requires the mod_logio module.

    %p

    remote_port

    The server port number.

    %P

    child_process

    The child process ID.

    %q

    request_query

    The query string. An empty string is logged if one does not exist.

    %r

    request

    The request line, which includes the method, URI, and HTTP protocol.

    %R

    response_handler

    The type of handler on the server.

    %s

    status

    The initial HTTP status of the response.

    %>s

    status

    The final HTTP status of the response.

    %t

    time_local

    The server time.

    %T

    request_time_sec

    The time taken to serve the request, in seconds.

    %u

    remote_user

    The remote user, if the request is authenticated.

    %U

    request_uri_supple

    The requested URI path, without the query string.

    %v

    server_name

    The server name.

    %V

    server_name_canonical

    The server name as determined by the UseCanonicalName directive.

    %{User-Agent}i

    http_user_agent

    The User-Agent HTTP request header.

    %{Referer}i

    http_referer

    The URL of the page from which the request originated.

Configuration

  • Parameters

    In addition to the common parameters, this plugin has the following parameters:

    Parameter

    Description

    Log Format

    Select the log format defined in your Apache log configuration file. Options include common, combined, and custom.

    APACHE LogFormat Configuration

    The LogFormat directive from your Apache configuration file.

    • When you set the Log Format to common or combined, the corresponding configuration fields are automatically populated. Confirm that the format is consistent with the one defined in the Apache configuration file.

    • When you set the Log Format to Custom, enter the actual format string. For example, LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D %f %k %p %q %R %T %I %O" customized.

    Extracted Field

    Log fields (keys) automatically extracted based on the content of the APACHE LogFormat Configuration.

  • Configuration example

    • Input log

      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"
    • Plugin configuration

      Follow the Procedure. Set Log format to combined.

    • Parsing result

      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 mode parsing

The IIS mode plugin parses log content into multiple key-value pairs based on the IIS log format definition.

IIS logs

A Windows server generates IIS logs based on the log format that you select (IIS, NCSA, or W3C).

  • Log format

    #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
    • Field prefix descriptions

      Prefix

      Description

      s-

      Server action.

      c-

      Client action.

      cs-

      Client-to-server action.

      sc-

      Server-to-client action.

    • Field descriptions

      Field

      Description

      date

      The date of the request.

      time

      The time of the request.

      s-sitename

      The Internet service name and instance number of the site that the client accessed.

      s-computername

      The name of the server that generated the log entry.

      s-ip

      The IP address of the server that generated the log entry.

      cs-method

      The request method, such as GET or POST.

      cs-uri-stem

      The URI resource that the client requested.

      cs-uri-query

      The URI query: the information that follows the question mark (?) in the request.

      s-port

      The server port.

      cs-username

      The authenticated domain or username.

      • For an authenticated user, the format is Domain\Username.

      • For an anonymous user, a hyphen (-) is displayed.

      c-ip

      The IP address of the client that accessed the server.

      cs-version

      The protocol version, such as HTTP/1.0 or HTTP/1.1.

      cs(User-Agent)

      The browser used by the client.

      Cookie

      The content of the cookie that was sent or received. If no cookie is present, a hyphen (-) is displayed.

      referer

      The site from which the user was referred.

      cs-host

      The host header information.

      sc-status

      The HTTP status code.

      sc-substatus

      The HTTP substatus code.

      sc-win32-status

      The Windows-specific operational status code.

      sc-bytes

      The number of bytes sent by the server.

      cs-bytes

      The number of bytes received by the server.

      time-taken

      The time taken to process the request, in milliseconds.

Configuration

  • Parameter descriptions

    In addition to the common parameters, this plugin has the following parameters:

    Parameter

    Description

    Log Format

    The log format used by the IIS server. Supported formats include IIS, NCSA, and W3C.

    IIS Configuration Fields

    • If the log format is IIS or NCSA, Log Service sets the IIS configuration fields by default.

    • If the log format is W3C, set this parameter 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"
      • Default IIS 5 configuration file path: C:\WINNT\system32\inetsrv\MetaBase.bin.

      • Default IIS 6 configuration file path: C:\WINDOWS\system32\inetsrv\MetaBase.xml.

      • Default IIS 7 configuration file path: C:\Windows\System32\inetsrv\config\applicationHost.config.

    Extracted Field

    Log Service automatically generates the extracted log fields (keys) based on the content of the IIS Configuration Fields parameter.

  • Configuration example

    • Input 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
      2023-10-27 08:00:00 W3SVC1 192.168.1.1 GET /index.html - 80 - 10.0.0.5 Mozilla/5.0 200 0 0 500 100 150
    • Plugin configuration

      Follow the Procedure. Set Log format to IIS.

    • Parsed result

      date: 2023-10-27
      time: 08:00:00
      s-sitename: W3SVC1
      s-ip: 192.168.1.1
      cs-method: GET
      cs-uri-stem: /index.html
      cs-uri-query: -
      s-port: 80
      cs-username: -
      c-ip: 10.0.0.5
      cs(User-Agent): Mozilla/5.0
      sc-status: 200
      sc-substatus: 0
      sc-win32-status: 0
      sc-bytes: 500
      cs-bytes: 100
      time-taken: 150

FAQ

Regex failure in Log Service

Check for these common issues:

  1. Mismatched log sample: Ensure that the log sample used in the Logtail configuration exactly matches the format of the collected logs, including spaces and special characters.

  2. Mixed log formats: If your log source contains multiple formats, a single regex may not match all of them. Enable keep unmatched content to preserve raw logs when parsing fails. You can also use multiple Logtail configurations to handle formats separately.

  3. Escaping differences between code and the console: A regular expression copied from code may contain extra escape characters, such as \\S+. In the Log Service console, use a single backslash, such as \S+.

Querying logs from a specific file

Log Service automatically adds the __tag__:__path__ metadata field to each log entry, containing the full path of the source file. Use this field to filter logs from a specific file such as /var/log/app/error.log: * AND __tag__:__path__: /var/log/app/error.log.

Cannot query historical data after index modification

Index changes apply only to newly ingested data. To query existing historical data with the new index configuration, run a reindex task.

Handling JSON logs with arrays

The JSON parsing plugin cannot directly split a JSON array into separate log entries.

Solution:

Log Service provides the JSON field unwrapping plugin to unwrap or split a JSON array field.

How it works: By specifying an unwrapping depth, the plugin iterates through the array field and generates a new log entry for each element in the array. The plugin copies other fields (non-array members) from the original log to each new log entry.

Comparison example:

Note
  • This operation increases the number of log entries. A single log that contains an array of N elements becomes N log entries. Consider this when planning your log storage and indexing costs.

  • Unwrapping depth: The level to which the JSON object is unwrapped. A value of 0 (default) fully unwraps the object, 1 unwraps only the current level, and so on.

Raw log

Unwrapping depth: 0 (prefix added)

Unwrapping depth: 1 (prefix added)

{"s_key":{"k1":{"k2":{"k3":{"k4":{"k51":"51","k52":"52"},"k41":"41"}}}}}
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
1_s_key:{"k1":{"k2":{"k3":{"k4":{"k51":"51","k52":"52"},"k41":"41"}}}}

Parsing logs with text and embedded JSON

Chain multiple processing plugins, where the output of one becomes the input for the next.

Use case:

Assume that your application log has the following format, which includes a timestamp, log level, and an embedded JSON message.

2025-11-12 10:30:15 INFO Request details: {"trace_id": "xyz-123", "user_id": 500, "action": "login"}

Parsing strategy: Add the following two plugins in order. Specify the correct source field for the second plugin. This chaining approach works for any mixed-format log.

  1. Use a regular expression parsing plugin to extract the leading text fields and capture the embedded JSON string in a separate field. The result is as follows:

    {
         "log_time": "2025-11-12 10:30:15",
         "log_level": "INFO",
         "json_message": "{\"trace_id\": \"xyz-123\", \"user_id\": 500, \"action\": \"login\"}"
    }
  2. Add a JSON parsing plugin, and set json_message as its source field to parse the JSON content into key-value pairs. The result is as follows:

    {
         "log_time": "2025-11-12 10:30:15",
         "log_level": "INFO",
         "trace_id": "xyz-123",
         "user_id": 500,
         "action": "login"
    }

Related documents