Re-implementation of out_file plugin for Fluentd.
out_file
plugin is not thread-safe and process-safe. See http://d.hatena.ne.jp/sfujiwara/20121027/1351330488 (Japanese)out_file
plugin creates multiple separated buffer files on running multiple threads (and processes). Want to write into one file cuncurrently from multiple threads (and processes).- Because of 2,
symlink_path
option will be broken under multiple threads (or processes) - Complex (Do we really need the File Buffer before writing file? Both is file!)
The fundamental strategy to solve above problems is:
Specify path
with time format, and just append contents to the strftime filename from multiple threads (and processes). No buffer file is generated anymore.
This is the same strategy with strftime_logger, which is already running on my production environment.
For compression, create a thread for compression running in an interval implied by the time format in the path
(like 1 hour interval for %H) to compress a previously generated file.
The thread and process safety is achieved by a delicate implementation, just for compatibility with out_file, although I actually think running another cron job for compression is better approach.
See example.conf
Basically same with out_file plugin. You may see the doc of out_file.
-
path
The path of the file such as
foo.%Y%m%d%H.log
.The time format used as part of the file name. The following characters are replaced with actual values when the file is created:
- %Y: year including the century (at least 4 digits)
- %m: month of the year (01..12)
- %d: Day of the month (01..31)
- %H: Hour of the day, 24-hour clock (00..23)
- %M: Minute of the hour (00..59)
- %S: Second of the minute (00..60)
-
time_slice_format (obsolete)
This option is provided just for compatibility with
out_file
. Use time format inpath
parameter instead. -
format
The format of the file content. The default is
out_file
.Please refer out_file#format.
-
time_format
The format of the time written in files. The default format is ISO-8601.
-
utc
Uses UTC for path formatting. The default format is localtime.
-
compress
Compresses files using gzip. No compression is performed by default.
-
time_slice_wait (obsolete)
This option is provided just for compatibility with
out_file
. Usecompress_wait
instead. -
compress_wait
The amount of time Fluentd will wait for old logs to compress. This is used to account for delays in logs arriving to your Fluentd node. The default wait time is 10 minutes (‘10m’), where Fluentd will wait until 10 minutes past the hour for any logs that occured within the past hour.
For example, when splitting files on an hourly basis, a log recorded at 1:59 but arriving at the Fluentd node between 2:00 and 2:10 will be uploaded together with all the other logs from 1:00 to 1:59 in one transaction, avoiding extra overhead. Larger values can be set as needed.
-
symlink_path
Create symlink to the newest file created.. No symlink is created by default. This is useful for tailing file content to check logs.
Notable differences with out_file
:
- No buffer file is generated.
append true|false
option was removed. Alwaysappend true
.- Filename is expanded using the current time, rather than the time in a chunk.
See CHANGELOG.md for details.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright (c) 2014 Naotoshi Seo. See LICENSE for details.