move

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Move plugin

It moves fields to the target field in a certain mode.

  • In allow mode, the specified fields will be moved
  • In block mode, the unspecified fields will be moved

Examples

pipelines:
  example_pipeline:
    ...
    actions:
    - type: move
      mode: allow
      target: other
      fields:
        - log.stream
        - zone
    ...

The original event:

{
  "service": "test",
  "log": {
    "level": "error",
    "message": "error occurred",
    "ts": "2023-10-30T13:35:33.638720813Z",
    "stream": "stderr"
  },
  "zone": "z501"
}

The resulting event:

{
  "service": "test",
  "log": {
    "level": "error",
    "message": "error occurred",
    "ts": "2023-10-30T13:35:33.638720813Z"
  },
  "other": {
    "stream": "stderr",
    "zone": "z501"
  }
}

pipelines:
  example_pipeline:
    ...
    actions:
    - type: move
      mode: block
      target: other
      fields:
        - log
    ...

The original event:

{
  "service": "test",
  "log": {
    "level": "error",
    "message": "error occurred",
    "ts": "2023-10-30T13:35:33.638720813Z",
    "stream": "stderr"
  },
  "zone": "z501",
  "other": {
    "user": "ivanivanov"
  }
}

The resulting event:

{
  "log": {
    "level": "error",
    "message": "error occurred",
    "ts": "2023-10-30T13:35:33.638720813Z"
  },
  "other": {
    "user": "ivanivanov",
    "service": "test",
    "zone": "z501"
  }
}

pipelines:
  example_pipeline:
    ...
    actions:
    - type: move
      mode: allow
      target: other
      fields:
        - log.message
        - error.message
        - zone
    ...

The original event:

{
  "service": "test",
  "log": {
    "message": "some log",
    "ts": "2023-10-30T13:35:33.638720813Z"
  },
  "error": {
    "code": 1,
    "message": "error occurred"
  },
  "zone": "z501"
}

The resulting event:

{
  "service": "test",
  "log": {
    "ts": "2023-10-30T13:35:33.638720813Z"
  },
  "error": {
    "code": 1,
  },
  "other": {
    "message": "error occurred",
    "zone": "z501"
  }
}

Config params

fields []cfg.FieldSelector required

The list of the fields to move.

  1. In block mode, the maximum fields depth is 1.
  2. If several fields have the same end of the path, the last specified field will overwrite the previous ones.

mode string required

The mode of the moving. Available modes are one of: allow|block.


target cfg.FieldSelector required

The target field of the moving.

  1. In block mode, the maximum target depth is 1.
  2. If the target field is existing non-object field, it will be overwritten as object field.


Generated using insane-doc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// > @3@4@5@6
	// >
	// > The list of the fields to move.
	// >> 1. In `block` mode, the maximum `fields` depth is 1.
	// >> 2. If several fields have the same end of the path,
	// >> the last specified field will overwrite the previous ones.
	Fields []cfg.FieldSelector `json:"fields" slice:"true" required:"true"` // *

	// > @3@4@5@6
	// >
	// > The mode of the moving. Available modes are one of: `allow|block`.
	Mode string `json:"mode" required:"true"` // *

	// > @3@4@5@6
	// >
	// > The target field of the moving.
	// >> 1. In `block` mode, the maximum `target` depth is 1.
	// >> 2. If the `target` field is existing non-object field,
	// >> it will be overwritten as object field.
	Target  cfg.FieldSelector `json:"target" parse:"selector" required:"true"` // *
	Target_ []string
}

! config-params ^ config-params

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, params *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