For other versions, see theVersioned plugin docs.
For questions about the plugin, open a topic in the Discuss forums. For bugs or feature requests, open an issue in Github.For the list of Elastic supported plugins, please consult the Elastic Support Matrix.
This output writes events to files on disk. You can use fieldsfrom the event as parts of the filename and/or path.
By default, this output writes one event per line in json format.You can customise the line format using the line
codec like
output { file { path => ... codec => line { format => "custom format: %{message}"} }}
This plugin supports the following configuration options plus the Common Options described later.
Setting | Input type | Required |
---|---|---|
No |
||
No |
||
No |
||
No |
||
No |
||
No |
||
Yes |
||
No |
Also see Common Options for a list of options supported by alloutput plugins.
true
If the configured file is deleted, but an event is handled by the plugin,the plugin will recreate the file. Default ⇒ true
-1
Dir access mode to use. Note that due to the bug in jruby system umaskis ignored on linux: https://github.com/jruby/jruby/issues/3426Setting it to -1 uses default OS value.Example: "dir_mode" => 0750
-1
File access mode to use. Note that due to the bug in jruby system umaskis ignored on linux: https://github.com/jruby/jruby/issues/3426Setting it to -1 uses default OS value.Example: "file_mode" => 0640
"_filepath_failures"
If the generated path is invalid, the events will be savedinto this file and inside the defined path.
2
Flush interval (in seconds) for flushing writes to log files.0 will flush on every message.
The path to the file to write. Event fields can be used here,like /var/log/logstash/%{host}/%{application}
One may also utilize the path option for date-based logrotation via the joda time format. This will use the eventtimestamp.E.g.: path => "./test-%{+YYYY-MM-dd}.txt"
to create./test-2013-05-29.txt
If you use an absolute path you cannot start with a dynamic string.E.g: /%{myfield}/
, /test-%{myfield}/
are not valid paths
append
If append
, the file will be opened for appending and each new event will be written at the end of the file.If overwrite
, the file will be truncated before writing and only the most recent event will appear in the file.
The following configuration options are supported by all output plugins:
"json_lines"
The codec used for output data. Output codecs are a convenient method for encoding your data before it leaves the output without needing a separate filter in your Logstash pipeline.
true
Disable or enable metric logging for this specific plugin instance.By default we record all the metrics we can, but you can disable metrics collectionfor a specific plugin.
Add a unique ID
to the plugin configuration. If no ID is specified, Logstash will generate one.It is strongly recommended to set this ID in your configuration. This is particularly usefulwhen you have two or more plugins of the same type. For example, if you have 2 file outputs.Adding a named ID in this case will help in monitoring Logstash when using the monitoring APIs.
output { file { id => "my_plugin_id" }}