Class: Fluent::Plugin::HttpPullInput
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::HttpPullInput
- Defined in:
- lib/fluent/plugin/in_http_pull.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ HttpPullInput
constructor
A new instance of HttpPullInput.
- #on_timer ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ HttpPullInput
Returns a new instance of HttpPullInput.
25 26 27 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 25 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 69 def configure(conf) compat_parameters_convert(conf, :parser) super @parser = parser_create unless @status_only @_request_headers = @request_headers.map do |section| header = section["header"] value = section["value"] [header.to_sym, value] end.to_h @http_method = :head if @status_only end |
#on_timer ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 90 def on_timer record = { "url" => @url } begin = { method: @http_method, url: @url, timeout: @timeout } [:proxy] = @proxy if @proxy [:user] = @user if @user [:password] = @password if @password [:headers] = @_request_headers unless @request_headers.empty? res = RestClient::Request.execute record["status"] = res.code record["body"] = res.body record["header"] = {} unless @response_headers.empty? @response_headers.each do |section| name = section["header"] symbolize_name = name.downcase.gsub(/-/, '_').to_sym record["header"][name] = res.headers[symbolize_name] end rescue StandardError => err if err.respond_to? :http_code record["status"] = err.http_code || 0 else record["status"] = 0 end record["error"] = err. end record_time = Engine.now if !@status_only && record["body"] != nil @parser.parse(record["body"]) do |time, | record["message"] = record_time = time end end record.delete("body") router.emit(@tag, record_time, record) end |
#shutdown ⇒ Object
136 137 138 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 136 def shutdown super end |
#start ⇒ Object
84 85 86 87 88 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 84 def start super timer_execute(:in_http_pull, @interval, &method(:on_timer)) end |