logstash-input-http_poller 4.0.3 → 5.0.2

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
- SHA1:
3
- metadata.gz: a32f39048f5329848504f38c8c89cf5e997cdc9b
4
- data.tar.gz: 6e9a910ca6dd641db1ce87e2b23f76d05249d128
2
+ SHA256:
3
+ metadata.gz: 50ae088dbf54c3b101fdbb36f6743d9525c4664ef9dc592ba3d351580a8712a8
4
+ data.tar.gz: 0ea8ab2cfae1a16dd3faadf4a1af9ccac2b9e235d1ac0a83353ed21e95c70b78
5
5
  SHA512:
6
- metadata.gz: 5b20a8cefd5691306d89cbb68c52105adc50675a3a9f95e6fc39abe46f307ca5591cb88c4628e934805c902b03383eafe9e9c0b309c64e3999c1418a783407e6
7
- data.tar.gz: 332c3f3e13855246c5bc821096558c9a58a65824491e107b2307d5c0366c3e20bf71c86af9683039414b1e1ea90d0b2f8a6df434bd27e82319c43d976ca313cf
6
+ metadata.gz: 47457f51157fb74494d11b03567af00c7855f1824b020740c836977fd99f3b91a06bbde2724148205971c4ff02dc539580537e90088dd36a14e5daf09311d94d
7
+ data.tar.gz: 982dd17052f30f21f8a4d6d1e852260f0955d11f0d42eae0dcc003a3478522fb4cb4a8310e57db821238127aefbe728cd758154e689045dc7dbc221ca29f617b
@@ -1,8 +1,27 @@
1
+ ## 5.0.2
2
+ - [DOC]Expanded url option to include Manticore keys [#119](https://github.com/logstash-plugins/logstash-input-http_poller/pull/119)
3
+
4
+ ## 5.0.1
5
+ - Fixed minor doc and doc formatting issues [#107](https://github.com/logstash-plugins/logstash-input-http_poller/pull/107)
6
+
7
+ ## 5.0.0
8
+ - Removed obsolete field `interval`
9
+
10
+ ## 4.0.6
11
+ - Changed `schedule` entry to show that it is required
12
+ [#102](https://github.com/logstash-plugins/logstash-input-http_poller/pull/102)
13
+
14
+ ## 4.0.5
15
+ - Docs: Set the default_codec doc attribute.
16
+
17
+ ## 4.0.4
18
+ - Update gemspec summary
19
+
1
20
  ## 4.0.3
2
21
  - Docs: Remove row in overview table to fix build error
3
22
 
4
23
  ## 4.0.2
5
- - Don't bleed URLs credentials on startup and on exception #82
24
+ - Don't bleed URLs credentials on startup and on exception [#82](https://github.com/logstash-plugins/logstash-input-http_poller/pull/82)
6
25
 
7
26
  ## 4.0.1
8
27
  - Fix some documentation issues
data/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -178,7 +179,7 @@
178
179
  APPENDIX: How to apply the Apache License to your work.
179
180
 
180
181
  To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "{}"
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
183
  replaced with your own identifying information. (Don't include
183
184
  the brackets!) The text should be enclosed in the appropriate
184
185
  comment syntax for the file format. We also recommend that a
@@ -186,7 +187,7 @@
186
187
  same "printed page" as the copyright notice for easier
187
188
  identification within third-party archives.
188
189
 
189
- Copyright {yyyy} {name of copyright owner}
190
+ Copyright 2020 Elastic and contributors
190
191
 
191
192
  Licensed under the Apache License, Version 2.0 (the "License");
192
193
  you may not use this file except in compliance with the License.
@@ -199,4 +200,3 @@
199
200
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
201
  See the License for the specific language governing permissions and
201
202
  limitations under the License.
202
-
@@ -1,5 +1,6 @@
1
1
  :plugin: http_poller
2
2
  :type: input
3
+ :default_codec: json
3
4
 
4
5
  ///////////////////////////////////////////
5
6
  START - GENERATED VARIABLES, DO NOT EDIT!
@@ -94,8 +95,6 @@ This plugin supports the following configuration options plus the <<plugins-{typ
94
95
  [cols="<,<,<",options="header",]
95
96
  |=======================================================================
96
97
  |Setting |Input type|Required
97
- | <<plugins-{type}s-{plugin}-user>> |<<string,string>>|no
98
- | <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
99
98
  | <<plugins-{type}s-{plugin}-automatic_retries>> |<<number,number>>|No
100
99
  | <<plugins-{type}s-{plugin}-cacert>> |a valid filesystem path|No
101
100
  | <<plugins-{type}s-{plugin}-client_cert>> |a valid filesystem path|No
@@ -108,18 +107,20 @@ This plugin supports the following configuration options plus the <<plugins-{typ
108
107
  | <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|No
109
108
  | <<plugins-{type}s-{plugin}-keystore_type>> |<<string,string>>|No
110
109
  | <<plugins-{type}s-{plugin}-metadata_target>> |<<string,string>>|No
110
+ | <<plugins-{type}s-{plugin}-password>> |<<password,password>>|No
111
111
  | <<plugins-{type}s-{plugin}-pool_max>> |<<number,number>>|No
112
112
  | <<plugins-{type}s-{plugin}-pool_max_per_route>> |<<number,number>>|No
113
113
  | <<plugins-{type}s-{plugin}-proxy>> |<<,>>|No
114
114
  | <<plugins-{type}s-{plugin}-request_timeout>> |<<number,number>>|No
115
115
  | <<plugins-{type}s-{plugin}-retry_non_idempotent>> |<<boolean,boolean>>|No
116
- | <<plugins-{type}s-{plugin}-schedule>> |<<hash,hash>>|No
116
+ | <<plugins-{type}s-{plugin}-schedule>> |<<hash,hash>>|Yes
117
117
  | <<plugins-{type}s-{plugin}-socket_timeout>> |<<number,number>>|No
118
118
  | <<plugins-{type}s-{plugin}-target>> |<<string,string>>|No
119
119
  | <<plugins-{type}s-{plugin}-truststore>> |a valid filesystem path|No
120
120
  | <<plugins-{type}s-{plugin}-truststore_password>> |<<password,password>>|No
121
121
  | <<plugins-{type}s-{plugin}-truststore_type>> |<<string,string>>|No
122
122
  | <<plugins-{type}s-{plugin}-urls>> |<<hash,hash>>|Yes
123
+ | <<plugins-{type}s-{plugin}-user>> |<<string,string>>|No
123
124
  | <<plugins-{type}s-{plugin}-validate_after_inactivity>> |<<number,number>>|No
124
125
  |=======================================================================
125
126
 
@@ -128,23 +129,6 @@ input plugins.
128
129
 
129
130
  &nbsp;
130
131
 
131
- [id="plugins-{type}s-{plugin}-user"]
132
- ===== `user`
133
-
134
- * Value type is <<string,string>>
135
- * There is no default value for this setting.
136
-
137
- Username to use with HTTP authentication for ALL requests. Note that you can also set this per-URL.
138
- If you set this you must also set the `password` option.
139
-
140
- [id="plugins-{type}s-{plugin}-password"]
141
- ===== `password`
142
-
143
- * Value type is <<password,password>>
144
- * There is no default value for this setting.
145
-
146
- Password to be used in conjunction with the username for HTTP authentication.
147
-
148
132
  [id="plugins-{type}s-{plugin}-automatic_retries"]
149
133
  ===== `automatic_retries`
150
134
 
@@ -248,6 +232,14 @@ If you'd like to work with the request/response metadata.
248
232
  Set this value to the name of the field you'd like to store a nested
249
233
  hash of metadata.
250
234
 
235
+ [id="plugins-{type}s-{plugin}-password"]
236
+ ===== `password`
237
+
238
+ * Value type is <<password,password>>
239
+ * There is no default value for this setting.
240
+
241
+ Password to be used in conjunction with <<plugins-{type}s-{plugin}-user>> for HTTP authentication.
242
+
251
243
  [id="plugins-{type}s-{plugin}-pool_max"]
252
244
  ===== `pool_max`
253
245
 
@@ -282,10 +274,7 @@ If you'd like to use an HTTP proxy . This supports multiple configuration syntax
282
274
  * Value type is <<number,number>>
283
275
  * Default value is `60`
284
276
 
285
- This module makes it easy to add a very fully configured HTTP client to logstash
286
- based on [Manticore](https://github.com/cheald/manticore).
287
- For an example of its usage see https://github.com/logstash-plugins/logstash-input-http_poller
288
- Timeout (in seconds) for the entire request
277
+ Timeout (in seconds) for the entire request.
289
278
 
290
279
  [id="plugins-{type}s-{plugin}-retry_non_idempotent"]
291
280
  ===== `retry_non_idempotent`
@@ -359,7 +348,45 @@ Specify the truststore type here. One of `JKS` or `PKCS12`. Default is `JKS`
359
348
  * There is no default value for this setting.
360
349
 
361
350
  A Hash of urls in this format : `"name" => "url"`.
362
- The name and the url will be passed in the outputed event
351
+ The name and the url will be passed in the outputted event.
352
+
353
+ The values in urls can be either:
354
+
355
+ * a string url (which will be issued as an HTTP GET).
356
+ * a sub-hash containing many useful keys provided by the Manticore backend:
357
+ ** url: the String url
358
+ ** method: (optional) the HTTP method to use (defaults to GET)
359
+ ** user: (optional) the HTTP Basic Auth user. The user must be under
360
+ an auth sub-hash for Manticore, but this plugin also accepts it either way.
361
+ ** password: (optional) the HTTP Basic Auth password. The password
362
+ must be under an auth sub-hash for Manticore, but this plugin accepts it either way.
363
+ ** headers: a hash containing key-value pairs of headers.
364
+ ** body: a string (supported only on POST and PUT requests)
365
+ ** possibly other options mentioned in the
366
+ https://www.rubydoc.info/github/cheald/manticore/Manticore/Client#http-instance_method[Manticore docs].
367
+ Note that Manticore options that are not explicitly documented above are not
368
+ thoroughly tested and therefore liable to break in unexpected ways if we
369
+ replace the backend.
370
+
371
+ *Notes:*
372
+
373
+ * Passwords specified as a part of `urls` are prone to exposure in plugin log output.
374
+ The plugin does not declare them as passwords, and therefore doesn't wrap them in
375
+ leak-reducing wrappers as we do elsewhere.
376
+ * We don't guarantee that boolean-type options like Manticore's `follow_redirects` are supported
377
+ correctly. The strings `true` or `false` may get passed through, and in ruby any
378
+ string is "truthy."
379
+ * Our implementation of this plugin precludes the ability to specify auth[:eager]
380
+ as anything other than true
381
+
382
+ [id="plugins-{type}s-{plugin}-user"]
383
+ ===== `user`
384
+
385
+ * Value type is <<string,string>>
386
+ * There is no default value for this setting.
387
+
388
+ Username to use with HTTP authentication for ALL requests. Note that you can also set this per-URL.
389
+ If you set this you must also set the <<plugins-{type}s-{plugin}-password>> option.
363
390
 
364
391
  [id="plugins-{type}s-{plugin}-validate_after_inactivity"]
365
392
  ===== `validate_after_inactivity`
@@ -367,13 +394,18 @@ The name and the url will be passed in the outputed event
367
394
  * Value type is <<number,number>>
368
395
  * Default value is `200`
369
396
 
370
- How long to wait before checking if the connection is stale before executing a request on a connection using keepalive.
371
- # You may want to set this lower, possibly to 0 if you get connection errors regularly
372
- Quoting the Apache commons docs (this client is based Apache Commmons):
373
- 'Defines period of inactivity in milliseconds after which persistent connections must be re-validated prior to being leased to the consumer. Non-positive value passed to this method disables connection validation. This check helps detect connections that have become stale (half-closed) while kept inactive in the pool.'
374
- See https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html#setValidateAfterInactivity(int)[these docs for more info]
375
-
397
+ How long to wait before checking for a stale connection to determine if a keepalive request is needed.
398
+ Consider setting this value lower than the default, possibly to 0, if you get connection errors regularly.
376
399
 
400
+ This client is based on Apache Commons' HTTP implementation. Here's how the
401
+ https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html#setValidateAfterInactivity(int)[Apache
402
+ Commons documentation] describes this option: "Defines period of inactivity in
403
+ milliseconds after which persistent connections must be re-validated prior to
404
+ being leased to the consumer. Non-positive value passed to this method disables
405
+ connection validation. This check helps detect connections that have become
406
+ stale (half-closed) while kept inactive in the pool."
377
407
 
378
408
  [id="plugins-{type}s-{plugin}-common-options"]
379
- include::{include_path}/{type}.asciidoc[]
409
+ include::{include_path}/{type}.asciidoc[]
410
+
411
+ :default_codec!:
@@ -17,8 +17,6 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
17
17
  # The name and the url will be passed in the outputed event
18
18
  config :urls, :validate => :hash, :required => true
19
19
 
20
- config :interval, :validate => :number, :obsolete => "The interval options is obsolete. Use schedule instead"
21
-
22
20
  # Schedule of when to periodically poll from the urls
23
21
  # Format: A hash with
24
22
  # + key: "cron" | "every" | "in" | "at"
@@ -165,7 +163,7 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
165
163
  # If there is a usable response. HEAD requests are `nil` and empty get
166
164
  # responses come up as "" which will cause the codec to not yield anything
167
165
  if body && body.size > 0
168
- @codec.decode(body) do |decoded|
166
+ decode_and_flush(@codec, body) do |decoded|
169
167
  event = @target ? LogStash::Event.new(@target => decoded.to_hash) : decoded
170
168
  handle_decoded_event(queue, name, request, response, event, execution_time)
171
169
  end
@@ -175,6 +173,12 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
175
173
  end
176
174
  end
177
175
 
176
+ private
177
+ def decode_and_flush(codec, body, &yielder)
178
+ codec.decode(body, &yielder)
179
+ codec.flush(&yielder)
180
+ end
181
+
178
182
  private
179
183
  def handle_decoded_event(queue, name, request, response, event, execution_time)
180
184
  apply_metadata(event, name, request, response, execution_time)
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-http_poller'
3
- s.version = '4.0.3'
3
+ s.version = '5.0.2'
4
4
  s.licenses = ['Apache License (2.0)']
5
- s.summary = "Poll HTTP endpoints with Logstash."
5
+ s.summary = "Decodes the output of an HTTP API into events"
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/logstash-plugin install gemname. This gem is not a stand-alone program"
7
7
  s.authors = [ "Elastic", "andrewvc"]
8
8
  s.email = 'info@elastic.co'
@@ -20,11 +20,12 @@ Gem::Specification.new do |s|
20
20
  # Gem dependencies
21
21
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
22
22
  s.add_runtime_dependency 'logstash-codec-plain'
23
- s.add_runtime_dependency 'logstash-mixin-http_client', ">= 6.0.0", "< 7.0.0"
23
+ s.add_runtime_dependency 'logstash-mixin-http_client', "~> 7"
24
24
  s.add_runtime_dependency 'stud', "~> 0.0.22"
25
25
  s.add_runtime_dependency 'rufus-scheduler', "~>3.0.9"
26
26
 
27
27
  s.add_development_dependency 'logstash-codec-json'
28
+ s.add_development_dependency 'logstash-codec-line'
28
29
  s.add_development_dependency 'logstash-devutils'
29
30
  s.add_development_dependency 'flores'
30
31
  s.add_development_dependency 'timecop'
@@ -1,4 +1,5 @@
1
1
  require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/devutils/rspec/shared_examples"
2
3
  require 'logstash/inputs/http_poller'
3
4
  require 'flores/random'
4
5
  require "timecop"
@@ -462,6 +463,40 @@ describe LogStash::Inputs::HTTP_Poller do
462
463
  expect(event.get(target)).to include(payload_normalized)
463
464
  end
464
465
  end
466
+
467
+ context 'using a line codec' do
468
+ let(:opts) do
469
+ default_opts.merge({"codec" => "line"})
470
+ end
471
+ subject(:events) do
472
+ [].tap do |events|
473
+ events << queue.pop until queue.empty?
474
+ end
475
+ end
476
+
477
+ context 'when response has a trailing newline' do
478
+ let(:response_body) { "one\ntwo\nthree\nfour\n" }
479
+ it 'emits all events' do
480
+ expect(events.size).to equal(4)
481
+ messages = events.map{|e| e.get('message')}
482
+ expect(messages).to include('one')
483
+ expect(messages).to include('two')
484
+ expect(messages).to include('three')
485
+ expect(messages).to include('four')
486
+ end
487
+ end
488
+ context 'when response has no trailing newline' do
489
+ let(:response_body) { "one\ntwo\nthree\nfour" }
490
+ it 'emits all events' do
491
+ expect(events.size).to equal(4)
492
+ messages = events.map{|e| e.get('message')}
493
+ expect(messages).to include('one')
494
+ expect(messages).to include('two')
495
+ expect(messages).to include('three')
496
+ expect(messages).to include('four')
497
+ end
498
+ end
499
+ end
465
500
  end
466
501
  end
467
502
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-http_poller
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-09-20 00:00:00.000000000 Z
12
+ date: 2020-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
@@ -48,23 +48,17 @@ dependencies:
48
48
  - !ruby/object:Gem::Dependency
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 6.0.0
54
- - - "<"
51
+ - - "~>"
55
52
  - !ruby/object:Gem::Version
56
- version: 7.0.0
53
+ version: '7'
57
54
  name: logstash-mixin-http_client
58
55
  prerelease: false
59
56
  type: :runtime
60
57
  version_requirements: !ruby/object:Gem::Requirement
61
58
  requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 6.0.0
65
- - - "<"
59
+ - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: 7.0.0
61
+ version: '7'
68
62
  - !ruby/object:Gem::Dependency
69
63
  requirement: !ruby/object:Gem::Requirement
70
64
  requirements:
@@ -107,6 +101,20 @@ dependencies:
107
101
  - - ">="
108
102
  - !ruby/object:Gem::Version
109
103
  version: '0'
104
+ - !ruby/object:Gem::Dependency
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ name: logstash-codec-line
111
+ prerelease: false
112
+ type: :development
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
110
118
  - !ruby/object:Gem::Dependency
111
119
  requirement: !ruby/object:Gem::Requirement
112
120
  requirements:
@@ -149,7 +157,9 @@ dependencies:
149
157
  - - ">="
150
158
  - !ruby/object:Gem::Version
151
159
  version: '0'
152
- description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
160
+ description: This gem is a Logstash plugin required to be installed on top of the
161
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
162
+ gem is not a stand-alone program
153
163
  email: info@elastic.co
154
164
  executables: []
155
165
  extensions: []
@@ -186,9 +196,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
196
  version: '0'
187
197
  requirements: []
188
198
  rubyforge_project:
189
- rubygems_version: 2.4.8
199
+ rubygems_version: 2.6.13
190
200
  signing_key:
191
201
  specification_version: 4
192
- summary: Poll HTTP endpoints with Logstash.
202
+ summary: Decodes the output of an HTTP API into events
193
203
  test_files:
194
204
  - spec/inputs/http_poller_spec.rb