convert_log_level

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Convert log level plugin

It converts the log level field according RFC-5424.

Config params

field cfg.FieldSelector default=level

The name of the event field to convert. The value of the field will be converted to lower case and trimmed for parsing.

Warn: it overrides fields if it contains non-object type on the path. For example: if field is info.level and input { "info": [{"userId":"12345"}] }, output will be: { "info": {"level": <level>} }


style string default=number options=number|string

Style format to convert. Must be one of number or string. Available RFC-5424 levels:

  • 0: emergency
  • 1: alert
  • 2: critical
  • 3: error
  • 4: warning
  • 5: notice
  • 6: informational
  • 7: debug

default_level string

The default log level if the field cannot be parsed. If empty, no default level will be set.

Also it uses if field contains non-object type. For example: if default_level is informational and input: {"level":[5]} the output will be: {"level":"informational"}


remove_on_fail bool default=false

Remove field if conversion fails. This can happen when the level is unknown. For example: { "level": "my_error_level" }



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 name of the event field to convert.
	// > The value of the field will be converted to lower case and trimmed for parsing.
	// >
	// > Warn: it overrides fields if it contains non-object type on the path. For example:
	// > if `field` is `info.level` and input
	// > `{ "info": [{"userId":"12345"}] }`,
	// > output will be: `{ "info": {"level": <level>} }`
	Field  cfg.FieldSelector `json:"field" parse:"selector" required:"false" default:"level"` // *
	Field_ []string

	// > @3@4@5@6
	// >
	// > Style format to convert. Must be one of number or string.
	// > Available RFC-5424 levels:
	// > <ul>
	// > <li>0: emergency</li>
	// > <li>1: alert </li>
	// > <li>2: critical </li>
	// > <li>3: error </li>
	// > <li>4: warning </li>
	// > <li>5: notice </li>
	// > <li>6: informational </li>
	// > <li>7: debug </li>
	// > </ul>
	Style string `json:"style" default:"number" options:"number|string"` // *

	// > @3@4@5@6
	// >
	// > The default log level if the field cannot be parsed. If empty, no default level will be set.
	// >
	// > Also it uses if field contains non-object type. For example:
	// > if `default_level` is `informational` and input:
	// > `{"level":[5]}`
	// > the output will be: `{"level":"informational"}`
	DefaultLevel string `json:"default_level" default:""` // *

	// > @3@4@5@6
	// >
	// > Remove field if conversion fails.
	// > This can happen when the level is unknown. For example:
	// > `{ "level": "my_error_level" }`
	RemoveOnFail bool `json:"remove_on_fail" default:"false"` // *
}

! 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