qan

package
v0.0.0-...-0ffe786 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolStats

type BoolStats struct {
	Sum        uint64 // %true = Sum/Cnt
	OutlierSum uint64 `json:"-"`
}

BoolStats are boolean-based metrics like QC_Hit and Filesort.

type Class

type Class struct {
	Id            string       // 32-character hex checksum of fingerprint
	Fingerprint   string       // canonical form of query: values replaced with "?"
	Metrics       *Metrics     // statistics for each metric, e.g. max Query_time
	TotalQueries  uint         // total number of queries in class
	UniqueQueries uint         // unique number of queries in class
	Example       *Example     `json:",omitempty"` // sample query with max Query_time
	UserSources   []UserSource // user@host sources parsed from slow log
	StartAt       time.Time    // start time of the earliest query of this class
	EndAt         time.Time    // end time of the latest query of this class
	// --
	Outliers uint   `json:"-"`
	LastDb   string `json:"-"`
	Sample   bool   `json:"-"`
}

A Class represents all events with the same fingerprint and class ID. This is only enforced by convention, so be careful not to mix events from different classes.

type Example

type Example struct {
	QueryTime float64 // Query_time
	Db        string  // Schema: <db> or USE <db>
	Query     string  // truncated to MaxExampleBytes
	Explain   string  // explain
	Size      int     `json:",omitempty"` // Original size of query.
	Ts        string  `json:",omitempty"` // in MySQL time zone
}

A Example is a real query and its database, timestamp, and Query_time. If the query is larger than MaxExampleBytes, it is truncated and TruncatedExampleSuffix is appended.

type Metrics

type Metrics struct {
	TimeMetrics   map[string]*TimeStats   `json:",omitempty"`
	NumberMetrics map[string]*NumberStats `json:",omitempty"`
	BoolMetrics   map[string]*BoolStats   `json:",omitempty"`
}

type NumberStats

type NumberStats struct {
	Vals       []uint64 `json:"-"`
	Sum        uint64
	Min        *uint64 `json:",omitempty"`
	Avg        *uint64 `json:",omitempty"`
	Med        *uint64 `json:",omitempty"` // median
	P95        *uint64 `json:",omitempty"` // 95th percentile
	Max        *uint64 `json:",omitempty"`
	OutlierSum uint64  `json:"-"`
}

NumberStats are integer-based metrics like Rows_sent and Merge_passes.

type Profile

type Profile struct {
	InstanceId   string      // UUID of MySQL instance
	Begin        time.Time   // time range [Begin, End)
	End          time.Time   // time range [Being, End)
	TotalTime    uint        // total seconds in time range minus gaps (missing periods)
	TotalQueries uint        // total unique class queries in time range
	RankBy       RankBy      // criteria for ranking queries compared to global
	Query        []QueryRank // 0=global, 1..N=queries
}

type QueryLog

type QueryLog struct {
	Point          uint
	Start_ts       time.Time
	Query_count    float32
	Query_load     float32
	Query_time_avg float32
}

start_ts, query_count, Query_time_sum

type QueryRank

type QueryRank struct {
	Rank        uint    // compared to global, same as Profile.Ranks index
	Percentage  float64 // of global value
	Id          string  // hex checksum
	Abstract    string  // e.g. SELECT tbl
	Fingerprint string  // e.g. SELECT tbl
	QPS         float64 // ResponseTime.Cnt / Profile.TotalTime
	Load        float64 // Query_time_sum / (Profile.End - Profile.Begin)
	Log         []QueryLog
	Stats       metrics.Stats // this query's Profile.Metric stats
}

type QueryReport

type QueryReport struct {
	InstanceId string                   // UUID of MySQL instance
	Begin      time.Time                // time range [Begin, End)
	End        time.Time                // time range [Being, End)
	Query      query.Query              // id, abstract, fingerprint, etc.
	Metrics    map[string]metrics.Stats // keyed on metric name, e.g. Query_time
	Example    query.Example            // query example
	Sparks     []interface{}            `json:",omitempty"`
	Metrics2   interface{}              `json:",omitempty"`
	Sparks2    interface{}              `json:",omitempty"`
}

type RankBy

type RankBy struct {
	Metric string // default: Query_time
	Stat   string // default: sum
	Limit  uint   // default: 10
}

type Report

type Report struct {
	UUID    string    // UUID of MySQL instance
	StartTs time.Time // Start time of interval, UTC
	EndTs   time.Time // Stop time of interval, UTC
	RunTime float64   // Time parsing data, seconds
	Global  *Class    // Metrics for all data
	Class   []*Class  // 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
	RateLimit       uint   `json:",omitempty"` // Percona Server rate limit
}

type Summary

type Summary struct {
	InstanceId string                   // UUID of MySQL instance
	Begin      time.Time                // time range [Begin, End)
	End        time.Time                // time range [Being, End)
	Metrics    map[string]metrics.Stats // keyed on metric name, e.g. Query_time
	Sparks     []interface{}            `json:",omitempty"`
	Metrics2   interface{}              `json:",omitempty"`
	Sparks2    interface{}              `json:",omitempty"`
}

type TimeStats

type TimeStats struct {
	Vals       []float64 `json:"-"`
	Sum        float64
	Min        *float64 `json:",omitempty"`
	Avg        *float64 `json:",omitempty"`
	Med        *float64 `json:",omitempty"` // median
	P95        *float64 `json:",omitempty"` // 95th percentile
	Max        *float64 `json:",omitempty"`
	OutlierSum float64  `json:"-"`
}

TimeStats are microsecond-based metrics like Query_time and Lock_time.

type UserSource

type UserSource struct {
	Ts   int64 // unix nano timestamp
	User string
	Host string
}

A UserSource is a user@host source parsed from slow log

Jump to

Keyboard shortcuts

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