regex

package
v0.0.0-...-db96926 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

Golang regexp package uses the RE2 syntax.

Example CLI usage (from honeytail root)

honeytail -p regex -k $HONEYTAIL_WRITEKEY \
  -f some/path/system.log \
  --dataset 'MY_TEST_DATASET' \
  --backfill \
  --regex.line_regex="(?P<time>\d{2}:\d{2}:\d{2}) (?P<field1>\w+)" \
  --regex.line_regex="(?P<foo>\w+)" \
  --regex.timefield="time" \
  --regex.time_format="%H:%M:%S"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseLineRegex

func ParseLineRegex(regexStr string) (*regexp.Regexp, error)

Compile a regex & validate expectations for log line parsing

func ParseLineRegexes

func ParseLineRegexes(regexStrs []string) ([]*regexp.Regexp, error)

Compile multiple log line regexes

Types

type Options

type Options struct {
	// Note: `LineRegex` and `line_regex` are named as singular so that
	// it's less confusing to users to input them.
	// Might be worth making this consistent across the entire repo
	LineRegex       []string `` /* 336-byte string literal not displayed */
	TimeFieldName   string   `long:"timefield" description:"Name of the field that contains a timestamp"`
	TimeFieldFormat string   `long:"time_format" description:"Timestamp format to use (strftime and Golang time.Parse supported)"`
	NumParsers      int      `hidden:"true" description:"number of regex parsers to spin up"`
}

type Parser

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

func (*Parser) Init

func (p *Parser) Init(options interface{}) error

func (*Parser) ProcessLines

func (p *Parser) ProcessLines(lines <-chan string, send chan<- event.Event, prefixRegex *parsers.ExtRegexp)

type RegexLineParser

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

func NewRegexLineParser

func NewRegexLineParser(regexStrs []string) (*RegexLineParser, error)

RegexLineParser factory

func (*RegexLineParser) ParseLine

func (p *RegexLineParser) ParseLine(line string) (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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