All Products
Search
Document Center

Simple Log Service:Add fields

最終更新日:May 06, 2024

If you use Logtail to collect logs, you can use the processor_add_fields plug-in to add log fields. This topic describes the parameters of the processor_add_fields plug-in and provides examples on how to configure the plug-in.

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.

Usage notes

Important

Only Logtail V0.16.28 and later support the processor_add_fields plug-in.

Form configuration

  • Parameters

    Set the Processor Type parameter to Add Field. Then, configure other parameters based on the following table.

    Parameter

    Description

    Add Field

    The name and value of the field that you want to add. You can add multiple fields.

    Ignore New Fields with Same Name

    Specifies whether to ignore duplicate fields if the fields have the same name.

  • Examples

    The following example shows how to add the aaa2 and aaa3 fields to a log:

    • Raw log

      "aaa1":"value1"
    • Logtail plug-in configuration for data processing添加字段

    • Result

      "aaa1":"value1"
      "aaa2":"value2"
      "aaa3":"value3"

Editor configuration in JSON

  • Parameters

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

    Parameter

    Type

    Required

    Description

    Fields

    Map

    Yes

    The name and value of the field that you want to add. You can specify multiple key-value pairs to add multiple fields.

    IgnoreIfExist

    Boolean

    No

    Specifies whether to ignore duplicate fields if the fields have the same name. Valid values:

    • true

    • false (default)

  • Examples

    The following example shows how to add the aaa2 and aaa3 fields to a log:

    • Raw log

      "aaa1":"value1"
    • Logtail plug-in configuration for data processing

      {
        "processors":[
          {
            "type":"processor_add_fields",
            "detail": {
              "Fields": {
                "aaa2": "value2",
                "aaa3": "value3"
              }
            }
          }
        ]
      }
    • Result

      "aaa1":"value1"
      "aaa2":"value2"
      "aaa3":"value3"