logstash-filter-multiline 1.0.0 → 1.1.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: 17b100c6051b6ad4550f98ae38ff0bc2d4409264
4
- data.tar.gz: 35c2238c3f6de3bd6dabe93787e1f4c248bd22ea
3
+ metadata.gz: df182f44556a48d76c7f81b2f17c48ea58e5b561
4
+ data.tar.gz: 88a66ec2683dc519251713821db75d76c8a26f57
5
5
  SHA512:
6
- metadata.gz: 0dbbeba706eb2f5e58d2273000efebedbf1f0b7e357bf01b0c3651409cd5b8b52cb57b47b333a71f51f224d21e96bd045ad1ce7a1a32d9913da6bed80bc5a9ef
7
- data.tar.gz: b802811b07e7ea7a2b906782e6759c289fa2f712f55c3eb77338e18e2f16972edcdfa68be817a8652adba0ea5526765f2781d68aa3d25d606f6d14b1e33d2f91
6
+ metadata.gz: 0221738244d7cf9ce35954fcfd90c0efddd861e84258203d4b35e6674187de9ccd02321d74c9022d2fff9c998867799a749414c5449b7dda5cdbca0076cbc350
7
+ data.tar.gz: c343454ea138b676862b5e5fb05befffd8db3ebcf5561c438af440161c78b0e98afdd7c35dea7dab77fab6d983ef6e461b73853f05e21f15ac3846662621b71a
@@ -0,0 +1,2 @@
1
+ ## 1.1.0
2
+ - Fix metadata handling, fixes #19 and #22
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+ gemspec
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Logstash Plugin
2
2
 
3
- This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
4
 
5
5
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
6
 
7
7
  ## Documentation
8
8
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
10
 
11
11
  - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
13
 
14
14
  ## Need Help?
15
15
 
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
83
83
 
84
84
  It is more important to the community that you are able to contribute.
85
85
 
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -228,8 +228,10 @@ class LogStash::Filters::Multiline < LogStash::Filters::Base
228
228
  # this line is not part of the previous event if we have a pending event, it's done, send it.
229
229
  # put the current event into pending
230
230
  unless pending.empty?
231
- tmp = event.to_hash
232
- event.overwrite(merge(pending))
231
+ tmp = event.to_hash_with_metadata
232
+ merged_events = merge(pending)
233
+ event.overwrite(merged_events)
234
+ event["@metadata"] = merged_events["@metadata"] # Override does not copy the metadata
233
235
  pending.clear # avoid array creation
234
236
  pending << LogStash::Event.new(tmp)
235
237
  else
@@ -253,7 +255,9 @@ class LogStash::Filters::Multiline < LogStash::Filters::Base
253
255
  # if we have something in pending, join it with this message and send it.
254
256
  # otherwise, this is a new message and not part of multiline, send it.
255
257
  unless pending.empty?
256
- event.overwrite(merge(pending << event))
258
+ merged_events = merge(pending << event)
259
+ event.overwrite(merged_events)
260
+ event["@metadata"] = merged_events["@metadata"] # Override does not copy the metadata
257
261
  pending.clear
258
262
  end
259
263
  end # if match
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-multiline'
4
- s.version = '1.0.0'
4
+ s.version = '1.1.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This filter will collapse multiline messages from a single source into one Logstash event."
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/plugin install gemname. This gem is not a stand-alone program"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
23
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0.alpha0'
24
24
  s.add_runtime_dependency 'logstash-patterns-core'
25
25
  s.add_runtime_dependency 'logstash-filter-mutate'
26
26
  s.add_runtime_dependency 'jls-grok', '~> 0.11.0'
@@ -245,4 +245,47 @@ describe LogStash::Filters::Multiline do
245
245
  end
246
246
  end
247
247
 
248
+
249
+ describe "keeps metadata fields after two consecutive non multline lines" do
250
+ config <<-CONFIG
251
+ filter {
252
+ mutate { add_field => { "[@metadata][index]" => "logstash-2015.11.19" } }
253
+ multiline {
254
+ pattern => "^%{NUMBER}"
255
+ what => "previous"
256
+ }
257
+ mutate { add_field => { "[@metadata][type]" => "foo" } }
258
+ }
259
+ CONFIG
260
+
261
+ sample ["line1", "line2"] do
262
+ expect(subject).to be_a(Array)
263
+ expect(subject[0]["@metadata"]).to include("index"=>"logstash-2015.11.19")
264
+ expect(subject[1]["@metadata"]).to include("index"=>"logstash-2015.11.19")
265
+ expect(subject[0]["@metadata"]).to include("type"=>"foo")
266
+ expect(subject[1]["@metadata"]).to include("type"=>"foo")
267
+ end
268
+ end
269
+
270
+ describe "keeps metadata fields after two consecutive non multline lines" do
271
+ config <<-CONFIG
272
+ filter {
273
+ mutate { add_field => { "[@metadata][index]" => "logstash-2015.11.19" } }
274
+ multiline {
275
+ pattern => "^%{NUMBER}"
276
+ what => "next"
277
+ }
278
+ mutate { add_field => { "[@metadata][type]" => "foo" } }
279
+ }
280
+ CONFIG
281
+
282
+ sample ["line1", "line2"] do
283
+ expect(subject).to be_a(Array)
284
+ expect(subject[0]["@metadata"]).to include("index"=>"logstash-2015.11.19")
285
+ expect(subject[1]["@metadata"]).to include("index"=>"logstash-2015.11.19")
286
+ expect(subject[0]["@metadata"]).to include("type"=>"foo")
287
+ expect(subject[1]["@metadata"]).to include("type"=>"foo")
288
+ end
289
+ end
290
+
248
291
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-multiline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 1.4.0
20
20
  - - <
21
21
  - !ruby/object:Gem::Version
22
- version: 2.0.0
22
+ version: 2.0.0.alpha0
23
23
  requirement: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '>='
@@ -27,7 +27,7 @@ dependencies:
27
27
  version: 1.4.0
28
28
  - - <
29
29
  - !ruby/object:Gem::Version
30
- version: 2.0.0
30
+ version: 2.0.0.alpha0
31
31
  prerelease: false
32
32
  type: :runtime
33
33
  - !ruby/object:Gem::Dependency
@@ -125,9 +125,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.2.2
128
+ rubygems_version: 2.4.6
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: This filter will collapse multiline messages from a single source into one Logstash event.
132
132
  test_files:
133
133
  - spec/filters/multiline_spec.rb
134
+ has_rdoc: