Bag Pack
Creates a map (bag) from a list of key-value pairs, supporting template resolution for dynamic values.
Schema
- bag_pack:
field: <ident>
items:
- key: <string>
value: <string>
skip_empty: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Target field to store the created map |
items | Y | - | Array of key-value pairs to include in the map |
items.key | Y | - | Key name for the map entry |
items.value | Y | - | Value for the map entry (supports templates) |
skip_empty | N | false | Skip items with empty values |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue if processor fails |
ignore_missing | N | false | Continue if source field doesn't exist |
on_failure | N | - | Processors to run on failure |
on_success | N | - | Processors to run on success |
tag | N | - | Processor identifier |
Item Configuration
Each item in the items
array supports:
- key: The key name in the resulting map
- value: The value to assign (supports template expressions like
{{field_name}}
)
Details
Values support template expressions using {{field_name}}
syntax, allowing for dynamic content insertion from other fields in the log entry. The skip_empty
option can be used to exclude items with null, empty string, or empty array/object values from the resulting map.
Template-resolved values maintain their original data types, ensuring proper type handling throughout the processing pipeline. When ignore_missing
is enabled, missing template fields are skipped rather than causing errors, providing robust handling of variable log structures.
This processor excels at data restructuring by converting separate fields into organized maps and building metadata objects from various log fields. It's particularly effective for API response formatting where structured data needs to be prepared for external consumption.
The processor also supports conditional field mapping, creating dynamic field mappings based on log content, and enables configuration object creation by building structured configuration objects from template values across different parts of the log entry.
Examples
Basic Map Creation
Creating a map from user fields with both dynamic and static values... |
|
produces a structured map object: |
|
Skip Empty Values
Using |
|
only includes non-empty values: |
|
Static and Dynamic Values
Combining template expressions with static values for metadata... |
|