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

Merge in_tail_ex features into in_tail. refs #269 #277

Merged
merged 12 commits into from
Mar 28, 2014
Merged

Conversation

repeatedly
Copy link
Member

Last step of #269 , merge in_tail_ex into in_tail.
The different from original in_tail_ex is below:

  • refresh_interval is 60 by default. The user should set refresh_interval XXs for watching new files
  • expand_date is always true
  • read_from_head is false by default. So you should set true when emulates original in_tail_ex.

This pull request changes in_tail internal, so I need some testers.

UPDATED (Mar/28/2014)

refresh_interval changed from nil to 60 seconds.

end

config_param :path, :string
config_param :tag, :string
config_param :rotate_wait, :time, :default => 5
config_param :pos_file, :string, :default => nil
config_param :read_from_head, :bool, :default => false
config_param :refresh_interval, :time, :default => nil
Copy link
Member

Choose a reason for hiding this comment

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

I think @refresh_interval can have default value (like 30 seconds).
Because anyways watches will be refreshed when fluentd restarts. There're no ways to not refresh watches.

Copy link
Member Author

Choose a reason for hiding this comment

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

 Because anyways watches will be refreshed when fluentd restarts. There're no ways to not refresh watches.

Could you tell me this situation deeply?
If the user sets /path/to/file, refresh feature is not needed.
So I set nil by default. in_tail refreshes watchers at only start method.

Copy link
Member

Choose a reason for hiding this comment

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

  • If path includes time patterns (like %H)
    • All users must set refresh_interval, right?
    • Then it's good idea to give default value
  • If path doesn't include time patterns
    • expand_paths always return consistent result.
    • it's ok to have refresh_interval because it does nothing

Copy link
Member Author

Choose a reason for hiding this comment

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

in_tail_ex's default is 3600.
I don't know which value is best.

I will check performance with shorter value.

@frsyuki
Copy link
Member

frsyuki commented Mar 24, 2014

@repeatedly Sorry for being late to review this big change.
I think overall implementation is good, as long as we can notice all users that path pattern must not include rotated files to not cause duplicated records.

@repeatedly repeatedly mentioned this pull request Mar 27, 2014
@@ -288,38 +350,55 @@ def on_rotate(io)
end
io.seek(pos)

@io_handler = IOHandler.new(io, @pe, log, &method(:wrap_receive_lines))
@io_handler = IOHandler.new(io, @pe, @log, &method(:wrap_receive_lines))
Copy link
Member

Choose a reason for hiding this comment

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

Can here avoid recreating IOHandler? Like: @io_handler.pe = mpe.

Copy link
Member

Choose a reason for hiding this comment

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

I think here should not recreate IOHandler because @buffer will be lost if we recreate IOHandler.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Will fix soon.

@frsyuki
Copy link
Member

frsyuki commented Mar 28, 2014

If we repeat refresh_interval, pos_file size increases for ever. Usually it doesn't matter because pos_file is small. However, it's better to have a cleanup code. For example, we can set 0xffffffff to pos on stop_watchers, and remove those lines on start.

@frsyuki
Copy link
Member

frsyuki commented Mar 28, 2014

The other code looks good to me 👍

@repeatedly
Copy link
Member Author

@frsyuki I added cleaup code for PositionFile. Could you check it again?

@frsyuki
Copy link
Member

frsyuki commented Mar 28, 2014

I reviewed. The others look good!

@repeatedly
Copy link
Member Author

I will merge this pull request in half an hour later.

repeatedly added a commit that referenced this pull request Mar 28, 2014
Merge in_tail_ex features into in_tail. refs #269
@repeatedly repeatedly merged commit f255bf1 into master Mar 28, 2014
@repeatedly repeatedly deleted the merge-tail_ex branch March 28, 2014 08:18
@wsorenson
Copy link

@repeatedly @frsyuki I am curious, what is the reason for this limitation: "as long as we can notice all users that path pattern must not include rotated files to not cause duplicated records."

Is there any way around this? I was hoping to watch stdout files which are being rotated.

@repeatedly
Copy link
Member Author

@wsorenson Because in_tail can't track file rotation correctly with * glob pattern.
We use inode for file tracking but some rotation tools change the inode with file compression or something.
in_tail doesn't know the rotation tool implementation, so including rotation file in * causes the log duplication.

Is there any way around this? I was hoping to watch stdout files which are being rotated.

Simple way is separating log path. For example:

<source>
  type tail
  path /path/to/rotation/file,/path/to/rotation/never-macth-unique-prefix-*,/path/to/dynamic/*,
</source>

@wsorenson
Copy link

@repeatedly what about the case where the files are simply rotated with copytruncate?

I assume it handles this by noticing the underlying file size has gone down?

@repeatedly
Copy link
Member Author

@wsorenson Yes. in_tail checks inode change or file size reduction.
The code is here: https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/in_tail.rb#L540

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request *Deprecated Label* Use enhancement label in general
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants