logstash-input-http_poller 1.1.0 → 1.1.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 +4 -4
- data/CHANGELOG.md +2 -0
- data/lib/logstash/inputs/http_poller.rb +8 -2
- data/logstash-input-http_poller.gemspec +1 -1
- data/spec/inputs/http_poller_spec.rb +27 -2
- 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: 0a79de169452abf5395cb7a3e06a5dae63f27dda
|
4
|
+
data.tar.gz: 755ee4b2c9fbc325ceac82c093b8b35ab9d30fab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9aba937e2387dd41d10a50f7e423dc4f79cdfd09314a9e6ab422a1f3063d33bc35166a12a442c9d14f286c6bd77129ed22348567dde55e8db199e1d31b30754
|
7
|
+
data.tar.gz: 78b7e079c117d402e17af33a59c628b85fcc51ca201235ecf362774654ad46cc7f264f38f5de1049c260d17e6f8c2251704f150c9ec5f5aaa2f02b405506a880
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,7 @@ require "manticore"
|
|
18
18
|
# # Supports all options supported by ruby's Manticore HTTP client
|
19
19
|
# method => get
|
20
20
|
# url => "http://localhost:9200/_cluster/health"
|
21
|
+
# automatic_retries => 2 # Retry the URL twice
|
21
22
|
# headers => {
|
22
23
|
# Accept => "application/json"
|
23
24
|
# }
|
@@ -44,6 +45,11 @@ require "manticore"
|
|
44
45
|
class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
45
46
|
include LogStash::PluginMixins::HttpClient
|
46
47
|
|
48
|
+
# Default client options for requests
|
49
|
+
DEFAULT_SPEC = {
|
50
|
+
:automatic_retries => 0 # By default manticore retries 3 times, make this explicit
|
51
|
+
}
|
52
|
+
|
47
53
|
config_name "http_poller"
|
48
54
|
|
49
55
|
default :codec, "json"
|
@@ -82,10 +88,10 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
82
88
|
private
|
83
89
|
def normalize_request(url_or_spec)
|
84
90
|
if url_or_spec.is_a?(String)
|
85
|
-
res = [:get, url_or_spec]
|
91
|
+
res = [:get, url_or_spec, DEFAULT_SPEC.clone]
|
86
92
|
elsif url_or_spec.is_a?(Hash)
|
87
93
|
# The client will expect keys / values
|
88
|
-
spec = Hash[url_or_spec.
|
94
|
+
spec = Hash[DEFAULT_SPEC.merge(url_or_spec).map {|k,v| [k.to_sym, v] }] # symbolize keys
|
89
95
|
|
90
96
|
# method and url aren't really part of the options, so we pull them out
|
91
97
|
method = (spec.delete(:method) || :get).to_sym.downcase
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-http_poller'
|
3
|
-
s.version = '1.1.
|
3
|
+
s.version = '1.1.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."
|
@@ -60,7 +60,9 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
60
60
|
|
61
61
|
it "should to set additional options correctly" do
|
62
62
|
opts = normalized.length > 2 ? normalized[2] : nil
|
63
|
-
|
63
|
+
# At this point we'r ddealing in symbols
|
64
|
+
expected = Hash[LogStash::Inputs::HTTP_Poller::DEFAULT_SPEC.merge(spec_opts || {}).map {|k,v| [k.to_sym,v]} ]
|
65
|
+
expect(opts).to eql(expected)
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
@@ -88,6 +90,29 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
88
90
|
}.merge(Hash[spec_opts.map {|k,v| [k.to_s,v]}])
|
89
91
|
end
|
90
92
|
|
93
|
+
it "should include the default options" do
|
94
|
+
expect(normalized[2]).to include(LogStash::Inputs::HTTP_Poller::DEFAULT_SPEC)
|
95
|
+
end
|
96
|
+
|
97
|
+
context "when overiding a spec default" do
|
98
|
+
let(:retries) { 3 }
|
99
|
+
let(:url) do
|
100
|
+
{
|
101
|
+
"url" => spec_url,
|
102
|
+
"method" => spec_method,
|
103
|
+
"automatic_retries" => retries
|
104
|
+
}.merge(Hash[spec_opts.map {|k,v| [k.to_s,v]}])
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should override the default options" do
|
108
|
+
expect(normalized[2]).to include(:automatic_retries => retries)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should not include the defaults" do
|
112
|
+
expect(normalized[2]).not_to include(LogStash::Inputs::HTTP_Poller::DEFAULT_SPEC)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
91
116
|
include_examples("a normalized request")
|
92
117
|
end
|
93
118
|
|
@@ -161,7 +186,7 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
161
186
|
|
162
187
|
it "should have the correct request url" do
|
163
188
|
if url.is_a?(Hash) # If the url was specified as a complex test the whole thing
|
164
|
-
expect(metadata["request"]).to
|
189
|
+
expect(metadata["request"]).to include(url)
|
165
190
|
else # Otherwise we have to make some assumptions
|
166
191
|
expect(metadata["request"]["url"]).to eql(url)
|
167
192
|
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.1.
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|