File
The file output plugin allows to write the data received through the input plugin to file.

Configuration Parameters

The plugin supports the following configuration parameters:
Key
Description
Default
Path
Directory path to store files. If not set, Fluent Bit will write the files on it's own positioned directory. note: this option was added on Fluent Bit v1.4.6
​
File
Set file name to store the records. If not set, the file name will be the tag associated with the records.
​
Format
The format of the file content. See also Format section. Default: out_file.
​
Mkdir
Recursively create output directory if it does not exist. Permissions set to 0755.
​
Workers
Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0.
1

Format

out_file format

Output time, tag and json records. There is no configuration parameters for out_file.
1
tag: [time, {"key1":"value1", "key2":"value2", "key3":"value3"}]
Copied!

plain format

Output the records as JSON (without additional tag and timestamp attributes). There is no configuration parameters for plain format.
1
{"key1":"value1", "key2":"value2", "key3":"value3"}
Copied!

csv format

Output the records as csv. Csv supports an additional configuration parameter.
Key
Description
Delimiter
The character to separate each data. Default: ','
1
time[delimiter]"value1"[delimiter]"value2"[delimiter]"value3"
Copied!

ltsv format

Output the records as LTSV. LTSV supports an additional configuration parameter.
Key
Description
Delimiter
The character to separate each pair. Default: '\t'(TAB)
Label_Delimiter
The character to separate label and the value. Default: ':'
1
field1[label_delimiter]value1[delimiter]field2[label_delimiter]value2
Copied!

template format

Output the records using a custom format template.
Key
Description
Template
The format string. Default: '{time} {message}'
This accepts a formatting template and fills placeholders using corresponding values in a record.
For example, if you set up the configuration as below:
1
[INPUT]
2
Name mem
3
​
4
[OUTPUT]
5
Name file
6
Format template
7
Template {time} used={Mem.used} free={Mem.free} total={Mem.total}
Copied!
You will get the following output:
1
1564462620.000254 used=1045448 free=31760160 total=32805608
Copied!

Getting Started

You can run the plugin from the command line or through the configuration file:

Command Line

From the command line you can let Fluent Bit count up a data with the following options:
1
$ fluent-bit -i cpu -o file -p path=output.txt
Copied!

Configuration File

In your main configuration file append the following Input & Output sections:
1
[INPUT]
2
Name cpu
3
Tag cpu
4
​
5
[OUTPUT]
6
Name file
7
Match *
8
Path output_dir
Copied!