Fluentd
Search…
file_single
The file_single buffer plugin provides a persistent buffer implementation. It uses files to store buffer chunks on disk.
file_single is similar to file_file but it does not have the metadata file.

Example Configuration

1
<match pattern>
2
@type forward
3
# forward parameters
4
<buffer>
5
@type file_single
6
path /var/log/fluent/out_fwd
7
</buffer>
8
</match>
Copied!

Parameters

path

type
required
default
version
string
1.7.0
The directory path where buffer chunks are stored. This parameter is required.
This parameter must be unique to avoid race condition problem between output plugins. Of course, this parameter must also be unique between fluentd instances.
The actual path consists of five (5) parts:
    path parameter
    fsb prefix
    tag or field value
    chunk id
    buf extension
1
# Example with <buffer tag> and tag is test.log
2
/path/to/buffer/fsb.test.log.b513b61c9791029c2513b61c9791029c2.buf
3
4
# Example with <buffer key> and record is {"key":"hello"}
5
/path/to/buffer/fsb.hello.b513b61c9791029c2513b61c9791029c2.buf
Copied!
Under multi-worker environment, worker_id and plugin id are added:
1
/path/to/buffer/worker1/out_fwd/fsb.test.log.b513b61c9791029c2513b61c9791029c2.buf
Copied!
Please make sure that you have enough space in the path directory. Running out of disk space is a problem frequently reported by users.

calc_num_records

type
required
default
version
bool
true
1.7.0
Calculate the number of records, chunk size, during chunk resume.
The buf_file_single plugin does not have the metadata file, so this plugin cannot keep the chunk size across fluentd restarts. If true, it calculates the chunk size by reading the file at startup.
If your plugin does not need the chunk size, you can set false to speedup the fluentd startup time.
This option is mainly for out_forward.

chunk_format

type
default
available values
version
enum
auto
msgpack/text/auto
1.7.0
Specifies the chunk format for calc_num_records.
With auto, the plugin decides the chunk format by formatted_to_msgpack_binary?. This option is useful when the output plugin does not implement formatted_to_msgpack_binary? correctly.

Limitation

chunk keys

buf_file_single does not have the metadata file, so buf_file_single cannot use rich metadata. The chunk keys must be the only tag or one field key for now.
1
<buffer> # OK. Same as <buffer tag>
2
<buffer tag> # OK
3
<buffer key> # OK
4
<buffer time> # NG. time is not supported
5
<buffer key1,key2> # NG. multiple field keys are not supported
Copied!
This limitation will be removed by adding the metadata header in the file.

Remote File System is Not Supported

Caution: file_single buffer implementation depends on the characteristics of the local file system. Don't use file_single buffer on remote file systems e.g. NFS, GlusterFS, HDFS and etc. We observed major data loss by using remote file system.
If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.
Last modified 4mo ago