postgresql

package
v0.0.0-...-b962a07 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package postgresql contains code for parsing PostgreSQL slow query logs.

The Postgres slow query format ------------------------------

In general, Postgres logs consist of a prefix, a level, and a message:

2017-11-06 19:20:32 UTC [11534-2] LOG: autovacuum launcher shutting down |<-------------prefix----------->|level|<----------message-------------->|

2017-11-07 01:43:39 UTC [3542-7] postgres@test LOG: duration: 15.577 ms statement: SELECT * FROM test; |<-------------prefix------------------------>|level|<-------------------message---------------------->|

The format of the configuration prefix is configurable as `log_line_prefix` in postgresql.conf using the following format specifiers:

%a = application name
%u = user name
%d = database name
%r = remote host and port
%h = remote host
%p = process ID
%t = timestamp without milliseconds
%m = timestamp with milliseconds
%i = command tag
%e = SQL state
%c = session ID
%l = session line number
%s = session start timestamp
%v = virtual transaction ID
%x = transaction ID (0 if none)
%q = stop here in non-session
     processes
%% = '%'

For example, the prefix format for the lines above is: %t [%p-%l] %q%u@%d We currently require users to pass the prefix format as a parser option.

Slow query logs specifically have the following format: 2017-11-07 01:43:39 UTC [3542-7] postgres@test LOG: duration: 15.577 ms statement: SELECT * FROM test; |<-------------prefix------------------------>|<----------header-------------------->|<-----query----->|

For convenience, we call everything after the prefix but before the actual query string the "header".

The query may span multiple lines; continuations are indented. For example:

2017-11-07 01:43:39 UTC [3542-7] postgres@test LOG: duration: 15.577 ms statement: SELECT * FROM test

WHERE id=1;

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	LogLinePrefix string `long:"log_line_prefix" description:"Format string for PostgreSQL log line prefix"`
}

type Parser

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

func (*Parser) Init

func (p *Parser) Init(options interface{}) (err error)

func (*Parser) ProcessLines

func (p *Parser) ProcessLines(lines <-chan string, send chan<- event.Event, prefixRegex *parsers.ExtRegexp)

Jump to

Keyboard shortcuts

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