parser

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Builtins = map[string]Builtin{
	"common": Builtin{
		`^(?P<host>\S*) (?P<ident>\S*) (?P<user>\S*) \[(?P<time>.*)\] "(?P<method>\S+)(?: +(?P<resource>\S*) +(?P<proto>\S*?))?" (?P<status>\S*) (?P<bytes>\S*)`,
		"time",
		"%d/%b/%Y:%H:%M:%S %z",
		"Common Log Format",
		[]string{
			`152.120.218.99 - - [25/Jul/2020:12:25:54 +0900] "GET /category/books HTTP/1.1" 200 67`,
		},
	},
	"combined": Builtin{
		`^(?P<host>\S*) (?P<ident>\S*) (?P<user>\S*) \[(?P<time>.*)\] "(?P<method>\S+)(?: +(?P<resource>\S*) +(?P<proto>\S*?))?" (?P<status>\S*) (?P<bytes>\S*) "(?P<referer>.*)" "(?P<agent>.*)"`,
		"time",
		"%d/%b/%Y:%H:%M:%S %z",
		"Combined Log Format",
		[]string{
			`152.120.218.99 - - [25/Jul/2020:12:25:54 +0900] "GET /category/books HTTP/1.1" 200 67 "/item/electronics/4234" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"`,
		},
	},
	"postgresql": Builtin{
		`^(?P<timestamp>.*) \[(?P<pid>\S*)\] (?P<message_type>[^:]*):\s*(?P<message>.*)$`,
		"timestamp",
		"2006-01-02 03:04:05.000 MST",
		"Postgresql log",
		[]string{
			`2020-07-25 05:37:40.021 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432`,
		},
	},
}

Functions

This section is empty.

Types

type Builtin

type Builtin struct {
	Regexp   string
	TSKey    string
	TSFormat string
	Desc     string
	Samples  []string
}

type Option

type Option func(*Parser)

Option function change Parser option

func NoM0

func NoM0() Option

func NoRaw

func NoRaw() Option

func TSFormat added in v0.3.0

func TSFormat(tsFormat string) Option

func TSKey added in v0.3.0

func TSKey(tsKey string) Option

type Parsed

type Parsed struct {
	KVs     map[string]string
	TSKey   string
	TSValue time.Time
}

type Parser

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

func New

func New(regex string, opts ...Option) *Parser

New return Parser

func (*Parser) Parse

func (p *Parser) Parse(in string) Parsed

Parse string

func (*Parser) Schema

func (p *Parser) Schema() Schema

Schema return schema

type Schema

type Schema struct {
	Keys  []string
	TSKey string
}

Jump to

Keyboard shortcuts

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