Skip to content

Commit

Permalink
Log Insights: Use more specific log parsing regexp (#622)
Browse files Browse the repository at this point in the history
Our existing log parsing regular expressions may lead to ambiguity in
parsing log line prefixes for some log lines.

Ensure we only look for identifiers (role name, application_name, and
database name) up to the default identifier length limit (63 bytes) to
reduce ambiguities.
  • Loading branch information
msakrejda authored Oct 23, 2024
1 parent ccdd179 commit d487aca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions logs/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type PrefixEscape struct {
var EscapeMatchers = map[rune]PrefixEscape{
// Application name
'a': {
Regexp: `.+?`,
Regexp: `.{1,63}?`,
ApplyValue: func(value string, logLine *state.LogLine, parser *LogParser) {
if value == "[unknown]" {
return
Expand All @@ -69,7 +69,7 @@ var EscapeMatchers = map[rune]PrefixEscape{
},
// User name
'u': {
Regexp: `.+?`,
Regexp: `.{1,63}?`,
ApplyValue: func(value string, logLine *state.LogLine, parser *LogParser) {
if value == "[unknown]" {
return
Expand All @@ -80,7 +80,7 @@ var EscapeMatchers = map[rune]PrefixEscape{
},
// Database name
'd': {
Regexp: `.+?`,
Regexp: `.{1,63}?`,
ApplyValue: func(value string, logLine *state.LogLine, parser *LogParser) {
if value == "[unknown]" {
return
Expand Down

0 comments on commit d487aca

Please sign in to comment.