Template Processor Plugin
The template
processor uses Golang templates to modify/create event Id, routing key, labels and fields.
Processor passes read-only event to template with methods:
RoutingKey() string
Id() string
Timestamp() time.Time
GetLabel(key string) string
- returns empty string if an event has no label associated with key
GetField(path string) any
- returns nil
if an event has ho field on passed path
If template execution or field setting fails, event is marked as failed, but other templates execution continues.
Configuration
[[processors]]
[processors.template]
# routing key template
routing_key = '{{ .RoutingKey }}-{{ .Timestamp.Format "2006-01-02" }}'
# id template
id = '{{ .GetLabel "message_id" }}'
# "label name -> template" map
[processors.template.labels]
host = '{{ .GetField "client.host" }}:{{ .GetField "client.port" }}'
# "field path -> template" map
[processors.template.fields]
"metadata.full_address" = '{{ .GetField "address.street" }}, {{ .GetField "address.building" }}'