All Products
Search
Document Center

Simple Log Service:Add fields

Last Updated:Apr 26, 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.

Important
  • Form configuration: You can use form configuration to collect text logs and container stdout and stderr.

  • Editor configuration in JSON: You cannot use editor configuration in JSON to collect text logs.

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.

Important Only Logtail V0.16.28 or later supports the processor_add_fields plug-in.

Usage notes

Form configuration

  • Parameters
    Set the Processor Type parameter to Add Field. The following table describes the parameters.
    ParameterDescription
    Add FieldThe name and value of the field that you want to add. You can add multiple fields.
    Ignore New Fields with Same NameSpecifies whether to ignore duplicate fields if the fields have the same name.
  • Sample configuration
    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 Add fields
    • Result
      "aaa1":"value1"
      "aaa2":"value2"
      "aaa3":"value3"

Editor configuration in JSON

  • Parameters
    The following table describes the parameters that you can configure in the detail parameter if you set the type parameter to processor_add_fields.
    ParameterTypeRequiredDescription
    FieldsMapYesThe name and value of the field that you want to add. You can specify multiple key-value pairs in the parameter.
    IgnoreIfExistBooleanNoSpecifies whether to ignore duplicate fields if the fields have the same name. Valid values:
    • true: ignores duplicate fields.
    • false: does not ignore duplicate fields. This is the default value.
  • Sample configuration
    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"