Skip to content
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

tail_files should persist initial offset as end of file #2788

Closed
andrewkroh opened this issue Oct 14, 2016 · 3 comments
Closed

tail_files should persist initial offset as end of file #2788

andrewkroh opened this issue Oct 14, 2016 · 3 comments
Labels
Filebeat Filebeat

Comments

@andrewkroh
Copy link
Member

At startup Filebeat initializes the registry with info about the file that it opens (but this does not contain an offset so it’s left as 0). This is the expected behavior for tail_files: false as we do not want to advance the offset until some data has been read. But for tail_files: true my personal expectation is that it would initially write the offset as the end of the file, instead of 0, so that if Filebeat exits it can resume reading from that point.

  • Version: 1.3.1
  • Operating System: affects all
  • Steps to Reproduce:
    • Delete .filebeat registry file.
    • Write multiple lines of text to out.log.
    • Start filebeat with tail_file: true.
    • Stop filebeat.
    • Read the .filebeat registry. It will have an offset of 0 because no events were written to the file while Filebeat was reading.

Config:

filebeat:
  prospectors:
    - paths:
        - out.log
      input_type: log
      tail_files: true
      close_older: 1s
@andrewkroh andrewkroh added the Filebeat Filebeat label Oct 14, 2016
@andrewkroh
Copy link
Member Author

// Launch the harvester
h.SetOffset(oldState.offset)
h.Start()
p.registrar.Persist <- h.GetState()

If the Havester.Start() wasn't asynchronous or it initialized the state prior to starting the havester goroutine, then this would work as expected because h.GetState() would return a fully initialized input.FileState containing the offset.

@ruflin
Copy link
Member

ruflin commented Oct 24, 2016

This should be solved together with #2613 by moving tail_files logic to the prospector.

Please note that in the 5.0 release the correct state is written as soon as the file is closed.

ruflin added a commit to ruflin/beats that referenced this issue Nov 3, 2016
tail_files is now only applied on the first run and after that ignored. Also the state for all files falling under tail_files and not having a state, a state will directly be written.

* Implement tail_files by setting ignore_older to 1ns for the first run
* Fix typo in stats variable names

Closes elastic#2613 and elastic#2788
urso pushed a commit that referenced this issue Nov 7, 2016
tail_files is now only applied on the first run and after that ignored. Also the state for all files falling under tail_files and not having a state, a state will directly be written.

* Implement tail_files by setting ignore_older to 1ns for the first run
* Fix typo in stats variable names

Closes #2613 and #2788
@ruflin
Copy link
Member

ruflin commented Nov 7, 2016

Closing as this was solved in #2932 and should be available in 5.1. As 5.0 is GA and filebeat 5.0 is backward compatible, I suggest we do not try to backport this.

@ruflin ruflin closed this as completed Nov 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Filebeat Filebeat
Projects
None yet
Development

No branches or pull requests

2 participants