Synopsis
Creates formatted strings using template values and field references.
Schema
- print:
format: <string>
values: <array>
field: <ident>
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 |
---|---|---|---|
format | Y | - | Printf-style format string with %s placeholders |
values | Y | - | Array of values or field references to substitute |
field | Y | - | Target field to store formatted result |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if formatting fails |
ignore_missing | N | false | Skip processing if referenced fields don't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
Creates formatted strings by substituting values into printf-style format strings. The processor supports both literal values and dynamic field references using template syntax.
Values in the values
array can be literal strings or field references using triple-brace template syntax ({{{field_name}}}
). The processor resolves field references before substituting into the format string.
The processor uses Go's fmt.Sprintf formatting with %s placeholders. The number of %s placeholders in the format string should match the number of values provided. Extra values are truncated, missing values are padded with empty strings.
When ignore_missing
is enabled, missing field references resolve to empty strings rather than causing processor failure. This allows graceful handling of optional fields in templates.
Template resolution occurs before format substitution. Ensure field references use correct triple-brace syntax ({{{field}}}
) to avoid literal text substitution instead of field value resolution.
Examples
Basic String Formatting
Creating formatted message with literal values... |
|
generates formatted string: |
|
Dynamic Field References
Using field references in format values... |
|
resolves field values into format: |
|
Alert Message Generation
Creating alert messages from event data... |
|
formats comprehensive alert: |
|
Report Summary Creation
Generating summary reports from metrics... |
|
creates processing summary: |
|
Mixed Literal and Dynamic Values
Combining literal text with field values... |
|
formats service status: |
|
Error Handling with Missing Fields
Handling missing fields gracefully... |
|
uses empty string for missing field: |
|
URL Construction
Building URLs from component parts... |
|
constructs complete URL: |
|