logstash-output-http 4.1.0 → 4.2.0

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
2
  SHA1:
3
- metadata.gz: 96be92dd03ba701e5c21af44559f567fe9e9d00e
4
- data.tar.gz: eee63a9d3a744b0e298116cf5842b6efa60ab5a4
3
+ metadata.gz: 3b4a026e5f3a42c48d00794b751d1611669b3e40
4
+ data.tar.gz: d0dc53c6a6dbc21e76e0cf9f949e2999aeea4eda
5
5
  SHA512:
6
- metadata.gz: 259ba5e8cd221de83656a1c04a3c032cfd93de96930cc1a7e9ff80a014356bb180e28e47a5c8dfeae3decc5bc59c2e29f391e49561834903f98405f14e21cfeb
7
- data.tar.gz: 3a33c97b68551e0a335bdac609de359124027314cc6350d5ebbef6537d508f9a8f91ebea06b261316d7c9110d89acba2d659b89e22e3ec52546ef8657fd5450b
6
+ metadata.gz: 04740829ac241f0f35cb36a199e84d31a27ac20764af5bdcb2ed496d6deb1b34f949579a984447de2f57b808eb130b1673a2a748c99965f2f43aa7d926cdf965
7
+ data.tar.gz: ecd0e6c6dce00ecc73b3b7d85a476a8384eddeb6f659495c8e18cd75f294d750e9b4c37b5125193017006f7c9ab0e97f005355f027874083405542416bf80371
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## 4.2.0
2
+ - Allow nested array in field definition, See https://github.com/logstash-plugins/logstash-output-http/pull/53
1
3
  ## 4.1.0
2
4
  - Allow nested field definitions in `mappings`
3
5
 
@@ -305,29 +305,23 @@ 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)
308
+ def convert_mapping(mapping, event)
309
+ if mapping.is_a?(Hash)
310
+ mapping.reduce({}) do |acc, kv|
311
+ k, v = kv
312
+ acc[k] = convert_mapping(v, event)
313
+ acc
315
314
  end
316
- acc
315
+ elsif mapping.is_a?(Array)
316
+ mapping.map { |elem| convert_mapping(elem, event) }
317
+ else
318
+ event.sprintf(mapping)
317
319
  end
318
320
  end
319
321
 
320
322
  def map_event(event)
321
323
  if @mapping
322
- @mapping.reduce({}) do |acc,kv|
323
- k,v = kv
324
- if v.is_a?(Hash)
325
- acc[k] = reduce_hash(v, event)
326
- else
327
- acc[k] = event.sprintf(v)
328
- end
329
- acc
330
- end
324
+ convert_mapping(@mapping, event)
331
325
  else
332
326
  event.to_hash
333
327
  end
@@ -1,7 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
-
3
2
  s.name = 'logstash-output-http'
4
- s.version = '4.1.0'
3
+ s.version = '4.2.0'
5
4
  s.licenses = ['Apache License (2.0)']
6
5
  s.summary = "This output lets you `PUT` or `POST` events to a generic HTTP(S) endpoint"
7
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"
@@ -287,7 +287,10 @@ describe LogStash::Outputs::Http do
287
287
  "host" => "X %{foo}",
288
288
  "event" => {
289
289
  "user" => "Y %{user}"
290
- }
290
+ },
291
+ "arrayevent" => [{
292
+ "user" => "Z %{user}"
293
+ }]
291
294
  }
292
295
  }
293
296
  }
@@ -296,7 +299,10 @@ describe LogStash::Outputs::Http do
296
299
  "host" => "X #{event.get("foo")}",
297
300
  "event" => {
298
301
  "user" => "Y #{event.get("user")}"
299
- }
302
+ },
303
+ "arrayevent" => [{
304
+ "user" => "Z #{event.get("user")}"
305
+ }]
300
306
  })
301
307
  }
302
308
  let(:expected_content_type) { "application/json" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-13 00:00:00.000000000 Z
11
+ date: 2017-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement