Description
I have use logstash-input-file(4.1.4) to ingest from file. I found data loss during log rotation.
I have set my 3 files to rotate. And when the file over 1k the file rotate happen.
My configuration of log rotate:
{
missingok
size 1k
notifempty
sharedscripts
rotate 3
}
My script to generate log and rotate:
for (( i=1 ; i <= 100000; i++ ))
do
echo "$i this is a bunch of test data blah blah" >> /tmp/log/test
if ! ((i % 1000)); then
sleep 1
fi
if ! ((i % 30000 || i == 100000)); then
/usr/sbin/logrotate -f /etc/logrotate.d/test &
fi
done
My configuration of logstash:
input {
file {
path => "/tmp/log/test*"
}
}
output {
file {
path => "/tmp/output.txt"
codec => line { format => "custom format: %{message}" }
}
}
Data loss happened as below:
I found that creating new "log" file caused data loss. I have checked the source code and found that new "log" file lost some logs in the beginning. (create_initial.rb seek operation cause this issue).It means that logs that written to the "log" files during the file rotation will lost.
Please give me some advice on this issue.
Thanks,
Tsukiand