Nginx access log / logrotate, tailing and td-agent
nicktgr15
nginx-forum at forum.nginx.org
Thu May 4 13:31:38 UTC 2017
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
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,274071,274071#msg-274071
More information about the nginx
mailing list