Documentation ¶
Overview ¶
Package log provides an interface and data structures for MySQL log parsers. Log parsing yields events that are aggregated to calculate metric statistics like max Query_time. See also percona.com/go-mysql/event/.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Offset uint64 // byte offset in file at which event starts OffsetEnd uint64 // byte offset in file at which event ends Ts time.Time // timestamp of event Admin bool // true if Query is admin command Query string // SQL query or admin command User string Host string Db string Server string LabelsKey []string LabelsValue []string TimeMetrics map[string]float64 // *_time and *_wait metrics NumberMetrics map[string]uint64 // most metrics BoolMetrics map[string]bool // yes/no metrics RateType string // Percona Server rate limit type RateLimit uint // Percona Server rate limit value }
An event is a query like "SELECT col FROM t WHERE id = 1", some metrics like Query_time (slow log) or SUM_TIMER_WAIT (Performance Schema), and other metadata like default database, timestamp, etc. Metrics and metadata are not guaranteed to be defined--and frequently they are not--but at minimum an event is expected to define the query and Query_time metric. Other metrics and metadata vary according to MySQL version, distro, and configuration.
type Options ¶
type Options struct { StartOffset uint64 // byte offset in file at which to start parsing FilterAdminCommand map[string]bool // admin commands to ignore Debug bool // print trace info to STDERR with standard library logger Debugf func(format string, v ...interface{}) // use this function for logging instead of log.Printf (Debug still should be true) DefaultLocation *time.Location // DefaultLocation to assume for logs in MySQL < 5.7 format. }
Options encapsulate common options for making a new LogParser.