Concat
Synopsis
Concatenates values from multiple source fields into a single target field using a specified separator.
Schema
- concat:
sources: <string[]>
target: <ident>
separator: <string>
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 |
---|---|---|---|
sources | Y | Array of field names to concatenate | |
target | Y | Field to store the concatenated result | |
separator | N | " " (space) | String used to join the source values |
description | N | - | Explanatory notes |
if | N | - | Condition to run |
ignore_failure | N | false | See Handling Failures |
ignore_missing | N | false | Skip missing fields instead of failing |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The processor reads values from the specified source fields, converts them to strings, and joins them using the separator. Empty values are excluded from the concatenation. If ignore_missing
is true, missing fields are skipped; otherwise, the processor fails if any source field is missing.
All source values are converted to strings using Go's standard string conversion, making the processor compatible with various data types including numbers, booleans, and complex objects.
The order of values in the concatenated result follows the order specified in the sources
array. Rearranging the source fields will change the output order.
When concatenating sensitive data or creating identifiers, consider the implications of the separator choice. Some separators may cause issues in downstream systems or create ambiguous results if the source data contains the separator character.
Complex objects (maps, arrays) are converted to their string representation, which may not be human-readable. Consider using specific field paths or preprocessing the data before concatenation.
For more complex string manipulation, consider using the set
processor and the so-called mustache syntax.
Examples
Basic Usage
Concatenate first and last name... |
|
into a single field: |
|
Custom Separator
Use a custom separator... |
|
to format the output: |
|
Multiple Field Types
Concatenate different data types... |
|
which are automatically converted to strings: |
|
Handling Missing Fields
With |
|
missing fields are skipped: |
|
Creating URLs
Build URLs from components... |
|
Note: This creates an invalid URL format |
|
Better URL Building
For proper URL building, concatenate in parts... |
|
to create well-formed URLs: |
|
Log Message Formatting
Create structured log messages... |
|
with consistent formatting: |
|
Empty Separator
Use an empty separator... |
|
to join values without any delimiter: |
|