template
This component is experimental and therefore subject to change or removal outside of major version releases.
Transforms messages using Go template syntax.
# Config fields, showing default values
label: ""
template:
text: ""
from_file: false
functions: {} # No default (optional)
sub_templates:
text: "" # No default (required)
from_file: false
Transforms messages using Go template syntax.
Supports built-in Go template functions,
Sprig template functions (including string manipulation, math, date, and encoding utilities)
and a custom meta function to access message metadata (e.g., {{ meta \"key\" }}).
Additionally, users can define custom Bloblang-based functions via the functions field, which are available during template execution.
Fields
text
The Go template to apply to messages. If from_file is enabled, this is used as the file path and the template is loaded from the file.
Type: string
Default: ""
# Examples
text: '{{ .name }} - {{ meta "source" }}'
text: '{{ range .items }}{{ .name }}: {{ .value }}{{ end }}'
from_file
When enabled, the template is loaded from a file.
Type: bool
Default: false
functions
A map of Bloblang functions to make available to the template.
Type: object
sub_templates
A map of other templates which will defined into the main template.
Type: object
sub_templates.<name>.text
The Go template. If from_file is enabled, this is used as the file path and the template is loaded from the file.
Type: string
sub_templates.<name>.from_file
When enabled, the template is loaded from a file.
Type: bool
Default: false