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 +4 -4
- data/lib/logstash/inputs/httpclient.rb +36 -27
- data/logstash-input-httpclient.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34f259c605e9064ef201bcf35e71b9aa20b82dc8
|
4
|
+
data.tar.gz: b9d6f9eab9ad654bc368dbd708f7f7ad7193cf01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
65
|
+
while true
|
66
66
|
begin
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
85
|
-
|
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
|
-
|
88
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
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.
|
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.
|
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-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|