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

Switch to poll mode to detect file changes in logparser #2858

Closed
wants to merge 1 commit into from

Conversation

ytian
Copy link

@ytian ytian commented May 26, 2017

tail doesn't work in macos(default use inotify, but it doesn't work in macos). set poll to true works.

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

tail doesn't work in macos(default use inotify, but it doesn't work in macos). set poll to true works.
@@ -82,7 +82,8 @@ func (l *LogParserPlugin) Gather(acc telegraf.Accumulator) error {
defer l.Unlock()

// always start from the beginning of files that appear while we're running
return l.tailNewfiles(true)
// why need to set true? It's ok to set l.FromBeginning.
return l.tailNewfiles(l.FromBeginning)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this parameter is false, we seek to the end of the file before reading. To ensure the entire file is read we need to leave this as true.

@@ -159,6 +160,7 @@ func (l *LogParserPlugin) tailNewfiles(fromBeginning bool) error {
Follow: true,
Location: &seek,
MustExist: true,
Poll: true, //inotify(default) not work in macos(darwin). poll test ok.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we could do here is allow this to be configurable. We can add an option to the plugin called watch_method with available options "poll" and "inotify". If unset, we could automatically pick an implementation.

@danielnelson danielnelson changed the title Update logparser.go Switch to poll mode to detect file changes in logparser Jun 26, 2017
@danielnelson danielnelson modified the milestone: 1.5.0 Aug 24, 2017
@danielnelson
Copy link
Contributor

Closing in favor of #3213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants