Documentation ¶
Index ¶
- Constants
- Variables
- func AnalyzeBackendLogLines(logLines []state.LogLine) (logLinesOut []state.LogLine, samples []state.PostgresQuerySample)
- func AnalyzeLogLines(logLinesIn []state.LogLine) (logLinesOut []state.LogLine, samples []state.PostgresQuerySample)
- func IsSupportedPrefix(prefix string) bool
- func ParseAndAnalyzeBuffer(logStream LineReader, linesNewerThan time.Time, server *state.Server) ([]state.LogLine, []state.PostgresQuerySample)
- func ParseLogLineWithPrefix(prefix string, line string) (logLine state.LogLine, ok bool)
- func PrintDebugInfo(logFileContents string, logLines []state.LogLine, ...)
- func PrintDebugLogLines(logFileContents string, logLines []state.LogLine, ...)
- func ReplaceSecrets(input []byte, logLines []state.LogLine, filterLogSecret []state.LogSecretKind) []byte
- func ValidateLogCollectionConfig(server *state.Server, settings []state.PostgresSetting) (bool, bool, bool, string)
- type LineReader
- type MaybeHerokuLogReader
Constants ¶
View Source
const LogPrefixAmazonRds string = "%t:%r:%u@%d:[%p]:"
View Source
const LogPrefixAzure string = "%t-%c-"
View Source
const LogPrefixCustom1 string = "%m [%p][%v] : [%l-1] %q[app=%a] "
View Source
const LogPrefixCustom10 string = "%m [%p]: [%l-1] db=%d,user=%u "
View Source
const LogPrefixCustom11 string = "pid=%p,user=%u,db=%d,app=%a,client=%h "
View Source
const LogPrefixCustom12 string = "user=%u,db=%d,app=%a,client=%h "
View Source
const LogPrefixCustom13 string = "%p-%s-%c-%l-%h-%u-%d-%m "
View Source
const LogPrefixCustom14 string = "%m [%p][%b][%v][%x] %q[user=%u,db=%d,app=%a] "
View Source
const LogPrefixCustom15 string = "%m [%p] %q%u@%d "
View Source
const LogPrefixCustom16 string = "%t [%p] %q%u@%d %h "
View Source
const LogPrefixCustom2 string = "%t [%p-%l] %q%u@%d "
View Source
const LogPrefixCustom3 string = "%m [%p] %q[user=%u,db=%d,app=%a] "
View Source
const LogPrefixCustom4 string = "%m [%p] %q[user=%u,db=%d,app=%a,host=%h] "
View Source
const LogPrefixCustom5 string = "%t [%p]: [%l-1] user=%u,db=%d - PG-%e "
View Source
const LogPrefixCustom6 string = "%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h "
View Source
const LogPrefixCustom7 string = "%t [%p]: [%l-1] [trx_id=%x] user=%u,db=%d "
View Source
const LogPrefixCustom8 string = "[%p]: [%l-1] db=%d,user=%u "
View Source
const LogPrefixCustom9 string = "%m %r %u %a [%c] [%p] "
View Source
const LogPrefixEmpty string = ""
View Source
const LogPrefixHeroku1 string = " sql_error_code = %e "
View Source
const LogPrefixHeroku2 string = `` /* 186-byte string literal not displayed */
View Source
const LogPrefixHerokuHobbyTier string = " database = %d connection_source = %r sql_error_code = %e "
Used only to recognize the Heroku hobby tier log_line_prefix to give a warning (logs are not supported on hobby tier) and avoid errors during prefix check; logs with this prefix are never actually received
View Source
const LogPrefixSimple string = "%m [%p] "
View Source
const MinSupportedLogMinDurationStatement = 10
Variables ¶
View Source
var AppBeforeCommaRegexp = `([^,]*)` // %a
View Source
var AppBeforeQuoteRegexp = `([^"]*)` // %a
View Source
var AppBeforeSpaceRegexp = `(\S*)` // %a
View Source
var AppInsideBracketsRegexp = `(\[unknown\]|[^,\]]*)` // %a
View Source
var BackendTypeRegexp = `([\w ]+)` // %b
View Source
var DbRegexp = `(\S*)` // %d
View Source
var HerokuPostgresDebugRegexp = regexp.MustCompile(`^(\w+ \d+ \d+:\d+:\d+ \w+ app\[postgres\] \w+ )?\[(\w+)\] \[\d+-\d+\] (.+)`)
View Source
var HostAndPortRegexp = `(.+(?:\(\d+\))?)?` // %r
View Source
var HostRegexp = `(\S*)` // %h
View Source
var LevelAndContentRegexp = `(\w+):\s+(.*\n?)$`
View Source
var LogLineCounterRegexp = `(\d+)` // %l
View Source
var LogPrefixAmazonRdsRegexp = regexp.MustCompile(`(?s)^` + TimeRegexp + `:` + HostAndPortRegexp + `:` + UserRegexp + `@` + DbRegexp + `:\[` + PidRegexp + `\]:` + LevelAndContentRegexp)
View Source
var LogPrefixAzureRegexp = regexp.MustCompile(`(?s)^` + TimeRegexp + `-` + SessionIdRegexp + `-` + LevelAndContentRegexp)
View Source
var LogPrefixCustom10Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\]: \[` + LogLineCounterRegexp + `-1\] db=` + DbRegexp + `,user=` + UserRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom11Regexp = regexp.MustCompile(`(?s)^pid=` + PidRegexp + `,user=` + UserRegexp + `,db=` + DbRegexp + `,app=` + AppBeforeCommaRegexp + `,client=` + HostRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom12Regexp = regexp.MustCompile(`(?s)^user=` + UserRegexp + `,db=` + DbRegexp + `,app=` + AppBeforeCommaRegexp + `,client=` + HostRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom13Regexp = regexp.MustCompile(`(?s)^` + PidRegexp + `-` + TimeRegexp + `-` + SessionIdRegexp + `-` + LogLineCounterRegexp + `-` + HostRegexp + `-` + UserRegexp + `-` + DbRegexp + `-` + TimeRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom14Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\]\[` + BackendTypeRegexp + `\]\[` + VirtualTxRegexp + `\]\[` + TransactionIdRegexp + `\] (?:\[user=` + UserRegexp + `,db=` + DbRegexp + `,app=` + AppInsideBracketsRegexp + `\] )?` + LevelAndContentRegexp)
View Source
var LogPrefixCustom15Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\] ` + `(?:` + UserRegexp + `@` + DbRegexp + ` )?` + LevelAndContentRegexp)
View Source
var LogPrefixCustom16Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\] ` + `(?:` + UserRegexp + `@` + DbRegexp + ` ` + HostRegexp + ` )?` + LevelAndContentRegexp)
View Source
var LogPrefixCustom1Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\]\[` + VirtualTxRegexp + `\] : \[` + LogLineCounterRegexp + `-1\] (?:\[app=` + AppInsideBracketsRegexp + `\] )?` + LevelAndContentRegexp)
View Source
var LogPrefixCustom2Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `-` + LogLineCounterRegexp + `\] ` + `(?:` + UserRegexp + `@` + DbRegexp + ` )?` + LevelAndContentRegexp)
View Source
var LogPrefixCustom3Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\] (?:\[user=` + UserRegexp + `,db=` + DbRegexp + `,app=` + AppInsideBracketsRegexp + `\] )?` + LevelAndContentRegexp)
View Source
var LogPrefixCustom4Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\] (?:\[user=` + UserRegexp + `,db=` + DbRegexp + `,app=` + AppBeforeCommaRegexp + `,host=` + HostRegexp + `\] )?` + LevelAndContentRegexp)
View Source
var LogPrefixCustom5Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\]: \[` + LogLineCounterRegexp + `-1\] user=` + UserRegexp + `,db=` + DbRegexp + ` - PG-` + SqlstateRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom6Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\]: \[` + LogLineCounterRegexp + `-1\] user=` + UserRegexp + `,db=` + DbRegexp + `,app=` + AppBeforeCommaRegexp + `,client=` + HostRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom7Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\]: \[` + LogLineCounterRegexp + `-1\] \[trx_id=` + TransactionIdRegexp + `\] user=` + UserRegexp + `,db=` + DbRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom8Regexp = regexp.MustCompile(`(?s)^\[` + PidRegexp + `\]: \[` + LogLineCounterRegexp + `-1\] db=` + DbRegexp + `,user=` + UserRegexp + ` ` + LevelAndContentRegexp)
View Source
var LogPrefixCustom9Regexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` ` + HostAndPortRegexp + ` ` + UserRegexp + ` ` + AppBeforeSpaceRegexp + ` \[` + SessionIdRegexp + `\] \[` + PidRegexp + `\] ` + LevelAndContentRegexp)
View Source
var LogPrefixHeroku1Regexp = regexp.MustCompile(`^ sql_error_code = ` + SqlstateRegexp + " " + LevelAndContentRegexp)
View Source
var LogPrefixHeroku2Regexp = regexp.MustCompile(`^ sql_error_code = ` + SqlstateRegexp + ` time_ms = "` + TimeRegexp + `" pid="` + PidRegexp + `" proc_start_time="` + TimeRegexp + `" session_id="` + SessionIdRegexp + `" vtid="` + VirtualTxRegexp + `" tid="` + TransactionIdRegexp + `" log_line="` + LogLineCounterRegexp + `" (?:database="` + DbRegexp + `" connection_source="` + HostAndPortRegexp + `" user="` + UserRegexp + `" application_name="` + AppBeforeQuoteRegexp + `" )?` + LevelAndContentRegexp)
View Source
var LogPrefixNoTimestampUserDatabaseAppRegexp = regexp.MustCompile(`(?s)^\[user=` + UserRegexp + `,db=` + DbRegexp + `,app=` + AppInsideBracketsRegexp + `\] ` + LevelAndContentRegexp)
View Source
var LogPrefixSimpleRegexp = regexp.MustCompile(`(?s)^` + TimeRegexp + ` \[` + PidRegexp + `\] ` + LevelAndContentRegexp)
View Source
var PidRegexp = `(\d+)` // %p
View Source
var RecommendedPrefixIdx = 4
View Source
var RsyslogHostnameRegxp = `(\S+)`
View Source
var RsyslogLevelAndContentRegexp = `(?:(\w+):\s+)?(.*\n?)$`
View Source
var RsyslogProcessNameRegexp = `(\w+)`
View Source
var RsyslogRegexp = regexp.MustCompile(`^` + RsyslogTimeRegexp + ` ` + RsyslogHostnameRegxp + ` ` + RsyslogProcessNameRegexp + `\[` + PidRegexp + `\]: ` + SyslogSequenceAndSplitRegexp + ` ` + RsyslogLevelAndContentRegexp)
View Source
var RsyslogTimeRegexp = `(\w+\s+\d+ \d{2}:\d{2}:\d{2})`
View Source
var SessionIdRegexp = `(\w+\.\w+)` // %c
View Source
var SqlstateRegexp = `(\w{5})` // %e
View Source
var SupportedPrefixes = []string{ LogPrefixAmazonRds, LogPrefixAzure, LogPrefixCustom1, LogPrefixCustom2, LogPrefixCustom3, LogPrefixCustom4, LogPrefixCustom5, LogPrefixCustom6, LogPrefixCustom7, LogPrefixCustom8, LogPrefixCustom9, LogPrefixCustom10, LogPrefixCustom11, LogPrefixCustom12, LogPrefixCustom13, LogPrefixCustom14, LogPrefixCustom15, LogPrefixCustom16, LogPrefixSimple, LogPrefixHeroku1, LogPrefixHeroku2, LogPrefixEmpty, }
View Source
var SyslogSequenceAndSplitRegexp = `(\[[\d-]+\])?`
View Source
var TimeRegexp = `(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [\-+]?\w+)` // %t or %m (or %s)
Every one of these regexps should produce exactly one matching group
View Source
var TransactionIdRegexp = `(\d+)` // %x
View Source
var UserRegexp = `(\S*)` // %u
View Source
var VirtualTxRegexp = `(\d+/\d+)?` // %v
Functions ¶
func AnalyzeBackendLogLines ¶
func AnalyzeLogLines ¶
func IsSupportedPrefix ¶
func ParseAndAnalyzeBuffer ¶
func ParseAndAnalyzeBuffer(logStream LineReader, linesNewerThan time.Time, server *state.Server) ([]state.LogLine, []state.PostgresQuerySample)
func ParseLogLineWithPrefix ¶
func PrintDebugInfo ¶
func PrintDebugInfo(logFileContents string, logLines []state.LogLine, samples []state.PostgresQuerySample)
func PrintDebugLogLines ¶ added in v0.49.0
func PrintDebugLogLines(logFileContents string, logLines []state.LogLine, classifications map[pganalyze_collector.LogLineInformation_LogClassification]bool)
func ReplaceSecrets ¶
func ReplaceSecrets(input []byte, logLines []state.LogLine, filterLogSecret []state.LogSecretKind) []byte
ReplaceSecrets - Replaces the secrets of the specified kind with the replacement character in the text
Types ¶
type LineReader ¶ added in v0.49.0
type MaybeHerokuLogReader ¶ added in v0.49.0
type MaybeHerokuLogReader struct {
LineReader
}
func NewMaybeHerokuLogReader ¶ added in v0.49.0
func NewMaybeHerokuLogReader(r io.Reader) *MaybeHerokuLogReader
func (*MaybeHerokuLogReader) ReadString ¶ added in v0.49.0
func (lr *MaybeHerokuLogReader) ReadString(delim byte) (string, error)
Click to show internal directories.
Click to hide internal directories.