Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorResponse(w http.ResponseWriter, err error)
- func JSONResponse(w http.ResponseWriter, statusCode int, v interface{})
- func WriteAccessControlHeaders(w http.ResponseWriter)
- type Agent
- type AgentConfig
- type AuthResponse
- type Cmd
- type Data
- type DataSpoolLimits
- type Endpoint
- type Error
- type ExplainQuery
- type ExplainResult
- type ExplainRow
- type Exporter
- type Host
- type Instance
- type JsonGzipSerializer
- type JsonSerializer
- type Links
- type LogEntry
- type NullFloat64
- type NullInt64
- type NullString
- type NullTime
- type Reply
- type Response
- type Serializer
- type ServiceData
- type ShowIndexRow
- type ShowTableStatus
- type Subsystem
- type Table
- type TableInfo
- type TableInfoQuery
- type TableInfoResult
- type Version
Constants ¶
const ( DEFAULT_AGENT_API_PORT = "9000" DEFAULT_QAN_API_PORT = "9001" DEFAULT_PROM_CONFIG_API_PORT = "9003" DEFAULT_METRICS_API_PORT = "9004" )
const ( LOG_EMERGENCY byte = iota // not used LOG_ALERT // not used LOG_CRITICAL // not used LOG_ERROR LOG_WARNING LOG_NOTICE LOG_INFO LOG_DEBUG )
http://en.wikipedia.org/wiki/Syslog#Severity_levels
const MAX_DATA_SIZE = 1024 * 1024 * 5
In go-mysql/event/query_class.go MAX_EXAMPLE_BYTES=1024*10 (10 KiB) and default top query limit is 200 which = ~2M. Then add overhead for JSON and a single data msg should not exceed 5 MiB which very liberal because the real-world avg is about 300 KiB/msg for QAN (30 KiB/msg for MM).
const VERSION = "1.0"
Variables ¶
var HostTypes = []string{"os", "mysql"}
var LogLevelName []string = []string{
"emergency",
"alert",
"critical",
"error",
"warning",
"notice",
"info",
"debug",
}
var LogLevelNumber map[string]byte = map[string]byte{ "emergency": LOG_EMERGENCY, "alert": LOG_ALERT, "critical": LOG_CRITICAL, "error": LOG_ERROR, "warning": LOG_WARNING, "notice": LOG_NOTICE, "info": LOG_INFO, "debug": LOG_DEBUG, }
Functions ¶
func ErrorResponse ¶
func ErrorResponse(w http.ResponseWriter, err error)
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, statusCode int, v interface{})
func WriteAccessControlHeaders ¶
func WriteAccessControlHeaders(w http.ResponseWriter)
Types ¶
type AgentConfig ¶
type AuthResponse ¶
type AuthResponse struct { Code uint // standard HTTP status (http://httpstatus.es/) Error string // empty if auth ok (Code=200) }
type Cmd ¶
type Cmd struct { Id string `json:",omitempty"` // set by API Ts time.Time User string AgentUUID string Service string Cmd string Data []byte `json:",omitempty"` }
Sent by API to agent
type Data ¶
type Data struct { // Agent sets: ProtocolVersion string Created time.Time // when Data was spooled (UTC) Hostname string // OS instance name the agent is running on Service string // which tool ContentType string // of Data ("application/json") ContentEncoding string // of Data ("gzip" or empty) Data []byte // encoded tool data }
Data from a tool
type DataSpoolLimits ¶
type ExplainQuery ¶
type ExplainResult ¶
type ExplainResult struct { Classic []*ExplainRow JSON string // since MySQL 5.6.5 }
type ExplainRow ¶
type ExplainRow struct { Id NullInt64 SelectType NullString Table NullString Partitions NullString // split by comma; since MySQL 5.1 CreateTable NullString // @todo Type NullString PossibleKeys NullString // split by comma Key NullString KeyLen NullString // https://jira.percona.com/browse/PCT-863 Ref NullString Rows NullInt64 Filtered NullFloat64 // as of 5.7.3 Extra NullString // split by semicolon }
type Instance ¶
type Instance struct { Subsystem string // Subsystem.Name ParentUUID string Id uint // internal ID for joining data tables UUID string // primary ID, for accessing API Name string // secondary ID, for human readability DSN string // type-specific DSN, if any Distro string Version string Created time.Time Deleted time.Time Links map[string]string `json:",omitempty"` }
type JsonGzipSerializer ¶
type JsonGzipSerializer struct {
// contains filtered or unexported fields
}
func NewJsonGzipSerializer ¶
func NewJsonGzipSerializer() *JsonGzipSerializer
func (*JsonGzipSerializer) Concurrent ¶
func (s *JsonGzipSerializer) Concurrent() bool
func (*JsonGzipSerializer) Encoding ¶
func (s *JsonGzipSerializer) Encoding() string
func (*JsonGzipSerializer) ToBytes ¶
func (s *JsonGzipSerializer) ToBytes(data interface{}) ([]byte, error)
type JsonSerializer ¶
type JsonSerializer struct { }
func NewJsonSerializer ¶
func NewJsonSerializer() *JsonSerializer
func (*JsonSerializer) Concurrent ¶
func (s *JsonSerializer) Concurrent() bool
func (*JsonSerializer) Encoding ¶
func (s *JsonSerializer) Encoding() string
func (*JsonSerializer) ToBytes ¶
func (j *JsonSerializer) ToBytes(data interface{}) ([]byte, error)
type NullFloat64 ¶
type NullFloat64 struct {
sql.NullFloat64
}
func (NullFloat64) Equal ¶
func (n NullFloat64) Equal(u NullFloat64) bool
func (NullFloat64) MarshalJSON ¶
func (n NullFloat64) MarshalJSON() (b []byte, err error)
func (*NullFloat64) UnmarshalJSON ¶
func (n *NullFloat64) UnmarshalJSON(b []byte) error
type NullString ¶
type NullString struct {
sql.NullString
}
func (NullString) Equal ¶
func (n NullString) Equal(u NullString) bool
func (*NullString) MarshalJSON ¶
func (n *NullString) MarshalJSON() (b []byte, err error)
func (*NullString) UnmarshalJSON ¶
func (n *NullString) UnmarshalJSON(b []byte) error
type Reply ¶
type Reply struct { Id string // set by API Cmd string // original Cmd.Cmd Error string // success if empty Data []byte `json:",omitempty"` }
Sent by agent in response to every command
type Response ¶
type Response struct { Code uint // standard HTTP status (http://httpstatus.es/) Error string // empty if ok (Code=200) }
type Serializer ¶
type ServiceData ¶
type ServiceData struct { Name string Config []byte `json:",omitempty"` // cloud-tools/<service>/config.go }
Data for StartService and StopService command replies
type ShowIndexRow ¶
type ShowIndexRow struct { Table string NonUnique bool KeyName string SeqInIndex int ColumnName string Collation NullString Cardinality NullInt64 SubPart NullInt64 Packed NullString Null NullString IndexType string Comment NullString IndexComment NullString Visible NullString }
ShowIndexRow describes one row from `SHOW INDEX FROM %s` query. # mysql -e 'SHOW INDEX FROM mysql.user\G' *************************** 1. row ***************************
Table: user Non_unique: 0 Key_name: PRIMARY
Seq_in_index: 1
Column_name: Host Collation: A Cardinality: 2 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment:
Index_comment:
Visible: YES
*************************** 2. row ***************************
Table: user Non_unique: 0 Key_name: PRIMARY
Seq_in_index: 2
Column_name: User Collation: A Cardinality: 5 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment:
Index_comment:
Visible: YES
# mysql -e 'DESCRIBE INFORMATION_SCHEMA.STATISTICS' +---------------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------------+------------------+------+-----+---------+-------+ | TABLE_CATALOG | varchar(64) | NO | | NULL | | | TABLE_SCHEMA | varchar(64) | NO | | NULL | | | TABLE_NAME | varchar(64) | NO | | NULL | | | NON_UNIQUE | int(1) | NO | | 0 | | | INDEX_SCHEMA | varchar(64) | NO | | NULL | | | INDEX_NAME | varchar(64) | YES | | NULL | | | SEQ_IN_INDEX | int(10) unsigned | NO | | NULL | | | COLUMN_NAME | varchar(64) | YES | | NULL | | | COLLATION | varchar(1) | YES | | NULL | | | CARDINALITY | bigint(21) | YES | | NULL | | | SUB_PART | bigint(21) | YES | | NULL | | | PACKED | binary(0) | YES | | NULL | | | NULLABLE | varchar(3) | NO | | | | | INDEX_TYPE | varchar(11) | NO | | | | | COMMENT | varchar(8) | NO | | | | | INDEX_COMMENT | varchar(2048) | NO | | NULL | | | IS_VISIBLE | varchar(3) | NO | | | | +---------------+------------------+------+-----+---------+-------+
type ShowTableStatus ¶
type ShowTableStatus struct { Name string Engine string Version string RowFormat string Rows NullInt64 AvgRowLength NullInt64 DataLength NullInt64 MaxDataLength NullInt64 IndexLength NullInt64 DataFree NullInt64 AutoIncrement NullInt64 CreateTime NullTime UpdateTime NullTime CheckTime NullTime Collation NullString Checksum NullString CreateOptions NullString Comment NullString }
type TableInfo ¶
type TableInfo struct { Create string `json:",omitempty"` Index map[string][]ShowIndexRow `json:",omitempty"` Status *ShowTableStatus `json:",omitempty"` Errors []string `json:",omitempty"` }