qan

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: May 15, 2015 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MIN_SLOWLOG_ROTATION_SIZE = 4096

Variables

This section is empty.

Functions

func ValidateConfig added in v1.0.5

func ValidateConfig(config *Config) error

Types

type Analyzer added in v1.0.11

type Analyzer interface {
	Start() error
	Stop() error
	Status() map[string]string
	String() string
	Config() Config
	SetConfig(Config)
}

An Analyzer runs a Worker at each Interval. Analyzers are responsible for MySQL: configuring, restarts, etc. The Worker is only ran when MySQL is configured and ready. Analyzers are also responsible for making Reports from the Results returned by Workers. The Worker determines the type of Analyzer: slowlog or perfschema. Analyzers are ran by the QAN Manager.

type AnalyzerFactory added in v1.0.11

type AnalyzerFactory interface {
	Make(config Config, name string, mysqlConn mysql.Connector, restartChan <-chan bool, tickChan chan time.Time) Analyzer
}

An AnalyzerFactory makes an Analyzer, real or mock.

type AnalyzerInstance added in v1.0.11

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

An AnalyzerInstnace is an Analyzer ran by a Manager, one per MySQL instance as configured.

type ByQueryTime

type ByQueryTime []*event.QueryClass

func (ByQueryTime) Len

func (a ByQueryTime) Len() int

func (ByQueryTime) Less

func (a ByQueryTime) Less(i, j int) bool

func (ByQueryTime) Swap

func (a ByQueryTime) Swap(i, j int)

type Config

type Config struct {
	proto.ServiceInstance
	// Manager
	CollectFrom       string // "slowlog" or "perfschema"
	Start             []mysql.Query
	Stop              []mysql.Query
	MaxWorkers        int
	Interval          uint  // minutes, "How often to report"
	MaxSlowLogSize    int64 // bytes, 0 = no max
	RemoveOldSlowLogs bool  // after rotating for MaxSlowLogSize
	// Worker
	ExampleQueries bool // only fingerprints if false
	WorkerRunTime  uint // seconds
	// Report
	ReportLimit uint
}

type Interval

type Interval struct {
	Number    int
	StartTime time.Time // UTC
	StopTime  time.Time // UTC
	// slowlog
	Filename    string // slow_query_log_file
	StartOffset int64  // bytes @ StartTime
	EndOffset   int64  // bytes @ StopTime
}

An Interval represents a period during which queries are fetched, aggregated, and reported. Intervals are created and sent by an IntervalIter. Analyzers use Intervals to set up and run Workers.

func (*Interval) String added in v1.0.1

func (i *Interval) String() string

type IntervalIter

type IntervalIter interface {
	Start()
	Stop()
	IntervalChan() chan *Interval
	TickChan() chan time.Time
}

An IntervalIter sends Intervals.

type IntervalIterFactory

type IntervalIterFactory interface {
	Make(analyzerType string, mysqlConn mysql.Connector, tickChan chan time.Time) IntervalIter
}

An IntervalIterFactory makes an IntervalIter, real or mock.

type Manager

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

A Manager runs AnalyzerInstances, one per MySQL instance as configured.

func NewManager

func NewManager(
	logger *pct.Logger,
	clock ticker.Manager,
	im *instance.Repo,
	mrm mrms.Monitor,
	mysqlFactory mysql.ConnectionFactory,
	analyzerFactory AnalyzerFactory,
) *Manager

func (*Manager) GetConfig

func (m *Manager) GetConfig() ([]proto.AgentConfig, []error)

func (*Manager) Handle

func (m *Manager) Handle(cmd *proto.Cmd) *proto.Reply

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) Status

func (m *Manager) Status() map[string]string

func (*Manager) Stop

func (m *Manager) Stop() error

type RealAnalyzer added in v1.0.11

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

func NewRealAnalyzer added in v1.0.11

func NewRealAnalyzer(logger *pct.Logger, config Config, iter IntervalIter, mysqlConn mysql.Connector, restartChan <-chan bool, worker Worker, clock ticker.Manager, spool data.Spooler) *RealAnalyzer

func (*RealAnalyzer) Config added in v1.0.12

func (a *RealAnalyzer) Config() Config

func (*RealAnalyzer) SetConfig added in v1.0.12

func (a *RealAnalyzer) SetConfig(config Config)

func (*RealAnalyzer) Start added in v1.0.11

func (a *RealAnalyzer) Start() error

func (*RealAnalyzer) Status added in v1.0.11

func (a *RealAnalyzer) Status() map[string]string

func (*RealAnalyzer) Stop added in v1.0.11

func (a *RealAnalyzer) Stop() error

func (*RealAnalyzer) String added in v1.0.11

func (a *RealAnalyzer) String() string

func (*RealAnalyzer) TakeOverPerconaServerRotation added in v1.0.12

func (a *RealAnalyzer) TakeOverPerconaServerRotation() error

Disable Percona Server slow log rotation and handle internally using the max_slowlog_size value. The slow log worker must rotate slow logs by itself to ensure full and proper parsing across rotations.

type Report

type Report struct {
	proto.ServiceInstance                     // MySQL instance
	StartTs               time.Time           // of interval, UTC
	EndTs                 time.Time           // of interval, UTC
	RunTime               float64             // seconds parsing data
	Global                *event.GlobalClass  // metrics for all data
	Class                 []*event.QueryClass // per-class metrics
	// slow log:
	SlowLogFile     string `json:",omitempty"` // not slow_query_log_file if rotated
	SlowLogFileSize int64  `json:",omitempty"`
	StartOffset     int64  `json:",omitempty"` // parsing starts
	EndOffset       int64  `json:",omitempty"` // parsing stops, but...
	StopOffset      int64  `json:",omitempty"` // ...parsing didn't complete if stop < end
}

Final QAN data struct, composed of a Result{} and metatdata, sent to the data.Spooler by the manager running the slow log or perfomance schema (pfs) parser.

func MakeReport

func MakeReport(config Config, interval *Interval, result *Result) *Report

type Result

type Result struct {
	Global     *event.GlobalClass  // metrics for all data
	Class      []*event.QueryClass // per-class metrics
	RunTime    float64             // seconds parsing data, hopefully < interval
	StopOffset int64               // slow log offset where parsing stopped, should be <= end offset
	Error      string              `json:",omitempty"`
}

Data for an interval from slow log or performance schema (pfs) parser, passed to MakeReport() which wraps it in a Report{} with metadata.

type Worker

type Worker interface {
	Setup(*Interval) error
	Run() (*Result, error)
	Stop() error
	Cleanup() error
	Status() map[string]string
}

A Worker gets queries, aggregates them, and returns a Result. Workers are ran by Analyzers. When ran, MySQL is presumed to be configured and ready.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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