parser

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT, MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeStampLayout        = "2006/01/02 15:04:05.000 -07:00"
	FormerTimeStampLayout  = "2006/01/02 15:04:05.000"
	TiFlashTimeStampLayout = "2006.01.02 15:04:05.000000"
	PromTimeStampLayout    = time.RFC3339Nano
)

Variables

View Source
var LevelTypeMap = map[string]item.LevelType{
	"CRITICAL": item.LevelFATAL,
	"FATAL":    item.LevelFATAL,
	"ERROR":    item.LevelERROR,
	"ERRO":     item.LevelERROR,
	"WARNING":  item.LevelWARN,
	"WARN":     item.LevelWARN,
	"INFO":     item.LevelINFO,
	"DEBUG":    item.LevelDEBUG,
}
View Source
var (
	PDLogV2RE = regexp.MustCompile(`^([0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3})\s[^\s]*\s\[([^\[\]]*)\]`)
)
View Source
var (
	PrometheusLogRE = regexp.MustCompile(`^level=([a-z]*) ts=([0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}[\S]*) [.]*`)
)
View Source
var (
	SlowQueryRE = regexp.MustCompile("^# Time: (.*)$")
)
View Source
var (
	TiFlashErrLogRE = regexp.MustCompile(`^([0-9]{4}\.[0-9]{2}\.[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}) \[ [0-9] \] <([^\[\]]*)>`)
)
View Source
var (
	TiKVLogRE = regexp.MustCompile(`^([0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3})\s([^\s]*)`)
)
View Source
var (
	UnifiedLogRE = regexp.MustCompile(`^\[([^\[\]]*)\]\s\[([^\[\]]*)\]`)
)

Functions

func ParseLogLevel

func ParseLogLevel(b []byte) item.LevelType

Types

type FileWrapper

type FileWrapper struct {
	Root     string
	Host     string
	Folder   string
	Filename string
}

FileWrapper is mapped from a file path, which is in the format of /{root}/{ip}/{component}:{port}/{xxx}.log

func NewFileWrapper

func NewFileWrapper(root, host, folder, filename string) *FileWrapper

NewFileWrapper creates a file wrapper

func ResolveDir

func ResolveDir(src string) ([]*FileWrapper, error)

ResolveDir traversing a folder and parse it's struct, generating a list of file wrapper.

func (*FileWrapper) Open

func (fw *FileWrapper) Open() (*os.File, error)

Open the file fw represent.

func (*FileWrapper) ParseFolderName

func (fw *FileWrapper) ParseFolderName() (comp string, port string, err error)

ParseFolderName returns the component name and port it listening on.

type PDLogV2Parser

type PDLogV2Parser struct{}

Parse pd (v2.x) log, example: 2019/08/21 02:11:54.405 util.go:59: [info] Release Version: v2.1.12

func (*PDLogV2Parser) ParseHead

func (*PDLogV2Parser) ParseHead(head []byte) (*time.Time, item.LevelType)

type Parser

type Parser interface {
	// Parse the first line of the log, and return ts and level,
	// if it's not the first line, nil will be returned.
	ParseHead(head []byte) (*time.Time, item.LevelType)
}

Parser is the log parser representation

func List

func List() []Parser

List all parsers this package has **not used anymore**

func ListStd

func ListStd() []Parser

ListStd return all std log parsers this package has

type PrometheusLogParser

type PrometheusLogParser struct{}

Parse prometheus and alertmanager log, example: level=warn ts=2022-06-09T09:16:54.674Z caller=main.go:377 deprecation_notice="'storage.tsdb.retention' flag is deprecated use 'storage.tsdb.retention.time' instead."

func (*PrometheusLogParser) ParseHead

func (*PrometheusLogParser) ParseHead(head []byte) (*time.Time, item.LevelType)

type SlowQueryParser

type SlowQueryParser struct{}

SlowQueryParser is a parser for tidb slow query log, example: # Time: 2019-08-22T10:46:31.81833097+08:00 # Txn_start_ts: 410633369355550820 # User: root@127.0.0.1 # Conn_ID: 2073 # Query_time: 0.522346068 # DB: sbtest # Is_internal: false # Digest: 24e32e2ec145a5ce9632abaa8ebfa009481a9f779c9ad50f4cf353fc8a7f63f7 # Num_cop_tasks: 0 # Cop_proc_avg: 0 Cop_proc_p90: 0 Cop_proc_max: 0

func (*SlowQueryParser) ParseHead

func (*SlowQueryParser) ParseHead(head []byte) (*time.Time, item.LevelType)

ParseHead parses headers

type TiFlashErrLogParser

type TiFlashErrLogParser struct{}

Parse tiflash error log, example: 2021.11.01 23:31:29.123456 [ 1 ] <Error> pingcap.tikv: Get Failed14: failed to connect to all addresses

func (*TiFlashErrLogParser) ParseHead

func (*TiFlashErrLogParser) ParseHead(head []byte) (*time.Time, item.LevelType)

type TiKVLogV2Parser

type TiKVLogV2Parser struct{}

Parse tikv (v2.x) log, example: 2019/08/13 03:27:49.382 INFO mod.rs:26: Welcome to TiKV. Release Version: 2.1.13 Git Commit Hash: b3cf3c8d642534ea6fa93d475a46da285cc6acbf Git Commit Branch: HEAD UTC Build Time: 2019-06-21 12:25:23 Rust Version: rustc 1.29.0-nightly (4f3c7a472 2018-07-17)

func (*TiKVLogV2Parser) ParseHead

func (*TiKVLogV2Parser) ParseHead(head []byte) (*time.Time, item.LevelType)

type UnifiedJSONLogParser

type UnifiedJSONLogParser struct{}

Parse unified JSON log, include tidb v2 and v3, pd v3 and tikv v3, examples: {"level":"INFO","time":"2022/01/14 08:09:55.307 +01:00","caller":"printer.go:34","message":"Welcome to TiDB.","Release Version":"v5.3.0","Edition":"Community","Git Commit Hash":"4a1b2e9fe5b5afb1068c56de47adb07098d768d6","Git Branch":"heads/refs/tags/v5.3.0","UTC Build Time":"2021-11-24 13:32:39","GoVersion":"go1.16.4","Race Enabled":false,"Check Table Before Drop":false,"TiKV Min Version":"v3.0.0-60965b006877ca7234adaced7890d7b029ed1306"}

func (*UnifiedJSONLogParser) ParseHead

func (*UnifiedJSONLogParser) ParseHead(head []byte) (*time.Time, item.LevelType)

type UnifiedLogParser

type UnifiedLogParser struct{}

Parse unified log, include tidb v2 and v3, pd v3 and tikv v3, examples: [2019/08/26 06:19:13.011 -04:00] [INFO] [printer.go:41] ["Welcome to TiDB."] ["Release Version"=v2.1.14]... [2019/08/26 07:19:49.529 -04:00] [INFO] [printer.go:41] ["Welcome to TiDB."] ["Release Version"=v3.0.2]... [2019/08/21 01:43:01.460 -04:00] [INFO] [util.go:60] [PD] [release-version=v3.0.2] [2019/08/26 07:20:23.815 -04:00] [INFO] [mod.rs:28] ["Release Version: 3.0.2"]

func (*UnifiedLogParser) ParseHead

func (*UnifiedLogParser) ParseHead(head []byte) (*time.Time, item.LevelType)

Jump to

Keyboard shortcuts

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