rename

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Rename plugin

It renames the fields of the event. You can provide an unlimited number of config parameters. Each parameter handled as cfg.FieldSelector:string. When override is set to false, the field won't be renamed in the case of field name collision. Sequence of rename operations isn't guaranteed. Use different actions for prioritization.

Note: if the renamed field name starts with underscore "_", it should be escaped with preceding underscore. E.g. if the renamed field is "_HOSTNAME", in config it should be "___HOSTNAME". Only one preceding underscore is needed. Renamed field names with only one underscore in config are considered as without preceding underscore: if there is "_HOSTNAME" in config the plugin searches for "HOSTNAME" field.

Example common:

pipelines:
  example_pipeline:
    ...
    actions:
    - type: rename
      override: false
      my_object.field.subfield: new_sub_field
    ...

Input event:

{
  "my_object": {
    "field": {
      "subfield":"value"
    }
  }
}

Output event:

{
  "my_object": {
    "field": {
      "new_sub_field":"value"  # renamed
    }
  }
}

Example journalctl:

pipelines:
  example_pipeline:
    ...
    actions:
    - type: rename
      override: false
      __HOSTNAME: host
      ___REALTIME_TIMESTAMP: ts
    ...

Input event:

{
  "_HOSTNAME": "example-host",
  "__REALTIME_TIMESTAMP": "1739797379239590"
}

Output event:

{
  "host": "example-host",   # renamed
  "ts": "1739797379239590"  # renamed
}


Generated using insane-doc

Documentation

Index

Constants

View Source
const (
	NotFoundIdx = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config []string

func (*Config) Append added in v0.10.0

func (c *Config) Append(key, value string)

func (*Config) Clone added in v0.10.0

func (c *Config) Clone() Config

func (*Config) Find added in v0.10.0

func (c *Config) Find(key string) (string, int)

func (*Config) ForEach added in v0.10.0

func (c *Config) ForEach(cb func(key, value string))

func (*Config) Remove added in v0.10.0

func (c *Config) Remove(key string)

func (*Config) UnmarshalJSON added in v0.10.0

func (c *Config) UnmarshalJSON(bytes []byte) error

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func (*Plugin) Do

func (p *Plugin) Do(event *pipeline.Event) pipeline.ActionResult

func (*Plugin) Start

func (p *Plugin) Start(config pipeline.AnyConfig, _ *pipeline.ActionPluginParams)

func (*Plugin) Stop

func (p *Plugin) Stop()

Jump to

Keyboard shortcuts

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