lib/logstash/inputs/elasticsearch.rb in logstash-input-elasticsearch-4.0.1 vs lib/logstash/inputs/elasticsearch.rb in logstash-input-elasticsearch-4.0.2

- old
+ new

@@ -1,10 +1,8 @@ # encoding: utf-8 require "logstash/inputs/base" require "logstash/namespace" -require 'elasticsearch' -require 'elasticsearch/transport/transport/http/manticore' require "base64" # Read from an Elasticsearch cluster, based on search query results. # This is useful for replaying test logs, reindexing, etc. # @@ -105,24 +103,24 @@ # SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary config :ca_file, :validate => :path def register + require "elasticsearch" + @options = { :index => @index, :body => @query, :scroll => @scroll, :size => @size } transport_options = {} if @user && @password - transport_options[:auth] = { - :user => @user, - :password => @password.value - } + token = Base64.strict_encode64("#{@user}:#{@password.value}") + transport_options[:headers] = { :Authorization => "Basic #{token}" } end hosts = if @ssl then @hosts.map do |h| host, port = h.split(":") @@ -130,20 +128,14 @@ end else @hosts end - client_options = { - :hosts => hosts, - :transport_options => transport_options, - :transport_class => Elasticsearch::Transport::Transport::HTTP::Manticore - } - if @ssl && @ca_file - client_options[:ssl] = { :enabled => true, :ca_file => @ca_file } + transport_options[:ssl] = { :ca_file => @ca_file } end - - @client = Elasticsearch::Client.new(client_options) + + @client = Elasticsearch::Client.new(:hosts => hosts, :transport_options => transport_options) end def run(output_queue) # get first wave of data r = @client.search(@options)