This is little app for collect logs from postgres csv logs to json. This is implement like pipeline-to-pipeline formatter. Logs ready for inject to graylog (via fluent, by example).
See images here:
mrecco/logrotate:v1.0.0
mrecco/pglog-collector:v1.1.0
mrecco/fluentd:v1.3.3
We must enable csvlog behavior and disable integrated rotation (because we use logrotate for this). All changes on postgresql.conf file.
- Add 'csvlog' to log_destination.
- Set logging_collector to on. This is required for logging to CSV format.
- Define log_directory and log_filename. You must know where you store logs. Set filename without any dynamic parameters.
- Set log_file_mode to 600.
- Set log_rotation_size and log_rotation_age to 0.
- Set log_truncate_on_rotation to off
See example.postgresql.conf: this contain compliant log-related parameters.
See volumes/logrotate/logrotate.conf.
You can use in without docker:
sudo -u postgres logrotate -f /path/to/postgresql-logrotate.conf
All configured and ready to send to graylog. See volumes/fluentd directory.
My code just convert ugly CSV format to JSON. JSON can be pushed to graylog by other applications and I satisfied how fluentd work for this.
Based on PostgreSQL Server. And this all for this!
https://www.postgresql.org/docs/11/runtime-config-logging.html
https://github.com/hpcloud/tail
Give me 0.1 BTC if you want me to never write code. Give me 1 BTC if you want me to believe in God. Give me 10 BTC - I will become a monk.
BTC: 32gLMtXkEsYK8nKbYTuhUMAAQxBTj7WUqr
Glad each Satoshi :)