action

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddName     = "add"
	AddUsageMsg = "usage: add(key, value)"
)
View Source
const (
	CopyName     = "copy"
	CopyUsageMsg = "usage: copy(from, to)"
)
View Source
const (
	DelName     = "del"
	DelUsageMsg = "usage: del(key1, key2...)"
)
View Source
const (
	DropEventName     = "dropEvent"
	DropEventUsageMsg = "usage: dropEvent()"
)
View Source
const (
	FmtName     = "fmt"
	FmtUsageMsg = "usage: fmt(key)"
)
View Source
const (
	FmtKeyName     = "fmtKey"
	FmtKeyUsageMsg = "usage: fmtKey()"
)
View Source
const (
	JsonDecodeName     = "jsonDecode"
	JsonDecodeUsageMsg = "usage: jsonDecode(key) or jsonDecode(key, to)"
)
View Source
const (
	JsonEncodeName     = "jsonEncode"
	JsonEncodeUsageMsg = "usage: jsonEncode(key) or jsonEncode(key, to)"
)
View Source
const (
	MoveName     = "move"
	MoveUsageMsg = "usage: move(from, to)"
)
View Source
const (
	PrintName     = "print"
	PrintUsageMsg = "usage: print()"
)
View Source
const (
	RegexName     = "regex"
	RegexUsageMsg = "usage: regex(key) or regex(key, to)"
)
View Source
const (
	ReturnName     = "return"
	ReturnUsageMsg = "usage: return()"
)
View Source
const (
	SetName     = "set"
	SetUsageMsg = "usage: set(key, value)"
)
View Source
const (
	SplitName     = "split"
	SplitUsageMsg = "usage: split(key) or split(key, to)"
)
View Source
const (
	StrConvertName     = "strconv"
	StrConvertUsageMsg = "usage: strconv(key, type)"
)
View Source
const (
	TimestampName     = "timestamp"
	TimestampUsageMsg = "usage: timestamp(key)"

	LayoutUnix   = "unix"
	LayoutUnixMs = "unix_ms"
)
View Source
const (
	ToStrName     = "toStr"
	ToStrUsageMsg = "usage: toStr(key) or toStr(key, srcType)"
)
View Source
const (
	UnderRootName     = "underRoot"
	UnderRootUsageMsg = "usage: underRoot(key)"
)
View Source
const (
	HeaderRoot = "_root"
)

Variables

View Source
var DefaultgrokPattern = map[string]string{
	"USERNAME":  "[a-zA-Z0-9._-]+",
	"USER":      "%{USERNAME}",
	"INT":       "(?:[+-]?(?:[0-9]+))",
	"WORD":      "\\b\\w+\\b",
	"UUID":      "[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}-){3}[A-Fa-f0-9]{12}",
	"IPV4":      "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
	"PATH":      "(?:%{UNIXPATH}|%{WINPATH})",
	"UNIXPATH":  "(/[\\w_%!$@:.,-]?/?)(\\S+)?",
	"WINPATH":   "([A-Za-z]:|\\\\)(?:\\\\[^\\\\?*]*)+",
	"MONTHNUM":  "(?:0?[1-9]|1[0-2])",
	"MONTHDAY":  "(?:(?:0[1-9])|(?:[12][0-9])|(?:3[01])|[1-9])",
	"YEAR":      "(\\d\\d){1,2}",
	"DATE_US":   "%{MONTHNUM}[/-]%{MONTHDAY}[/-]%{YEAR}",
	"DATE_EU":   "%{MONTHDAY}[./-]%{MONTHNUM}[./-]%{YEAR}",
	"DATE_CN":   "%{YEAR}[./-]%{MONTHNUM}[./-]%{MONTHDAY}",
	"DATE":      "%{DATE_US}|%{DATE_EU}|%{DATE_CN}",
	"HOUR":      "(?:2[0123]|[01]?[0-9])",
	"MINUTE":    "(?:[0-5][0-9])",
	"SECOND":    "(?:(?:[0-5][0-9]|60)(?:[:.,][0-9]+)?)",
	"TIME":      "([^0-9]?)%{HOUR}:%{MINUTE}(?::%{SECOND})([^0-9]?)",
	"DATESTAMP": "%{DATE}[- ]%{TIME}",
}
View Source
var ErrorDropEvent = errors.New("DROP_EVENT")
View Source
var ErrorReturn = errors.New("RETURN")

Functions

func NewGrok added in v1.4.0

func NewGrok(match string, patternPaths []string, ignoreBlank bool, pattern map[string]string) *grok

func NewGrokAction added in v1.4.0

func NewGrokAction(args []string, extra cfg.CommonCfg) (*grokAction, error)

func RegisterAction

func RegisterAction(name string, f Factory)

Types

type Action

type Action interface {
	// contains filtered or unexported methods
}

type Add

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

func NewAdd

func NewAdd(args []string) (*Add, error)

type Config

type Config cfg.CommonCfg

func (*Config) ToActionCfg

func (c *Config) ToActionCfg() (*ConfigAction, error)

func (*Config) Validate

func (c *Config) Validate() error

type ConfigAction

type ConfigAction struct {
	Expression  string        `yaml:"action,omitempty"`
	IgnoreError bool          `yaml:"ignoreError,omitempty"`
	DropIfError bool          `yaml:"dropIfError,omitempty"`
	Extra       cfg.CommonCfg `yaml:",inline,omitempty"`
}

type ConvertStr added in v1.5.0

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

func NewConvertStr added in v1.5.0

func NewConvertStr(args []string) (*ConvertStr, error)

type Copy

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

func NewCopy

func NewCopy(args []string) (*Copy, error)

type Del

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

func NewDel

func NewDel(args []string) (*Del, error)

type DropEvent

type DropEvent struct {
}

func NewDropEvent

func NewDropEvent(args []string) (*DropEvent, error)

type Factory

type Factory func(args []string, extra cfg.CommonCfg) (Action, error)

type Fmt

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

func NewFmt

func NewFmt(args []string, extra cfg.CommonCfg) (*Fmt, error)

type FmtKey

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

func NewFmtKey

func NewFmtKey(args []string, extra cfg.CommonCfg) (*FmtKey, error)

type FmtKeyExtra

type FmtKeyExtra struct {
	Regex   string `yaml:"regex,omitempty" validate:"required"`
	Replace string `yaml:"replace,omitempty" validate:"required"`
}

type Instance

type Instance struct {
	Name string
	Action
	Config ConfigAction
}

func GetAction

func GetAction(c Config) (*Instance, error)

GetAction ..

func (*Instance) Exec

func (a *Instance) Exec(e api.Event) error

type JsonDecode

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

func NewJsonDecode

func NewJsonDecode(args []string) (*JsonDecode, error)

type JsonEncode added in v1.4.0

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

func NewJsonEncode added in v1.4.0

func NewJsonEncode(args []string) (*JsonEncode, error)

type Move

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

func NewMove

func NewMove(args []string) (*Move, error)

type Print

type Print struct {
}

func NewPrint

func NewPrint(args []string) (*Print, error)

type Regex

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

func NewRegex

func NewRegex(args []string, extra cfg.CommonCfg) (*Regex, error)

type Return

type Return struct {
}

func NewReturn

func NewReturn(args []string) (*Return, error)

type Set

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

Set is same with Add

func NewSet

func NewSet(args []string) (*Set, error)

type Split added in v1.4.0

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

func NewSplit added in v1.4.0

func NewSplit(args []string, extra cfg.CommonCfg) (*Split, error)

type SplitExtra added in v1.4.0

type SplitExtra struct {
	Separator string   `yaml:"separator,omitempty" validate:"required"`
	Max       int      `yaml:"max,omitempty" default:"-1"`
	Keys      []string `yaml:"keys,omitempty" validate:"required"`
}

type StrConvert

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

func NewStrConvert

func NewStrConvert(args []string) (*StrConvert, error)

type Timestamp

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

func NewTimestamp

func NewTimestamp(args []string, extra cfg.CommonCfg) (*Timestamp, error)

type UnderRoot

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

func NewUnderRoot

func NewUnderRoot(args []string) (*UnderRoot, error)

Jump to

Keyboard shortcuts

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