Documentation
¶
Overview ¶
Package slowquery parses already-stored container log lines (see internal/api/database_slow_queries.go) into structured slow-query entries for Postgres and MySQL. Redis has no log-based slow query record (SLOWLOG is a live-server command, not log output) and is deliberately not handled here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Timestamp time.Time
// DurationMs is the statement's own reported execution time in
// milliseconds (Postgres' "duration:", MySQL's "Query_time"
// converted from seconds).
DurationMs float64
Query string
// RowsExamined is 0 when the engine's slow query log doesn't report
// it (Postgres never does; MySQL always does for a real slow-log
// entry).
RowsExamined int64
}
Entry is one parsed slow query.
func ParseMySQL ¶
ParseMySQL extracts every slow-query entry from lines, in the order given, reconstructing each entry's multi-line block: a "# Query_time:" header, an optional "# User@Host:"/"SET timestamp=...;" line, then one or more lines of SQL text terminated by the next header line (another "#"-prefixed line) or the end of input. Everything before the first header line, and any "#"-prefixed line that isn't a header this package recognizes (e.g. "# Time:", "# User@Host:"), is skipped.
func ParsePostgres ¶
ParsePostgres extracts every slow-statement entry from lines, in the order given. Non-matching lines (ordinary Postgres log output that isn't a duration line) are skipped, not treated as an error: the raw log stream mixes slow-query lines with every other message Postgres writes to stderr.