PostgreSQL supports logging in json format. From my perspective json logs are badly readable, but allows machine processing, and with good tools, it is beautifully simple.
There are more tools for json processing - I use jq.
For simple analyze of errors in log, I can use sequence of commands:
For transformation to csv and viewing it in pspg:
cat postgresql-Sun.json | \
jq -r 'select(.error_severity=="ERROR") | [.timestamp, .user, .ps, .error_severity, .message ] | @csv' \
| pspg --csv
With these tools the work with log is "almost" effective and friendly (pspg supports sorting, searching, clipboard).
No comments:
Post a Comment