Class: Fluent::HTTPOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::HTTPOutput
- Defined in:
- lib/fluent/plugin/out_http.rb,
lib/fluent/plugin/http/error.rb
Overview
The out_http buffered output plugin sends event records via HTTP.
Constant Summary collapse
- ResponseError =
Unsuccessful response error
Class.new(StandardError) do def self.error(request, response) new "Failed to POST event records to #{request.uri} because of " \ "unsuccessful response code: #{response.code.inspect} " \ "#{response.body.inspect}" end end
Instance Method Summary collapse
-
#configure(conf) ⇒ Object
Configures the plugin.
-
#format(tag, time, record) ⇒ String
Serializes the event.
-
#initialize ⇒ HTTPOutput
constructor
A new instance of HTTPOutput.
-
#shutdown ⇒ Object
Hook method that is called at the shutdown.
-
#start ⇒ Object
Hook method that is called at the startup.
-
#write(chunk) ⇒ Object
Sends the event records.
Constructor Details
#initialize ⇒ HTTPOutput
Returns a new instance of HTTPOutput.
22 23 24 25 26 |
# File 'lib/fluent/plugin/out_http.rb', line 22 def initialize require 'fluent/plugin/http/error' super end |
Instance Method Details
#configure(conf) ⇒ Object
Configures the plugin
32 33 34 35 36 37 38 |
# File 'lib/fluent/plugin/out_http.rb', line 32 def configure(conf) super @url = validate_url(url) @accept_status_code = validate_accept_status_code(accept_status_code) @authorization_token = () end |
#format(tag, time, record) ⇒ String
Serializes the event
65 66 67 |
# File 'lib/fluent/plugin/out_http.rb', line 65 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
Hook method that is called at the shutdown
53 54 55 56 57 |
# File 'lib/fluent/plugin/out_http.rb', line 53 def shutdown super http.finish end |
#start ⇒ Object
Hook method that is called at the startup
43 44 45 46 47 48 |
# File 'lib/fluent/plugin/out_http.rb', line 43 def start super is_https = url.scheme == 'https' @http = Net::HTTP.start(url.host, url.port, use_ssl: is_https) end |
#write(chunk) ⇒ Object
Sends the event records
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fluent/plugin/out_http.rb', line 74 def write(chunk) records = [] chunk.msgpack_each { |_tag, _time, record| records << record } post_records = post_records_request(records) response = http.request(post_records) return if accept_status_code.include?(response.code) raise ResponseError.error(post_records, response) end |