logstash-input-http_poller 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27ad585ea744dd3feb40d3acfe744dabbfb5a122
4
- data.tar.gz: 74ecba4a7d356cf7386c62469d6c16091f34f794
3
+ metadata.gz: 265b825999ea3786b93cc2c6ceff4c2a50800fcd
4
+ data.tar.gz: 56bb9dc953d316e0d6023e39a6653062fb6ccb23
5
5
  SHA512:
6
- metadata.gz: 664d8bf1546d7b866c623b14d6a7dfeb799becb06e223a51510aed06cc2d2c3e3a0ca6c1e512e14e74dc96799624a34b83f1ab643d02a7ce1112b162866be04d
7
- data.tar.gz: fd6716eaa478426b08494312a7e2939537d652780fa6455f58ef1bac3f01547f01a380d425fea9b7867535cd58277ff120f0f17e0775e4f11e6a0b664e10420f
6
+ metadata.gz: d97e0bcafd842865eaa04d9d64e18c6d90414daa8213f620797406023965a58b19e652910cb2cc1e3000440b3f4ef6769f7f892cdb307bbc0c2a9de68ce6f968
7
+ data.tar.gz: 7ba774a15dafbb3f193989c7f11fefac339b99b763eeff997e616cf32ffda7224a2d3821a2c5d13375a3ff2b0b25713c1a298e115fbaef00adc5295db98e168b
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ * 1.0.1
2
+ - Add 'target' option
3
+
1
4
  * 1.0.0
2
5
  - Initial release
@@ -22,7 +22,7 @@ filter {
22
22
  }
23
23
 
24
24
  csv {
25
- columns => [ pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime ]
25
+ columns => [ pxname,svname,qcur,qmax,scur,smax,slim,stot,binhttp://localhost:9201/haproxy?stats;csvm,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime ]
26
26
  }
27
27
 
28
28
  # This is a pointless CSV header
@@ -35,4 +35,9 @@ output {
35
35
  stdout {
36
36
  codec => rubydebug
37
37
  }
38
+
39
+ elasticsearch {
40
+ protocol => "http"
41
+ cluster => "avc-cluster"
42
+ }
38
43
  }
@@ -1,28 +1,10 @@
1
1
  input {
2
- http_poller {
3
- urls => {
4
- test1 => "http://localhost:9200"
5
- test2 => {
6
- # Supports all options supported by ruby's Manticore HTTP client
7
- method => get
8
- url => "http://localhost:9200/_cluster/health"
9
- headers => {
10
- Accept => "application/json"
11
- }
12
- auth => {
13
- user => "AzureDiamond"
14
- pass => "hunter2"
15
- }
16
- }
17
- }
18
- request_timeout => 60
19
- interval => 60
20
- codec => "json"
21
- # A hash of request metadata info (timing, response headers, etc.) will be sent here
22
- metadata_target => "_http_poller_metadata"
23
- }
2
+ stdin {}
24
3
  }
25
4
 
26
5
  output {
27
- elasticsearch {}
6
+ elasticsearch {
7
+ protocol => http
8
+ host => "127.0.0.1"
9
+ }
28
10
  }
@@ -56,6 +56,9 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
56
56
  # How often (in seconds) the urls will be called
57
57
  config :interval, :validate => :number, :required => true
58
58
 
59
+ # Define the target field for placing the received data. If this setting is omitted, the data will be stored at the root (top level) of the event.
60
+ config :target, :validate => :string
61
+
59
62
  # If you'd like to work with the request/response metadata
60
63
  # Set this value to the name of the field you'd like to store a nested
61
64
  # hash of metadata.
@@ -132,21 +135,7 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
132
135
  request_async(queue, name, request)
133
136
  end
134
137
 
135
- # TODO: Remove this once our patch to manticore is accepted. The real callback should work
136
- # Some exceptions are only returned here! There is no callback,
137
- # for example, if there is a bad port number.
138
- # https://github.com/cheald/manticore/issues/22
139
- # This issue is now fixed, but we'll leave this code in for older versions
140
- # of manticore. Once the plugin ecosystem is more updated we can kill this.
141
- client.execute!.each_with_index do |resp, i|
142
- if resp.is_a?(java.lang.Exception) || resp.is_a?(StandardError)
143
- name = @requests.keys[i]
144
- request = @requests[name]
145
- # We can't report the time here because this is as slow as the slowest request
146
- # This is all temporary code anyway
147
- handle_failure(queue, name, request, resp, nil)
148
- end
149
- end
138
+ client.execute!
150
139
  end
151
140
 
152
141
  private
@@ -165,7 +154,8 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
165
154
  private
166
155
  def handle_success(queue, name, request, response, execution_time)
167
156
  @codec.decode(response.body) do |decoded|
168
- handle_decoded_event(queue, name, request, response, decoded, execution_time)
157
+ event = @target ? LogStash::Event.new(@target => decoded.to_hash) : decoded
158
+ handle_decoded_event(queue, name, request, response, event, execution_time)
169
159
  end
170
160
  end
171
161
 
@@ -184,6 +174,7 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
184
174
  end
185
175
 
186
176
  private
177
+ # Beware, on old versions of manticore some uncommon failures are not handled
187
178
  def handle_failure(queue, name, request, exception, execution_time)
188
179
  event = LogStash::Event.new
189
180
  apply_metadata(event, name, request)
@@ -196,14 +187,16 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
196
187
  "url" => @urls[name], # We want the exact parameter they passed in
197
188
  "name" => name,
198
189
  "error" => exception.to_s,
190
+ "backtrace" => exception.backtrace,
199
191
  "runtime_seconds" => execution_time
200
192
  }
201
193
 
202
194
  queue << event
203
195
  rescue StandardError, java.lang.Exception => e
204
196
  @logger.error? && @logger.error("Cannot read URL or send the error as an event!",
205
- :exception => exception,
206
- :exception_message => exception.message,
197
+ :exception => e,
198
+ :exception_message => e.message,
199
+ :exception_backtrace => e.backtrace,
207
200
  :name => name,
208
201
  :url => request
209
202
  )
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-http_poller'
3
- s.version = '1.0.0'
3
+ s.version = '1.0.1'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Poll HTTP endpoints with 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."
@@ -209,7 +209,6 @@ describe LogStash::Inputs::HTTP_Poller do
209
209
  end
210
210
  end
211
211
 
212
-
213
212
  describe "a valid request and decoded response" do
214
213
  let(:payload) { {"a" => 2, "hello" => ["a", "b", "c"]} }
215
214
  let(:opts) { default_opts }
@@ -280,15 +279,18 @@ describe LogStash::Inputs::HTTP_Poller do
280
279
  expect(event.to_hash).to include(payload)
281
280
  end
282
281
  end
283
- end
284
- end
285
-
286
-
287
-
288
-
289
-
290
-
291
-
292
282
 
283
+ context "with a specified target" do
284
+ let(:target) { "mytarget" }
285
+ let(:opts) { default_opts.merge("target" => target) }
293
286
 
287
+ it "should store the event info in the target" do
288
+ # When events go through the pipeline they are java-ified
289
+ # this normalizes the payload to java types
290
+ payload_normalized = LogStash::Json.load(LogStash::Json.dump(payload))
291
+ expect(event[target]).to include(payload_normalized)
292
+ end
293
+ end
294
+ end
295
+ end
294
296
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-http_poller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrewvc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2015-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core