Hi,
We are using td-agent to tail nginx logs and push them to s3 (every minute). We are rotating access logs every 10 minutes and we've noticed that when a log rotation happens log lines still go to the rotated log file for up to a minute after the rotation. Because of this we are losing some log lines when the rotation happens as td-agent follows the rotated log file for only 5 sec and then switches to the new one.
We checked the contents of the rotated gzs and during that first minute after the rotation not all log lines go to the rotated log file.. some go to the newly created access log (could be different workers?). Is this the expected behaviour? In our case we'll probably configure td-agent to tail the rotated log file for 60 seconds before switching to the new one but we are wondering if nginx behaves as expected.
The following postrotate script is used in logrotate config.
postrotate
[ ! -f /var/run/nginx.pid ] || /bin/kill -USR1 `cat /var/run/nginx.pid`
endscript
Regards,
Nik