Class: LogStash::Outputs::Pipe
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::Pipe
- Defined in:
- lib/logstash/outputs/pipe.rb
Overview
Pipe output.
Pipe events to stdin of another program. You can use fields from the event as parts of the command. WARNING: This feature can cause logstash to fork off multiple children if you are not carefull with per-event commandline.
Instance Method Summary collapse
-
#close ⇒ Object
def receive.
- #receive(event) ⇒ Object
- #register ⇒ Object
Instance Method Details
#close ⇒ Object
def receive
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/logstash/outputs/pipe.rb', line 57 def close @logger.info("close: closing pipes") @pipes.each do |command, pipe| begin drop_pipe(command) @logger.debug("Closed pipe #{command}", :pipe => pipe) rescue Exception => e @logger.error("Excpetion while closing pipes.", :exception => e) end end end |
#receive(event) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/logstash/outputs/pipe.rb', line 34 def receive(event) command = event.sprintf(@command) if @message_format output = event.sprintf(@message_format) + "\n" else output = event.to_json end begin pipe = get_pipe(command) pipe.puts(output) rescue IOError, Errno::EPIPE, Errno::EBADF => e @logger.error("Error writing to pipe, closing pipe.", :command => command, :pipe => pipe) drop_pipe(command) retry end close_stale_pipes end |
#register ⇒ Object
28 29 30 31 |
# File 'lib/logstash/outputs/pipe.rb', line 28 def register @pipes = {} @last_stale_cleanup_cycle = Time.now end |