All Products
Search
Document Center

Simple Log Service:Rename fields

Last Updated:Jul 15, 2024

If you use Logtail to collect logs, you can use the processor_rename plug-in to rename fields. This topic describes the parameters of the processor_rename plug-in. This topic also provides examples on how to configure the plug-in.

Limits

The input plug-ins for text logs and container stdout and stderr support only form configuration. Other input plug-ins support only editor configuration in JSON.

Entry point

If you want to use a Logtail plug-in to process logs, you can add a Logtail plug-in configuration when you create or modify a Logtail configuration. For more information, see Overview of Logtail plug-ins for data processing.

Usage notes

Important

Logtail V0.16.28 and later support the processor_rename plug-in.

Form configuration

  • Parameters

    Set Processor Type to Rename Fields. Then, configure other parameters based on the following table.

    Parameter

    Description

    Original Field

    The original fields to rename.

    New Field

    The new names of the original fields.

    Report Original Field Missing Error

    Specifies whether to report an error if the raw log does not contain the original fields.

  • Configuration example

    The following example shows how to rename the aaa1 field to bbb1 and rename the aaa2 field to bbb2.

    • Raw log

      "aaa1":"value1"
      "aaa2":"value2"
      "aaa3":"value3"
    • Logtail plug-in configuration for data processing Rename fields

    • Results

      "bbb1":"value1"
      "bbb2":"value2"
      "aaa3":"value3"

Editor configuration in JSON

  • Parameters

    Set type to processor_rename. Then, configure other parameters in detail based on the following table.

    Parameter

    Type

    Required

    Description

    NoKeyError

    Boolean

    No

    Specifies whether to report an error if the raw log does not contain the original fields. Valid values:

    • true: reports an error.

    • false: does not report an error. This is the default value.

    SourceKeys

    String array

    Yes

    The original fields to rename.

    DestKeys

    String array

    Yes

    The new names of the original fields.

  • Configuration example

    The following example shows how to rename the aaa1 field to bbb1 and rename the aaa2 field to bbb2.

    • Raw log

      "aaa1":"value1"
      "aaa2":"value2"
      "aaa3":"value3"
    • Logtail plug-in configuration for data processing

      {
        "processors":[
          {
            "type":"processor_rename",
            "detail": {
              "SourceKeys": ["aaa1","aaa2"],
              "DestKeys": ["bbb1","bbb2"],
              "NoKeyError": true
            }
          }
        ]
      }
    • Results

      "bbb1":"value1"
      "bbb2":"value2"
      "aaa3":"value3"