logstash-filter-json 0.1.5 → 0.1.6

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: b4abf730a01ac9da979c89a47d2e1b92d657a87f
4
- data.tar.gz: 03a580d2eac4b824f0f1ec9f5f79f02e0be9a6f4
3
+ metadata.gz: 570c551e0acf8c620bac6b1a0ec970c28f17fd19
4
+ data.tar.gz: 0741d212e884d19071563fdf906cc3b1bce4ee2e
5
5
  SHA512:
6
- metadata.gz: eb74108d4ad143faded3a10c92892ab429bc56b8521b12a519357c9a993a9139ad518b405ed98beebfc3f4ed57d0b439b9f3e52fdc690264f4d7c31322ee53a5
7
- data.tar.gz: 474d3e47d19b1356b9db9da4e68f188e9ac052a3ebee1aaff04cd87ff1e80720fce9e84411f62237cf12bfa95070e285867d7e86966436d9b394c61a0769abf2
6
+ metadata.gz: 9289ef875a3f2909c9f591c85c33e6325c63f3e3428682a5d4a413861c02cde0d54b56cc8a4dd5323b972f81753e71a8f04bb6703db0223c52c8f654953b17ad
7
+ data.tar.gz: 1d330052f8cecbe8cbb45d4509f08ec42ba3249c4f604089efaf01fb13442fbc34eefbfa5584b4fcc3d9e39798741255698f344690806588111ab6915452fd7d
@@ -90,7 +90,9 @@ class LogStash::Filters::Json < LogStash::Filters::Base
90
90
 
91
91
  filter_matched(event)
92
92
  rescue => e
93
- event.tag("_jsonparsefailure")
93
+ tag = "_jsonparsefailure"
94
+ event["tags"] ||= []
95
+ event["tags"] << tag unless event["tags"].include?(tag)
94
96
  @logger.warn("Trouble parsing json", :source => @source,
95
97
  :raw => event[@source], :exception => e)
96
98
  return
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-json'
4
- s.version = '0.1.5'
4
+ s.version = '0.1.6'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This is a JSON parsing filter. It takes an existing field which contains JSON and expands it into an actual data structure within the 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"
@@ -86,4 +86,44 @@ describe LogStash::Filters::Json do
86
86
  end
87
87
  end
88
88
 
89
+ context "when json could not be parsed" do
90
+
91
+ subject(:filter) { LogStash::Filters::Json.new(config) }
92
+
93
+ let(:message) { "random_message" }
94
+ let(:config) { {"source" => "message"} }
95
+ let(:event) { LogStash::Event.new("message" => message) }
96
+
97
+ before(:each) do
98
+ filter.register
99
+ filter.filter(event)
100
+ end
101
+
102
+ it "add the failure tag" do
103
+ expect(event).to include "tags"
104
+ end
105
+
106
+ it "uses an array to store the tags" do
107
+ expect(event['tags']).to be_a Array
108
+ end
109
+
110
+ it "add a json parser failure tag" do
111
+ expect(event['tags']).to include "_jsonparsefailure"
112
+ end
113
+
114
+ context "there are two different errors added" do
115
+
116
+ let(:event) { LogStash::Event.new("message" => message, "tags" => ["_anotherkinfoffailure"] ) }
117
+
118
+ it "pile the different error messages" do
119
+ expect(event['tags']).to include "_jsonparsefailure"
120
+ end
121
+
122
+ it "keep the former error messages on the list" do
123
+ expect(event['tags']).to include "_anotherkinfoffailure"
124
+ end
125
+ end
126
+
127
+ end
128
+
89
129
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - '>='
17
18
  - !ruby/object:Gem::Version
@@ -19,10 +20,7 @@ dependencies:
19
20
  - - <
20
21
  - !ruby/object:Gem::Version
21
22
  version: 2.0.0
22
- name: logstash-core
23
- prerelease: false
24
- type: :runtime
25
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - '>='
28
26
  - !ruby/object:Gem::Version
@@ -30,20 +28,22 @@ dependencies:
30
28
  - - <
31
29
  - !ruby/object:Gem::Version
32
30
  version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
- requirement: !ruby/object:Gem::Requirement
34
+ name: logstash-devutils
35
+ version_requirements: !ruby/object:Gem::Requirement
35
36
  requirements:
36
37
  - - '>='
37
38
  - !ruby/object:Gem::Version
38
39
  version: '0'
39
- name: logstash-devutils
40
- prerelease: false
41
- type: :development
42
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: !ruby/object:Gem::Requirement
43
41
  requirements:
44
42
  - - '>='
45
43
  - !ruby/object:Gem::Version
46
44
  version: '0'
45
+ prerelease: false
46
+ type: :development
47
47
  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
48
48
  email: info@elastic.co
49
49
  executables: []