lib/logstash/inputs/elasticsearch.rb in logstash-input-elasticsearch-4.5.0 vs lib/logstash/inputs/elasticsearch.rb in logstash-input-elasticsearch-4.6.0

- old
+ new

@@ -143,10 +143,13 @@ # Cloud authentication string ("<username>:<password>" format) is an alternative for the `user`/`password` configuration. # # For more info, check out the https://www.elastic.co/guide/en/logstash/current/connecting-to-cloud.html#_cloud_auth[Logstash-to-Cloud documentation] config :cloud_auth, :validate => :password + # Set the address of a forward HTTP proxy. + config :proxy, :validate => :uri_or_empty + # SSL config :ssl, :validate => :boolean, :default => false # SSL Certificate Authority file in PEM encoded format, must also include any chain certificates as necessary config :ca_file, :validate => :path @@ -195,14 +198,34 @@ @hosts end ssl_options = { :ssl => true, :ca_file => @ca_file } if @ssl && @ca_file ssl_options ||= {} + @logger.warn "Supplied proxy setting (proxy => '') has no effect" if @proxy.eql?('') + + transport_options[:proxy] = @proxy.to_s if @proxy && !@proxy.eql?('') + @client = Elasticsearch::Client.new(:hosts => hosts, :transport_options => transport_options, :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore, :ssl => ssl_options) end + ## + # @override to handle proxy => '' as if none was set + # @param value [Array<Object>] + # @param validator [nil,Array,Symbol] + # @return [Array(true,Object)]: if validation is a success, a tuple containing `true` and the coerced value + # @return [Array(false,String)]: if validation is a failure, a tuple containing `false` and the failure reason. + def self.validate_value(value, validator) + return super unless validator == :uri_or_empty + + value = deep_replace(value) + value = hash_or_array(value) + + return true, value.first if value.size == 1 && value.first.empty? + + return super(value, :uri) + end def run(output_queue) if @schedule @scheduler = Rufus::Scheduler.new(:max_work_threads => 1) @scheduler.cron @schedule do