template

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

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" }}'

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Template

type Template struct {
	*core.BaseProcessor `mapstructure:"-"`
	Id                  string            `mapstructure:"id"`
	RoutingKey          string            `mapstructure:"routing_key"`
	Labels              map[string]string `mapstructure:"labels"`
	Fields              map[string]string `mapstructure:"fields"`
	// contains filtered or unexported fields
}

func (*Template) Close

func (p *Template) Close() error

func (*Template) Init

func (p *Template) Init() error

func (*Template) Run

func (p *Template) Run()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL