Class: Fluent::SumologicOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::SumologicOutput
- Includes:
- SetTagKeyMixin, SetTimeKeyMixin
- Defined in:
- lib/fluent/plugin/out_sumologic.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ SumologicOutput
constructor
A new instance of SumologicOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ SumologicOutput
Returns a new instance of SumologicOutput.
21 22 23 |
# File 'lib/fluent/plugin/out_sumologic.rb', line 21 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
25 26 27 |
# File 'lib/fluent/plugin/out_sumologic.rb', line 25 def configure(conf) super end |
#format(tag, time, record) ⇒ Object
33 34 35 |
# File 'lib/fluent/plugin/out_sumologic.rb', line 33 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
37 38 39 |
# File 'lib/fluent/plugin/out_sumologic.rb', line 37 def shutdown super end |
#start ⇒ Object
29 30 31 |
# File 'lib/fluent/plugin/out_sumologic.rb', line 29 def start super end |
#write(chunk) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fluent/plugin/out_sumologic.rb', line 41 def write(chunk) = {} case @format when 'json' chunk.msgpack_each do |tag, time, record| if @include_tag_key record.merge!(@tag_key => tag) end if @include_time_key record.merge!(@time_key => @timef.format(time)) end source_name = record[@source_name_key] || '' record.delete(@source_name_key) [source_name] = [] unless [source_name] [source_name] << record.to_json end when 'text' chunk.msgpack_each do |tag, time, record| source_name = record[@source_name_key] || '' [source_name] = [] unless [source_name] [source_name] << record['message'] 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) http.use_ssl = true http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE # http.set_debug_output $stderr .each do |source_name, | request = Net::HTTP::Post.new(@path) request['X-Sumo-Name'] = source_name unless source_name.empty? request.body = .join("\n") response = http.request(request) unless response.is_a?(Net::HTTPSuccess) raise "Failed to send data to #{@host}. #{response.code} #{response.}" end end end |