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.
26 27 28 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 26 def initialize super end |
Instance Method Details
#configure(conf) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 61 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 end |
#on_timer ⇒ Object
80 81 82 83 84 85 86 87 88 89 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 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 80 def on_timer record = { "url" => @url } begin = { method: :get, 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
126 127 128 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 126 def shutdown super end |
#start ⇒ Object
74 75 76 77 78 |
# File 'lib/fluent/plugin/in_http_pull.rb', line 74 def start super timer_execute(:in_http_pull, @interval, &method(:on_timer)) end |