Class: LogStash::Inputs::Beats

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/beats/tls.rb,
lib/logstash/inputs/beats/message_listener.rb,
lib/logstash/inputs/beats/raw_event_transform.rb,
lib/logstash/inputs/beats/event_transform_common.rb,
lib/logstash/inputs/beats/codec_callback_listener.rb,
lib/logstash/inputs/beats/decoded_event_transform.rb,
lib/logstash/inputs/beats.rb

Defined Under Namespace

Classes: CodecCallbackListener, DecodedEventTransform, EventTransformCommon, MessageListener, RawEventTransform, TLS

Instance Method Summary collapse

Instance Method Details

#client_authentification?Boolean

Returns:

  • (Boolean)


213
214
215
# File 'lib/logstash/inputs/beats.rb', line 213

def client_authentification?
  @ssl_certificate_authorities && @ssl_certificate_authorities.size > 0
end

#convert_protocolsObject



221
222
223
# File 'lib/logstash/inputs/beats.rb', line 221

def convert_protocols
  TLS.get_supported(@tls_min_version..@tls_max_version).map(&:name)
end

#create_serverObject

def register



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/logstash/inputs/beats.rb', line 169

def create_server
  server = org.logstash.beats.Server.new(@host, @port)
  if @ssl
    ssl_builder = org.logstash.netty.SslSimpleBuilder.new(@ssl_certificate, @ssl_key, @ssl_key_passphrase.nil? ? nil : @ssl_key_passphrase.value)
      .setProtocols(convert_protocols)
      .setCipherSuites(normalized_ciphers)

    ssl_builder.setHandshakeTimeoutMilliseconds(@ssl_handshake_timeout)

    if client_authentification?
      if @ssl_verify_mode.upcase == "FORCE_PEER"
          ssl_builder.setVerifyMode(org.logstash.netty.SslSimpleBuilder::SslClientVerifyMode::FORCE_PEER)
      end
      ssl_builder.setCertificateAuthorities(@ssl_certificate_authorities)
    end

    server.enableSSL(ssl_builder)
  end

  server
end

#need_identity_map?Boolean

Returns:

  • (Boolean)


209
210
211
# File 'lib/logstash/inputs/beats.rb', line 209

def need_identity_map?
  @codec.kind_of?(LogStash::Codecs::Multiline)
end

#normalized_ciphersObject



217
218
219
# File 'lib/logstash/inputs/beats.rb', line 217

def normalized_ciphers
  @cipher_suites.map(&:upcase)
end

#registerObject



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/logstash/inputs/beats.rb', line 142

def register
  # Logstash 2.4
  if defined?(LogStash::Logger) && LogStash::Logger.respond_to?(:setup_log4j)
    LogStash::Logger.setup_log4j(@logger)
  end

  if !@ssl
    @logger.warn("Beats input: SSL Certificate will not be used") unless @ssl_certificate.nil?
    @logger.warn("Beats input: SSL Key will not be used") unless @ssl_key.nil?
  elsif !ssl_configured?
    raise LogStash::ConfigurationError, "Certificate or Certificate Key not configured"
  end

  @logger.info("Beats inputs: Starting input listener", :address => "#{@host}:#{@port}")

  # wrap the configured codec to support identity stream
  # from the producers if running with the multiline codec.
  #
  # If they dont need an identity map, codec are stateless and can be reused
  # accross multiples connections.
  if need_identity_map?
    @codec = LogStash::Codecs::IdentityMapCodec.new(@codec)
  end

  @server = create_server
end

#run(output_queue) ⇒ Object



199
200
201
202
203
# File 'lib/logstash/inputs/beats.rb', line 199

def run(output_queue)
  message_listener = MessageListener.new(output_queue, self)
  @server.setMessageListener(message_listener)
  @server.listen
end

#ssl_configured?Boolean

Returns:

  • (Boolean)


191
192
193
# File 'lib/logstash/inputs/beats.rb', line 191

def ssl_configured?
  !(@ssl_certificate.nil? || @ssl_key.nil?)
end

#stopObject

def run



205
206
207
# File 'lib/logstash/inputs/beats.rb', line 205

def stop
  @server.stop
end

#target_codec_on_field?Boolean

Returns:

  • (Boolean)


195
196
197
# File 'lib/logstash/inputs/beats.rb', line 195

def target_codec_on_field?
  !@target_codec_on_field.empty?
end