how to use sincedb in logstash?
This is apparently caused by a bug in the File handler.
When File{} input method reads a log file, the last byte processed is being saved and periodically copied out to the sincedb
file. While you can set the file to be /dev/null
if you want, Logstash reads the file only during start up and uses the information from table in memory after.
The problem is that the table in memory indexes position by inode, and is never pruned, even if it detects that a given file no longer exists. If you delete a file and then add a new one -- even if it has a different name -- it may well have the same inode number, and the File handler will think it is the same file.
If the new file is larger, then the handler will only read from the previous max byte onwards and update the table. If the new file is smaller, then it seems to think the file was somehow truncated, and may start processing again from the default position.
As a result, the only way to handle things is to set sincedb
to be /dev/null
, and then restart logstash (causing the internal table to be lost) and then all the files matching the pattern will be re-read from the beginning - and this has problems as well, since some of the files may not be new.