Class: LogStash::Inputs::Fifo
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Fifo
- Defined in:
- lib/logstash/inputs/fifo.rb
Overview
Read events from a single file or fifo (named pipe).
Unlike the ‘file’ input, this input reads the specified file or named pipe once from top to bottom then finish. This is suited for reading events out of a static file that does not grow over time, or reading from a named pipe into which events are written by a process.
If the ‘reopen_after_eof` option (default: false) is set to true, the named pipe will be re-opened and re-read upon reaching EOF. This may be required if events are written by a process that does not keep the descriptor open across writes.
Because setting ‘reopen_after_eof` to true is not useful for static files and can degrade system health, specifying anything other than a named pipe for `path` when `reopen_after_eof` is true is disallowed and will result in an error.
By default, each event is assumed to be one line. The multiline filter may be used to join consecutive lines
Constant Summary collapse
- READ_SIZE =
16384
Instance Method Summary collapse
- #register ⇒ Object
-
#run(queue) ⇒ Object
def register.
-
#stop ⇒ Object
def run.
Instance Method Details
#register ⇒ Object
49 50 51 52 53 |
# File 'lib/logstash/inputs/fifo.rb', line 49 def register @host = Socket.gethostname open_close_file fix_streaming_codecs end |
#run(queue) ⇒ Object
def register
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/logstash/inputs/fifo.rb', line 55 def run(queue) while !stop? begin data = @file.read(READ_SIZE) rescue => e # ignore exceptions during shutdown break if stop? raise end decode_events(data) do |event| decorate(event) event.set("host", @host) if !event.include?("host") queue << event end if not data if @reopen_after_eof open_close_file else do_stop end end end # loop end |
#stop ⇒ Object
def run
81 82 83 |
# File 'lib/logstash/inputs/fifo.rb', line 81 def stop open_close_file true end |