logstash-input-http_poller 1.0.2 → 1.1.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 +3 -2
- data/lib/logstash/inputs/http_poller.rb +15 -4
- data/logstash-input-http_poller.gemspec +1 -1
- data/spec/inputs/http_poller_spec.rb +27 -4
- 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: 376d01f7f7f2543cf29dc25d017d09e5d7c46472
|
4
|
+
data.tar.gz: e1fe840d963dc87fb97afd647f43047eaf9f1a44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b7aa09232b6540dab84356da874b160396071edcc76ae1e1021e98121909918319cf87624f2fc069bf26980051360ad60455bfb0b83050d37e732d4a28fa7b6
|
7
|
+
data.tar.gz: b151a285605f59e062f62faddf8c4b09378fc43ee0fe2ef51525e6e102c36e3b5c3094eeb65ad66480703ef2274371adbe2b15f9b900d9ee27e7cb0519b0780b
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
* 1.1.0
|
2
|
+
- Error metadata no longer '_' prefixed for kibana compat
|
3
|
+
- HTTP metadata now normalized to prevent conflicts with ES schemas
|
1
4
|
* 1.0.2
|
2
5
|
- Bug fix: Decorating the event before pushing it to the queue
|
3
|
-
|
4
6
|
* 1.0.1
|
5
7
|
- Add 'target' option
|
6
|
-
|
7
8
|
* 1.0.0
|
8
9
|
- Initial release
|
@@ -31,7 +31,7 @@ require "manticore"
|
|
31
31
|
# interval => 60
|
32
32
|
# codec => "json"
|
33
33
|
# # A hash of request metadata info (timing, response headers, etc.) will be sent here
|
34
|
-
# metadata_target => "
|
34
|
+
# metadata_target => "http_poller_metadata"
|
35
35
|
# }
|
36
36
|
# }
|
37
37
|
#
|
@@ -184,8 +184,8 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
184
184
|
|
185
185
|
# This is also in the metadata, but we send it anyone because we want this
|
186
186
|
# persisted by default, whereas metadata isn't. People don't like mysterious errors
|
187
|
-
event["
|
188
|
-
"
|
187
|
+
event["http_request_failure"] = {
|
188
|
+
"request" => structure_request(request),
|
189
189
|
"name" => name,
|
190
190
|
"error" => exception.to_s,
|
191
191
|
"backtrace" => exception.backtrace,
|
@@ -214,7 +214,7 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
214
214
|
m = {
|
215
215
|
"name" => name,
|
216
216
|
"host" => @host,
|
217
|
-
"
|
217
|
+
"request" => structure_request(request),
|
218
218
|
}
|
219
219
|
|
220
220
|
m["runtime_seconds"] = execution_time
|
@@ -228,4 +228,15 @@ class LogStash::Inputs::HTTP_Poller < LogStash::Inputs::Base
|
|
228
228
|
|
229
229
|
m
|
230
230
|
end
|
231
|
+
|
232
|
+
private
|
233
|
+
# Turn [method, url, spec] requests into a hash for friendlier logging / ES indexing
|
234
|
+
def structure_request(request)
|
235
|
+
method, url, spec = request
|
236
|
+
# Flatten everything into the 'spec' hash, also stringify any keys to normalize
|
237
|
+
Hash[(spec||{}).merge({
|
238
|
+
"method" => method.to_s,
|
239
|
+
"url" => url,
|
240
|
+
}).map {|k,v| [k.to_s,v] }]
|
241
|
+
end
|
231
242
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-http_poller'
|
3
|
-
s.version = '1.0
|
3
|
+
s.version = '1.1.0'
|
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."
|
@@ -130,6 +130,25 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
|
+
|
134
|
+
describe "#structure_request" do
|
135
|
+
it "Should turn a simple request into the expected structured request" do
|
136
|
+
expected = {"url" => "http://example.net", "method" => "get"}
|
137
|
+
expect(subject.send(:structure_request, ["get", "http://example.net"])).to eql(expected)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should turn a complex request into the expected structured one" do
|
141
|
+
headers = {
|
142
|
+
"X-Fry" => " Like a balloon, and... something bad happens! "
|
143
|
+
}
|
144
|
+
expected = {
|
145
|
+
"url" => "http://example.net",
|
146
|
+
"method" => "get",
|
147
|
+
"headers" => headers
|
148
|
+
}
|
149
|
+
expect(subject.send(:structure_request, ["get", "http://example.net", {"headers" => headers}])).to eql(expected)
|
150
|
+
end
|
151
|
+
end
|
133
152
|
end
|
134
153
|
|
135
154
|
describe "events" do
|
@@ -140,8 +159,12 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
140
159
|
expect(metadata["name"]).to eql(name)
|
141
160
|
end
|
142
161
|
|
143
|
-
it "should have the correct url" do
|
144
|
-
|
162
|
+
it "should have the correct request url" do
|
163
|
+
if url.is_a?(Hash) # If the url was specified as a complex test the whole thing
|
164
|
+
expect(metadata["request"]).to eql(url)
|
165
|
+
else # Otherwise we have to make some assumptions
|
166
|
+
expect(metadata["request"]["url"]).to eql(url)
|
167
|
+
end
|
145
168
|
end
|
146
169
|
|
147
170
|
it "should have the correct code" do
|
@@ -167,8 +190,8 @@ describe LogStash::Inputs::HTTP_Poller do
|
|
167
190
|
expect(event).to be_a(LogStash::Event)
|
168
191
|
end
|
169
192
|
|
170
|
-
it "should enqueue a message with '
|
171
|
-
expect(event["
|
193
|
+
it "should enqueue a message with 'http_request_failure' set" do
|
194
|
+
expect(event["http_request_failure"]).to be_a(Hash)
|
172
195
|
end
|
173
196
|
|
174
197
|
it "should tag the event with '_http_request_failure'" do
|
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
|
4
|
+
version: 1.1.0
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|