Class: LogStash::Inputs::Stdin

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/stdin.rb

Overview

Read events from standard input.

By default, each event is assumed to be one line. If you want to join lines, you’ll want to use the multiline codec.

Constant Summary collapse

READ_SIZE =
16384

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*params) ⇒ Stdin

Returns a new instance of Stdin.



27
28
29
30
31
32
# File 'lib/logstash/inputs/stdin.rb', line 27

def initialize(*params)
  super

  @host_key = ecs_select[disabled: 'host', v1: '[host][hostname]']
  @event_original_key = ecs_select[disabled: nil, v1: '[event][original]']
end

Class Method Details

.reloadable?Boolean

When a configuration is using this plugin We are defining a blocking pipeline which cannot be reloaded

Returns:

  • (Boolean)


23
24
25
# File 'lib/logstash/inputs/stdin.rb', line 23

def self.reloadable?
  false
end

Instance Method Details

#registerObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/logstash/inputs/stdin.rb', line 34

def register
  begin
    @stdin = StdinChannel::Reader.new
    self.class.module_exec { alias_method :stdin_read, :channel_read }
    self.class.module_exec { alias_method :stop, :channel_stop}
  rescue => e
    @logger.debug("fallback to reading from regular $stdin", :exception => e)
    self.class.module_exec { alias_method :stdin_read, :default_read }
    self.class.module_exec { alias_method :stop, :default_stop }
  end

  @host = Socket.gethostname
  fix_streaming_codecs
end

#run(queue) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/logstash/inputs/stdin.rb', line 49

def run(queue)
  puts "The stdin plugin is now waiting for input:" if $stdin.tty?
  while !stop?
    if data = stdin_read
      process(data, queue)
    end
  end
end