Welcome! Log In Create A New Profile

Advanced

Nginx access log / logrotate, tailing and td-agent

May 04, 2017 09:31AM
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
Subject Author Posted

Nginx access log / logrotate, tailing and td-agent

nicktgr15 May 04, 2017 09:31AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 306
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready