-
Notifications
You must be signed in to change notification settings - Fork 100
Lost data on rotation #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Any news/progress on this one? |
This is likely due to the fact that Logstash will only look for new files when it reaches the end of the current file. In this scenario, the script is writing 100,000 records before rotation. On my machine, this is taking roughly 11 seconds to between each logrotation (there's a sleep in your script every 10,000, so this makes sense) This means Logstash needs to process 10,000 lines per second at least in order to keep up. If it cannot keep up, the new file checks will stall. When I tested this, I noticed that Logstash would miss one of the rotations probably because it was running behind. Testing the script to demonstrate this. Logstash had log.level:debug, and I see this:
Only two new rotations were observed in the above run. inodes for the logs:
The first entry in our log was this:
This "old" is test.log.4, and the "new" is test.log.2. You can see test.log.3 was missed here. The second entry:
The old here is test.log.2, and the new is test.log. test.log.1 was missed. If we ask Logstash about how fast it's going using the stats api, we can see it processing (at least on my laptop here, the test environment) slower than the logs are being emitted into the log file by
The above numbers are roughly events-per-second. In the We can try to improve the implementation problem (file discovery happens after file reads), but ultimately, Logstash is processing slower than you are producing events. Even if we make the file discovery handled outside of the main file input thread, Logstash is still consuming slower than you are processing, which means that your logrotation will not really be saving you space, because while you might logrotate to delete I would note that Logstash should be able to read files faster than this, but ultimately we cannot, in software, behave well in a scenario where: Logstash is consuming at a lower rate than the data is being produced, and the data being produced is being deleted quickly -- there will always be data loss in these scenarios or undesirable behavior (deleted files still occupying disk space because Logstash has them open with the intent to read them fully) |
@LionelCons I need more details if you want a good answer. I don't know what progress you are asking about. If you believe you are encountering this issue, providing details on what you observe and also your configuration(s) would be wonderful in helping identify if your issue is the same as the one reported in this ticket. |
Filebeat probably doesn't lose data here because it has file discovery ("prospecting") executing separately (in a coroutine or thread) from file reading ("harvesting"). This allows it (as I say in my comment above) to find new files during processing of existing known files. It would still have the problem I described that a prospected-but-not-harvested file will still occupy disk space after logrotate has deleted it -- until filebeat finishes reading it and closes the file as idle. |
It seems that my problem (incomplete lines read from Kafka logs) most likely comes inodes being re-used. This seems to be a known issue: jordansissel/ruby-filewatch#79. @jordansissel: Could you comment on this PR from your |
/etc/logrotate.d/test
:script.sh
to generate some data & rotate ittouch /var/log/test
Start Logstash with the following config.
Once logstash is started - start
script.sh
, and wait for it to finishcompare size of logs with ingested data:
*** note that Filebeat tested without data loss ***
The text was updated successfully, but these errors were encountered: