When you use Logtail to collect logs, you can use the processor_packjson plug-in to pack one or more fields into a field in JSON object format. This topic describes the parameters of the processor_packjson plug-in and provides configuration examples.
Limits
Text logs and container standard output support only form-based configuration. Other input plugins support only JSON configuration.
Entry point
To use a Logtail plugin to process logs, you can add a plugin configuration when you create or modify a Logtail collection configuration. For more information, see Overview of Logtail plugins for data processing.
Configuration description
Logtail 0.16.28 and later supports the processor_packjson plug-in.
Configure the plug-in using the form
Parameters
Set Processor Type to Pack Fields. The following table describes the parameters.
Parameter
Description
Source Fields
The source fields to pack.
Destination Field
The destination field after packing.
Keep Source Fields
Select this option to keep the source fields in the parsed log.
Alarm On Missing Source Fields
Select this option to report an error if the specified source fields do not exist in the raw log.
Example
The following example shows how to pack the a and b fields into the d_key JSON field:
Raw log
"a":"1" "b":"2"Logtail plug-in configuration

Processing result
"a":"1" "b":"2" "d_key":"{\"a\":\"1\",\"b\":\"2\"}"
Configure the plug-in using JSON
Parameters
Set type to processor_packjson. The following table describes the parameters in the detail object.
Parameter
Type
Required
Description
SourceKeys
Array of strings
Yes
The source fields to pack.
DestKey
String
No
The destination field after packing.
KeepSource
Boolean
No
Specifies whether to keep the source fields in the parsed log. Valid values:
true (default)
false
AlarmIfIncomplete
Boolean
No
Specifies whether to report an error if the specified source fields do not exist in the raw log. Valid values:
true (default value): Reports an error.
false
Example
The following example shows how to pack the a and b fields into the d_key JSON field:
Raw log
"a":"1" "b":"2"Logtail plug-in configuration
{ "processors":[ { "type":"processor_packjson", "detail": { "SourceKeys": ["a","b"], "DestKey":"d_key", "KeepSource":true, "AlarmIfEmpty":true } } ] }Processing result
"a":"1" "b":"2" "d_key":"{\"a\":\"1\",\"b\":\"2\"}"
References
Configure a Logtail pipeline using API operations:
GetLogtailPipelineConfig - Get a Logtail pipeline configuration
ListLogtailPipelineConfig - List Logtail pipeline configurations
CreateLogtailPipelineConfig - Create a Logtail pipeline configuration
DeleteLogtailPipelineConfig - Delete a Logtail pipeline configuration
UpdateLogtailPipelineConfig - Update a Logtail pipeline configuration
Configure a processor plugin in the console:
Collect container logs from a Kubernetes cluster using a CRD (stdout/file)