diff --git a/README.md b/README.md index 45121b6..09bbf43 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Or install it yourself as: type sumologic host collectors.sumologic.com port 443 + proxy 10.0.0.1:3128 format json|text path /receiver/v1/http/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX== @@ -43,6 +44,9 @@ Or install it yourself as: #### port - Port of HTTP Collectors URL +#### proxy +- HTTP proxy address including port + #### path - Path of HTTP Collectors URL diff --git a/lib/fluent/plugin/out_sumologic.rb b/lib/fluent/plugin/out_sumologic.rb index 7c2858a..c070424 100644 --- a/lib/fluent/plugin/out_sumologic.rb +++ b/lib/fluent/plugin/out_sumologic.rb @@ -7,6 +7,7 @@ class Fluent::SumologicOutput< Fluent::BufferedOutput config_param :host, :string, :default => 'collectors.sumologic.com' config_param :port, :integer, :default => 443 + config_param :proxy, :string, :default => nil config_param :verify_ssl, :bool, :default => true config_param :path, :string, :default => '/receiver/v1/http/XXX' config_param :format, :string, :default => 'json' @@ -63,8 +64,12 @@ def write(chunk) end end - (proxy,proxy_port) = ENV['http_proxy'].split(':') - http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i) + http = Net::HTTP.new(@host, @port.to_i) + proxy_string = if ENV['http_proxy'] then ENV['http_proxy'] else @proxy end + if(proxy_string){ + (proxy,proxy_port) = proxy_string.split(':') + http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i) + } http.use_ssl = true http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE http.set_debug_output $stderr