logstash-input-httpclient 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfffe002abaff65c15fae28f60bdb26c96a49296
4
- data.tar.gz: a0ccb1d87c692aa0a408d1565000a7f758fc28d6
3
+ metadata.gz: 34f259c605e9064ef201bcf35e71b9aa20b82dc8
4
+ data.tar.gz: b9d6f9eab9ad654bc368dbd708f7f7ad7193cf01
5
5
  SHA512:
6
- metadata.gz: a2d781b3211acb8ccf50e73c1fa8d64fc3edcd8e15d176df3f1787c5596277a3e8cdad396cafb82129858715742709b623284191f670475ca596ca779290bf6e
7
- data.tar.gz: 41cf27bfe287f24232626b2ee3d82a3a63f53adb5d0dcba29ea836b1e87a4a3254ecbfa978ba60d5f52b13f9df386a652aa330ca9d526be949efac2ef9c3adaf
6
+ metadata.gz: f58d38b040dda5c5bd5fbdbeb91b8438ac2c1962c1164f49b7d18c822cff00c76bf5822250b3ab55822db38f9005aefd8ecc5e60344d06fe1b6100c78d7b7525
7
+ data.tar.gz: 69193c447b6aa56d3cfc7c03a1c829c46d76f0e6197f2e1a3fce12d46e0e820694fb999619896bcbd0a96b6cbdf7e81acbaa37d8f89b0789dadadbf682ce1b97
@@ -62,37 +62,46 @@ class LogStash::Inputs::HttpClient < LogStash::Inputs::Base
62
62
  queue_times = Array.new #track an average of how long it's taking to queue events into logstash
63
63
  #::start creates a connection to the HTTP server and keeps it alive for the duration
64
64
  Net::HTTP.start @uri.host, @uri.port, :use_ssl => @uri.scheme == 'https' do |http|
65
- Stud.interval(@interval) do
65
+ while true
66
66
  begin
67
- http_start = Time.now
68
- request = Net::HTTP::Get.new(@uri.path)
69
- request ["X-Logstash-Avg-Queue-Secs"] = arr_avg(queue_times, 20, 3)
70
- response = http.request request # Net::HTTPResponse object
71
- http_elapsed = Time.now - http_start
72
- rescue => e
73
- @logger.warn("Http request failed, will retry", :exception => e)
74
- @logger.warn(e.backtrace)
75
- sleep(@interval)
76
- retry
77
- end
78
- #event = LogStash::Event.new("message" => response.body)
79
- @codec.decode(response.body) do |event|
80
- event[@response_object_name] = {}
81
- if @include_response_headers
82
- event[@response_object_name]["headers"] = response
67
+ sleepIval = @interval
68
+ begin
69
+ http_start = Time.now
70
+ request = Net::HTTP::Get.new(@uri.request_uri)
71
+ request ["X-Logstash-Avg-Queue-Secs"] = arr_avg(queue_times, 20, 3)
72
+ response = http.request request # Net::HTTPResponse object
73
+ http_elapsed = Time.now - http_start
74
+ rescue => e
75
+ @logger.warn("Http request failed, will retry", :exception => e)
76
+ @logger.warn(e.backtrace)
77
+ sleep(sleepIval)
78
+ retry
83
79
  end
84
- if @include_response_code
85
- event[@response_object_name]["code"] = response.code
80
+
81
+ if response["X-More-Events-Available"] == "true"
82
+ sleepIval = 0 #don't wait if the server indicated there are more events ready now
86
83
  end
87
- if @include_http_request_time
88
- event[@response_object_name]["took_secs"] = http_elapsed
84
+
85
+ @codec.decode(response.body) do |event|
86
+ event[@response_object_name] = {}
87
+ if @include_response_headers
88
+ event[@response_object_name]["headers"] = response
89
+ end
90
+ if @include_response_code
91
+ event[@response_object_name]["code"] = response.code
92
+ end
93
+ if @include_http_request_time
94
+ event[@response_object_name]["took_secs"] = http_elapsed
95
+ end
96
+ decorate(event)
97
+ queue_start = Time.now
98
+ queue << event
99
+ queue_elapsed = Time.now - queue_start
100
+ queue_times.push queue_elapsed
89
101
  end
90
- decorate(event)
91
- queue_start = Time.now
92
- queue << event
93
- queue_elapsed = Time.now - http_start
94
- queue_times.push queue_elapsed
95
- end
102
+ ensure
103
+ sleep(@interval)
104
+ end
96
105
  end #interval loop
97
106
  end #HTTP keepalive
98
107
  end # def run
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-httpclient'
3
- s.version = '0.1.0'
3
+ s.version = '0.2.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "This input queries a http url at a regular interval and sends the responses to logstash."
6
6
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-httpclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bradvido
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core