logstash-codec-json 0.1.7 → 1.0.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 +0 -0
- data/NOTICE.TXT +5 -0
- data/README.md +1 -1
- data/lib/logstash/codecs/json.rb +8 -3
- data/logstash-codec-json.gemspec +1 -1
- data/spec/codecs/json_spec.rb +23 -0
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 301db44dac7fae7150d3192cedfc924aede32ecc
|
4
|
+
data.tar.gz: 3655a1837f16ee061573a65e17582c87f6c72397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 654736689c2cffe29aa09dc2df93825f8c617a6ddac5dec1e14104de6b34b6ec06f868b0b7068a719c0abb6e8befcd1eb99dc5178d64ad1e356f3943fa393dda
|
7
|
+
data.tar.gz: 77fc0dc02e502d549a32c8bacc77c03f34e9999f2f53281817a21e0c26f42a7182825bfbedee93ead67b4d1667d1d5503039d37f526be9c7231a025752eb863d
|
data/CHANGELOG.md
ADDED
File without changes
|
data/NOTICE.TXT
ADDED
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Logstash provides infrastructure to automatically generate documentation for thi
|
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
16
|
-
Need help? Try #logstash on freenode IRC or the logstash
|
16
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
17
17
|
|
18
18
|
## Developing
|
19
19
|
|
data/lib/logstash/codecs/json.rb
CHANGED
@@ -6,7 +6,12 @@ require "logstash/json"
|
|
6
6
|
# This codec may be used to decode (via inputs) and encode (via outputs)
|
7
7
|
# full JSON messages. If you are streaming JSON messages delimited
|
8
8
|
# by '\n' then see the `json_lines` codec.
|
9
|
-
#
|
9
|
+
#
|
10
|
+
# Encoding will result in a compact JSON representation (no line terminators or indentation)
|
11
|
+
#
|
12
|
+
# If this codec recieves a payload from an input that is not valid JSON, then
|
13
|
+
# it will fall back to plain text and add a tag `_jsonparsefailure`. Upon a JSON
|
14
|
+
# failure, the payload will be stored in the `message` field.
|
10
15
|
class LogStash::Codecs::JSON < LogStash::Codecs::Base
|
11
16
|
config_name "json"
|
12
17
|
|
@@ -19,7 +24,7 @@ class LogStash::Codecs::JSON < LogStash::Codecs::Base
|
|
19
24
|
# weird cases like this, you can set the `charset` setting to the
|
20
25
|
# actual encoding of the text and Logstash will convert it for you.
|
21
26
|
#
|
22
|
-
# For nxlog users, you
|
27
|
+
# For nxlog users, you may to set this to "CP1252".
|
23
28
|
config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"
|
24
29
|
|
25
30
|
public
|
@@ -35,7 +40,7 @@ class LogStash::Codecs::JSON < LogStash::Codecs::Base
|
|
35
40
|
yield LogStash::Event.new(LogStash::Json.load(data))
|
36
41
|
rescue LogStash::Json::ParserError => e
|
37
42
|
@logger.info("JSON parse failure. Falling back to plain-text", :error => e, :data => data)
|
38
|
-
yield LogStash::Event.new("message" => data, "tags" => "_jsonparsefailure")
|
43
|
+
yield LogStash::Event.new("message" => data, "tags" => ["_jsonparsefailure"])
|
39
44
|
end
|
40
45
|
end # def decode
|
41
46
|
|
data/logstash-codec-json.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-codec-json'
|
4
|
-
s.version = '0.
|
4
|
+
s.version = '1.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This codec may be used to decode (via inputs) and encode (via outputs) full JSON messages"
|
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"
|
data/spec/codecs/json_spec.rb
CHANGED
@@ -64,6 +64,29 @@ describe LogStash::Codecs::JSON do
|
|
64
64
|
insist { decoded } == true
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
context "when json could not be parsed" do
|
69
|
+
|
70
|
+
let(:message) { "random_message" }
|
71
|
+
|
72
|
+
it "add the failure tag" do
|
73
|
+
subject.decode(message) do |event|
|
74
|
+
expect(event).to include "tags"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "uses an array to store the tags" do
|
79
|
+
subject.decode(message) do |event|
|
80
|
+
expect(event['tags']).to be_a Array
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "add a json parser failure tag" do
|
85
|
+
subject.decode(message) do |event|
|
86
|
+
expect(event['tags']).to include "_jsonparsefailure"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
67
90
|
end
|
68
91
|
|
69
92
|
context "#encode" do
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-codec-json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.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-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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: []
|
@@ -51,9 +51,11 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
|
+
- CHANGELOG.md
|
54
55
|
- CONTRIBUTORS
|
55
56
|
- Gemfile
|
56
57
|
- LICENSE
|
58
|
+
- NOTICE.TXT
|
57
59
|
- README.md
|
58
60
|
- Rakefile
|
59
61
|
- lib/logstash/codecs/json.rb
|
@@ -81,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
83
|
version: '0'
|
82
84
|
requirements: []
|
83
85
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.2.2
|
85
87
|
signing_key:
|
86
88
|
specification_version: 4
|
87
89
|
summary: This codec may be used to decode (via inputs) and encode (via outputs) full JSON messages
|