I am trying to parse the log file generated by my RDS instance using pgBadger
, so far with no results.
The log_line_prefix is set to %t:%r:%u@%d:[%p]:
A sample line in the log file looks like :
2019-09-24 17:19:25 UTC:172.31.10.173(53224):username@database:[12829]:LOG: execute <unnamed>: SELECT 1
I am using pgbadger with this command:
./pgbadger -p "%t:%r:%u@%d:[%p]:" postgresql.log.2019-09-24-17 -o pgbadger_rdsinstance.html
It throws the below error
Unmatched ( in regex; marked by <-- HERE in m/^(?:\d+-\d+-\d+T\d+:\d+:\d+\.\d+Z)?\s*(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)\s*[^:]*:( <-- HERE [^\(:]+\(\d+\):([^\@]+)\@([^:]+):\[(\d+)\]:(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})(?: [A-Z\+\-\d]{3,6})?:([a-zA-Z0-9\-\.]+|\[local\]|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[0-9a-fA-F:]+)?[\(\d\)]*:([0-9a-zA-Z\_\[\]\-\.]*)@([0-9a-zA-Z\_\[\]\-\.]*):\[(\d+)\]:(LOG|WARNING|ERROR|FATAL|PANIC|DETAIL|STATEMENT|HINT|CONTEXT|LOCATION):\s+(.*)/ at ./pgbadger line 2430.
Not sure what should be the correct pattern here. Looks like it isnt able to parse 172.31.10.173(53224)
.
I tried by escaping the parenthesis like : %t:%r\\(%a\\):%u@%d:[%p]:
, but that doesnt help.
I parsed a sample log file by removing this (53224)
part, and it works just fine.
What should be the correct pattern for this prefix?
If this is pgBadger 11.1 or newer, you can try using --format rds
and remove --prefix
. I guess this is a new bug that needs to be reported, but at least --format rds
worked for me.