logstash-input-http_poller 5.2.1 → 5.4.0
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/docs/index.asciidoc +18 -0
- data/lib/logstash/inputs/http_poller.rb +31 -14
- data/logstash-input-http_poller.gemspec +4 -4
- data/spec/inputs/http_poller_spec.rb +13 -12
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 959498284e07e414f7be7e02b9df125372526da763a4d273b55fc609186b777c
|
4
|
+
data.tar.gz: 6a6f4dc0da77770581920f719e9de03f3d81bdc079a61fdb43874e5c09d3afa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3af6dc69528053dcc66ccdef55fbd9dfc56bede4cd383ccd44689a884f601b14b630f1d3accc7d56e86ca41f4bbe544379e7dc8cc23d8794db8b2c6d9fd4711
|
7
|
+
data.tar.gz: 693a73cc6a442b7b78d15987ea99d84a6a3b5a6143b12261a95eda1a7bfec070650771f66c2a652709470e4c5cebdc5e8f0921c6e3265c3942d168d8bb32aea2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 5.4.0
|
2
|
+
- Refactor: start using scheduler mixin [#134](https://github.com/logstash-plugins/logstash-input-http_poller/pull/134)
|
3
|
+
|
4
|
+
## 5.3.1
|
5
|
+
- Fix: make sure plugin is closing the http client [#130](https://github.com/logstash-plugins/logstash-input-http_poller/pull/130)
|
6
|
+
|
7
|
+
## 5.3.0
|
8
|
+
- Feat: added ssl_supported_protocols option [#133](https://github.com/logstash-plugins/logstash-input-http_poller/pull/133)
|
9
|
+
|
1
10
|
## 5.2.1
|
2
11
|
- Deps: unpin rufus-scheduler dependency [#130](https://github.com/logstash-plugins/logstash-input-http_poller/pull/130)
|
3
12
|
|
data/docs/index.asciidoc
CHANGED
@@ -146,6 +146,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
146
146
|
| <<plugins-{type}s-{plugin}-retry_non_idempotent>> |<<boolean,boolean>>|No
|
147
147
|
| <<plugins-{type}s-{plugin}-schedule>> |<<hash,hash>>|Yes
|
148
148
|
| <<plugins-{type}s-{plugin}-socket_timeout>> |<<number,number>>|No
|
149
|
+
| <<plugins-{type}s-{plugin}-ssl_supported_protocols>> |<<string,string>>|No
|
149
150
|
| <<plugins-{type}s-{plugin}-ssl_verification_mode>> |<<string,string>>|No
|
150
151
|
| <<plugins-{type}s-{plugin}-target>> |<<string,string>>|No
|
151
152
|
| <<plugins-{type}s-{plugin}-truststore>> |a valid filesystem path|No
|
@@ -414,6 +415,23 @@ See: rufus/scheduler for details about different schedule options and value stri
|
|
414
415
|
|
415
416
|
Timeout (in seconds) to wait for data on the socket. Default is `10s`
|
416
417
|
|
418
|
+
[id="plugins-{type}s-{plugin}-ssl_supported_protocols"]
|
419
|
+
===== `ssl_supported_protocols`
|
420
|
+
|
421
|
+
* Value type is <<string,string>>
|
422
|
+
* Allowed values are: `'TLSv1.1'`, `'TLSv1.2'`, `'TLSv1.3'`
|
423
|
+
* Default depends on the JDK being used. With up-to-date Logstash, the default is `['TLSv1.2', 'TLSv1.3']`.
|
424
|
+
`'TLSv1.1'` is not considered secure and is only provided for legacy applications.
|
425
|
+
|
426
|
+
List of allowed SSL/TLS versions to use when establishing a connection to the HTTP endpoint.
|
427
|
+
|
428
|
+
For Java 8 `'TLSv1.3'` is supported only since **8u262** (AdoptOpenJDK), but requires that you set the
|
429
|
+
`LS_JAVA_OPTS="-Djdk.tls.client.protocols=TLSv1.3"` system property in Logstash.
|
430
|
+
|
431
|
+
NOTE: If you configure the plugin to use `'TLSv1.1'` on any recent JVM, such as the one packaged with Logstash,
|
432
|
+
the protocol is disabled by default and needs to be enabled manually by changing `jdk.tls.disabledAlgorithms` in
|
433
|
+
the *$JDK_HOME/conf/security/java.security* configuration file. That is, `TLSv1.1` needs to be removed from the list.
|
434
|
+
|
417
435
|
[id="plugins-{type}s-{plugin}-ssl_verification_mode"]
|
418
436
|
===== `ssl_verification_mode`
|
419
437
|
|
@@ -4,11 +4,11 @@ require "logstash/namespace"
|
|
4
4
|
require "logstash/plugin_mixins/http_client"
|
5
5
|
require "socket" # for Socket.gethostname
|
6
6
|
require "manticore"
|
7
|
-
require "rufus/scheduler"
|
8
7
|
require "logstash/plugin_mixins/ecs_compatibility_support"
|
9
8
|
require 'logstash/plugin_mixins/ecs_compatibility_support/target_check'
|
10
9
|
require 'logstash/plugin_mixins/validator_support/field_reference_validation_adapter'
|
11
10
|
require 'logstash/plugin_mixins/event_support/event_factory_adapter'
|
11
|
+
require 'logstash/plugin_mixins/scheduler'
|
12
12
|
|
13
13
|
class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
14
14
|
include LogStash::PluginMixins::HttpClient
|
@@ -18,6 +18,8 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
18
18
|
|
19
19
|
extend LogStash::PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter
|
20
20
|
|
21
|
+
include LogStash::PluginMixins::Scheduler
|
22
|
+
|
21
23
|
config_name "http_poller"
|
22
24
|
|
23
25
|
default :codec, "json"
|
@@ -45,23 +47,34 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
45
47
|
config :metadata_target, :validate => :string, :default => '@metadata'
|
46
48
|
|
47
49
|
public
|
48
|
-
Schedule_types = %w(cron every at in)
|
49
50
|
def register
|
50
51
|
@host = Socket.gethostname.force_encoding(Encoding::UTF_8)
|
51
52
|
|
52
|
-
@logger.info("Registering http_poller Input", :type => @type, :schedule => @schedule, :timeout => @timeout)
|
53
|
-
|
54
53
|
setup_ecs_field!
|
55
54
|
setup_requests!
|
56
55
|
end
|
57
56
|
|
58
57
|
# @overload
|
59
58
|
def stop
|
60
|
-
|
61
|
-
|
59
|
+
close_client
|
60
|
+
end
|
61
|
+
|
62
|
+
# @overload
|
63
|
+
def close
|
64
|
+
close_client
|
65
|
+
end
|
66
|
+
|
67
|
+
def close_client
|
68
|
+
@logger.debug("closing http client", client: client)
|
69
|
+
begin
|
70
|
+
client.close # since Manticore 0.9.0 this shuts-down/closes all resources
|
71
|
+
rescue => e
|
72
|
+
details = { exception: e.class, message: e.message }
|
73
|
+
details[:backtrace] = e.backtrace if @logger.debug?
|
74
|
+
@logger.warn "failed closing http client", details
|
62
75
|
end
|
63
|
-
# TODO implement client.close as we as releasing it's pooled resources!
|
64
76
|
end
|
77
|
+
private :close_client
|
65
78
|
|
66
79
|
private
|
67
80
|
def setup_requests!
|
@@ -169,25 +182,27 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
169
182
|
raise Logstash::ConfigurationError, msg_invalid_schedule if @schedule.keys.length != 1
|
170
183
|
schedule_type = @schedule.keys.first
|
171
184
|
schedule_value = @schedule[schedule_type]
|
172
|
-
raise LogStash::ConfigurationError, msg_invalid_schedule unless
|
185
|
+
raise LogStash::ConfigurationError, msg_invalid_schedule unless %w(cron every at in).include?(schedule_type)
|
173
186
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
@scheduler.thread.join # due newer rufus (3.8) doing a blocking operation on scheduler.join
|
187
|
+
opts = schedule_type == "every" ? { first_in: 0.01 } : {}
|
188
|
+
scheduler.public_send(schedule_type, schedule_value, opts) { run_once(queue) }
|
189
|
+
scheduler.join
|
178
190
|
end
|
179
191
|
|
180
192
|
def run_once(queue)
|
181
193
|
@requests.each do |name, request|
|
194
|
+
# prevent executing a scheduler kick after the plugin has been stop-ed
|
195
|
+
# this could easily happen as the scheduler shutdown is not immediate
|
196
|
+
return if stop?
|
182
197
|
request_async(queue, name, request)
|
183
198
|
end
|
184
199
|
|
185
|
-
client.execute!
|
200
|
+
client.execute! unless stop?
|
186
201
|
end
|
187
202
|
|
188
203
|
private
|
189
204
|
def request_async(queue, name, request)
|
190
|
-
@logger.debug? && @logger.debug("
|
205
|
+
@logger.debug? && @logger.debug("async queueing fetching url", name: name, url: request)
|
191
206
|
started = Time.now
|
192
207
|
|
193
208
|
method, *request_opts = request
|
@@ -204,6 +219,7 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
204
219
|
|
205
220
|
private
|
206
221
|
def handle_success(queue, name, request, response, execution_time)
|
222
|
+
@logger.debug? && @logger.debug("success fetching url", name: name, url: request)
|
207
223
|
body = response.body
|
208
224
|
# If there is a usable response. HEAD requests are `nil` and empty get
|
209
225
|
# responses come up as "" which will cause the codec to not yield anything
|
@@ -242,6 +258,7 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
242
258
|
private
|
243
259
|
# Beware, on old versions of manticore some uncommon failures are not handled
|
244
260
|
def handle_failure(queue, name, request, exception, execution_time)
|
261
|
+
@logger.debug? && @logger.debug("failed fetching url", name: name, url: request)
|
245
262
|
event = event_factory.new_event
|
246
263
|
event.tag("_http_request_failure")
|
247
264
|
apply_metadata(event, name, request, nil, execution_time)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-http_poller'
|
3
|
-
s.version = '5.
|
3
|
+
s.version = '5.4.0'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Decodes the output of an HTTP API into events"
|
6
|
-
s.description
|
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'
|
9
9
|
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
@@ -20,8 +20,8 @@ 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", ">= 7.
|
24
|
-
s.add_runtime_dependency '
|
23
|
+
s.add_runtime_dependency "logstash-mixin-http_client", ">= 7.2.0"
|
24
|
+
s.add_runtime_dependency 'logstash-mixin-scheduler', '~> 1.0'
|
25
25
|
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.3'
|
26
26
|
s.add_runtime_dependency 'logstash-mixin-event_support', '~> 1.0', '>= 1.0.1'
|
27
27
|
s.add_runtime_dependency 'logstash-mixin-validator_support', '~> 1.0'
|
@@ -201,8 +201,8 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should run at the schedule" do
|
204
|
-
run_plugin_and_yield_queue(plugin, sleep: 3) do |queue|
|
205
|
-
try(
|
204
|
+
run_plugin_and_yield_queue(plugin, sleep: 3.1) do |queue|
|
205
|
+
try(10) { expect(queue.size).to be >= 2 }
|
206
206
|
end
|
207
207
|
end
|
208
208
|
end
|
@@ -227,8 +227,8 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
227
227
|
end
|
228
228
|
|
229
229
|
it "should run at the schedule" do
|
230
|
-
run_plugin_and_yield_queue(plugin, sleep:
|
231
|
-
try(
|
230
|
+
run_plugin_and_yield_queue(plugin, sleep: 4.1) do |queue|
|
231
|
+
try(10) { expect(queue.size).to eq(1) }
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
@@ -247,7 +247,7 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
247
247
|
#T 0123456
|
248
248
|
#events x x x x
|
249
249
|
#expects 3 events at T=5
|
250
|
-
try(
|
250
|
+
try(10) { expect(queue.size).to be_between(2, 3) }
|
251
251
|
end
|
252
252
|
end
|
253
253
|
end
|
@@ -255,15 +255,15 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
255
255
|
context "given 'in' expression" do
|
256
256
|
let(:opts) {
|
257
257
|
{
|
258
|
-
"schedule" => { "in" => "
|
258
|
+
"schedule" => { "in" => "1s"},
|
259
259
|
"urls" => default_urls,
|
260
260
|
"codec" => "json",
|
261
261
|
"metadata_target" => metadata_target
|
262
262
|
}
|
263
263
|
}
|
264
264
|
it "should run at the schedule" do
|
265
|
-
run_plugin_and_yield_queue(plugin, sleep: 2.
|
266
|
-
try(
|
265
|
+
run_plugin_and_yield_queue(plugin, sleep: 2.05) do |queue|
|
266
|
+
try(10) { expect(queue.size).to eq(1) }
|
267
267
|
end
|
268
268
|
end
|
269
269
|
end
|
@@ -410,14 +410,15 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
410
410
|
before do
|
411
411
|
plugin.register
|
412
412
|
u = url.is_a?(Hash) ? url["url"] : url # handle both complex specs and simple string URLs
|
413
|
-
plugin.client.stub(u,
|
414
|
-
:body => response_body,
|
415
|
-
:code => code
|
416
|
-
)
|
413
|
+
plugin.client.stub(u, :body => response_body, :code => code)
|
417
414
|
allow(plugin).to receive(:decorate)
|
418
415
|
plugin.send(:run_once, queue)
|
419
416
|
end
|
420
417
|
|
418
|
+
after do
|
419
|
+
plugin.close
|
420
|
+
end
|
421
|
+
|
421
422
|
it "should have a matching message" do
|
422
423
|
expect(event.to_hash).to include(payload)
|
423
424
|
end
|
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: 5.
|
4
|
+
version: 5.4.0
|
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: 2022-
|
12
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 7.
|
53
|
+
version: 7.2.0
|
54
54
|
name: logstash-mixin-http_client
|
55
55
|
prerelease: false
|
56
56
|
type: :runtime
|
@@ -58,21 +58,21 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 7.
|
61
|
+
version: 7.2.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
68
|
-
name:
|
67
|
+
version: '1.0'
|
68
|
+
name: logstash-mixin-scheduler
|
69
69
|
prerelease: false
|
70
70
|
type: :runtime
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '1.0'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|