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

fix(input.tail): Fix from_beginning option behavior #16240

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wen-templari
Copy link

Summary

Currently, after setting from_beginning to true, tail will start from the beginning of the file regardless of the previous persisted offset.

This PR makes setting from_beginning to true only start from the beginning of the file when there is no persisted offset.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #16237

@telegraf-tiger telegraf-tiger bot added area/tail fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Nov 28, 2024
@srebhan
Copy link
Member

srebhan commented Dec 2, 2024

@wen-templari we cannot do this as this will likely break someone else's use-case where they want to enforce the start of file even if a state is persisted. I suggest we introduce a new option replacing from_beginning e.g. called read_start which can take the options

  • end (default) - start reading from the end of the file
  • beginning - start reading from the beginning of the file ignoring any saved offset
  • saved offset or end - start reading from the persisted offset of the file or, if no offset persisted, start from the end
  • saved offset or beginning - start reading from the persisted offset of the file or, if no offset persisted, start from the beginning

What do you think?

@srebhan srebhan self-assigned this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tail fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[inputs.tail] Behaviour when from_beginning and statefile coexist is not as expected.
2 participants