logstash-output-http 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/outputs/http.rb +18 -2
- data/logstash-output-http.gemspec +1 -1
- data/spec/outputs/http_spec.rb +34 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96be92dd03ba701e5c21af44559f567fe9e9d00e
|
4
|
+
data.tar.gz: eee63a9d3a744b0e298116cf5842b6efa60ab5a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 259ba5e8cd221de83656a1c04a3c032cfd93de96930cc1a7e9ff80a014356bb180e28e47a5c8dfeae3decc5bc59c2e29f391e49561834903f98405f14e21cfeb
|
7
|
+
data.tar.gz: 3a33c97b68551e0a335bdac609de359124027314cc6350d5ebbef6537d508f9a8f91ebea06b261316d7c9110d89acba2d659b89e22e3ec52546ef8657fd5450b
|
data/CHANGELOG.md
CHANGED
@@ -66,7 +66,7 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
66
66
|
#
|
67
67
|
# For example:
|
68
68
|
# [source,ruby]
|
69
|
-
# mapping => {"foo" => "%{host}"
|
69
|
+
# mapping => {"foo" => "%{host}"
|
70
70
|
# "bar" => "%{type}"}
|
71
71
|
config :mapping, :validate => :hash
|
72
72
|
|
@@ -305,11 +305,27 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
305
305
|
end
|
306
306
|
end
|
307
307
|
|
308
|
+
def reduce_hash(hash, event)
|
309
|
+
hash.reduce({}) do |acc, kv|
|
310
|
+
k, v = kv
|
311
|
+
if v.is_a?(Hash)
|
312
|
+
acc[k] = reduce_hash(v, event)
|
313
|
+
else
|
314
|
+
acc[k] = event.sprintf(v)
|
315
|
+
end
|
316
|
+
acc
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
308
320
|
def map_event(event)
|
309
321
|
if @mapping
|
310
322
|
@mapping.reduce({}) do |acc,kv|
|
311
323
|
k,v = kv
|
312
|
-
|
324
|
+
if v.is_a?(Hash)
|
325
|
+
acc[k] = reduce_hash(v, event)
|
326
|
+
else
|
327
|
+
acc[k] = event.sprintf(v)
|
328
|
+
end
|
313
329
|
acc
|
314
330
|
end
|
315
331
|
else
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-http'
|
4
|
-
s.version = '4.
|
4
|
+
s.version = '4.1.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This output lets you `PUT` or `POST` events to a generic HTTP(S) endpoint"
|
7
7
|
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"
|
data/spec/outputs/http_spec.rb
CHANGED
@@ -102,7 +102,9 @@ describe LogStash::Outputs::Http do
|
|
102
102
|
# Requires pool_max to be 1
|
103
103
|
|
104
104
|
let(:port) { PORT }
|
105
|
-
let(:event) {
|
105
|
+
let(:event) {
|
106
|
+
LogStash::Event.new({"message" => "hi"})
|
107
|
+
}
|
106
108
|
let(:url) { "http://localhost:#{port}/good" }
|
107
109
|
let(:method) { "post" }
|
108
110
|
|
@@ -225,7 +227,9 @@ describe LogStash::Outputs::Http do
|
|
225
227
|
|
226
228
|
describe "integration tests" do
|
227
229
|
let(:url) { "http://localhost:#{port}/good" }
|
228
|
-
let(:event) {
|
230
|
+
let(:event) {
|
231
|
+
LogStash::Event.new("foo" => "bar", "baz" => "bot", "user" => "McBest")
|
232
|
+
}
|
229
233
|
|
230
234
|
subject { LogStash::Outputs::Http.new(config) }
|
231
235
|
|
@@ -265,12 +269,39 @@ describe LogStash::Outputs::Http do
|
|
265
269
|
|
266
270
|
describe "sending a mapped event" do
|
267
271
|
let(:config) {
|
268
|
-
{"url" => url, "http_method" => "post", "pool_max" => 1, "mapping" => {"blah" => "X %{foo}"}}
|
272
|
+
{"url" => url, "http_method" => "post", "pool_max" => 1, "mapping" => {"blah" => "X %{foo}"} }
|
269
273
|
}
|
270
274
|
let(:expected_body) { LogStash::Json.dump("blah" => "X #{event.get("foo")}") }
|
271
275
|
let(:expected_content_type) { "application/json" }
|
272
276
|
|
273
277
|
include_examples("a received event")
|
274
278
|
end
|
279
|
+
|
280
|
+
describe "sending a mapped, nested event" do
|
281
|
+
let(:config) {
|
282
|
+
{
|
283
|
+
"url" => url,
|
284
|
+
"http_method" => "post",
|
285
|
+
"pool_max" => 1,
|
286
|
+
"mapping" => {
|
287
|
+
"host" => "X %{foo}",
|
288
|
+
"event" => {
|
289
|
+
"user" => "Y %{user}"
|
290
|
+
}
|
291
|
+
}
|
292
|
+
}
|
293
|
+
}
|
294
|
+
let(:expected_body) {
|
295
|
+
LogStash::Json.dump({
|
296
|
+
"host" => "X #{event.get("foo")}",
|
297
|
+
"event" => {
|
298
|
+
"user" => "Y #{event.get("user")}"
|
299
|
+
}
|
300
|
+
})
|
301
|
+
}
|
302
|
+
let(:expected_content_type) { "application/json" }
|
303
|
+
|
304
|
+
include_examples("a received event")
|
305
|
+
end
|
275
306
|
end
|
276
307
|
end
|