logstash-filter-json 2.0.6 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd746f5742e8da5738fb9721b8e63bb08c59f7c4
4
- data.tar.gz: 3496565b8e687152acf4f1573305505e97cfbddb
3
+ metadata.gz: e3a3f04567d37846259538d4df0e706fd70e2ea5
4
+ data.tar.gz: 0badea87ef0fae43fa838a62e3e136f049214891
5
5
  SHA512:
6
- metadata.gz: 0b615c999b1a94f8be0033acfbd212be5c9ac682a6d96202d6cb4b2c2b8674c71ee49016d472de1799b5b6ceb4f7c426d65c990158e98eb33e5983b6605eac67
7
- data.tar.gz: b977b150a7cb258f3edeb9fa48c959f8c944ff99413270b7dfc65d3fcf41fa55d50fd84c7bb172a599a2153a5db7cd574359bd2f1feaa9a99f549005dcc7002e
6
+ metadata.gz: ff8ff0813e23f1881f877aa1c37bdb6e21af5e266f32d1b3a0da256847f742f8b4a8c226c43bbd6503d2baab1d975f2209279d63cf99cb8ee7115769746b09e1
7
+ data.tar.gz: d46aa98df97832ae3053250137fc28390a272054fcf1c60a0932eb5daa02db5b076e0863f95d2af0ed7c27e0b9986e4091599d068b9f834ac914213449ecae3e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## 3.0.0
2
+ - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
1
3
  # 2.0.6
2
4
  - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
3
5
  # 2.0.5
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+
3
+ # Specify your gem's dependencies in logstash-mass_effect.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
1
+ Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Build
4
- Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-json-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-json-unit/)
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-json.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-json)
5
4
 
6
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
7
6
 
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
56
55
  ```
57
56
  - Install plugin
58
57
  ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
59
62
  bin/plugin install --no-verify
63
+
60
64
  ```
61
65
  - Run Logstash with your plugin
62
66
  ```sh
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
74
78
  ```
75
79
  - Install the plugin from the Logstash home
76
80
  ```sh
77
- bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
78
87
  ```
79
88
  - Start Logstash and proceed to test the plugin
80
89
 
@@ -66,7 +66,7 @@ class LogStash::Filters::Json < LogStash::Filters::Base
66
66
  def filter(event)
67
67
  @logger.debug? && @logger.debug("Running json filter", :event => event)
68
68
 
69
- source = event[@source]
69
+ source = event.get(@source)
70
70
  return unless source
71
71
 
72
72
  begin
@@ -78,7 +78,7 @@ class LogStash::Filters::Json < LogStash::Filters::Base
78
78
  end
79
79
 
80
80
  if @target
81
- event[@target] = parsed
81
+ event.set(@target, parsed)
82
82
  else
83
83
  unless parsed.is_a?(Hash)
84
84
  @tag_on_failure.each{|tag| event.tag(tag)}
@@ -98,7 +98,7 @@ class LogStash::Filters::Json < LogStash::Filters::Base
98
98
  end
99
99
 
100
100
  # b) then set all parsed fields in the event
101
- parsed.each{|k, v| event[k] = v}
101
+ parsed.each{|k, v| event.set(k, v)}
102
102
 
103
103
  # c) finally re-inject proper @timestamp
104
104
  if parsed_timestamp
@@ -108,7 +108,7 @@ class LogStash::Filters::Json < LogStash::Filters::Base
108
108
  event.timestamp = LogStash::Timestamp.new
109
109
  @logger.warn("Unrecognized #{LogStash::Event::TIMESTAMP} value, setting current time to #{LogStash::Event::TIMESTAMP}, original in #{LogStash::Event::TIMESTAMP_FAILURE_FIELD} field", :value => parsed_timestamp.inspect)
110
110
  event.tag(LogStash::Event::TIMESTAMP_FAILURE_TAG)
111
- event[LogStash::Event::TIMESTAMP_FAILURE_FIELD] = parsed_timestamp.to_s
111
+ event.set(LogStash::Event::TIMESTAMP_FAILURE_FIELD, parsed_timestamp.to_s)
112
112
  end
113
113
  end
114
114
  end
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-json'
4
- s.version = '2.0.6'
4
+ s.version = '3.0.0'
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
- 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"
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"
8
8
  s.authors = ["Elastic"]
9
9
  s.email = 'info@elastic.co'
10
10
  s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
@@ -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-plugin-api", "~> 1.0"
23
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
24
24
 
25
25
  s.add_development_dependency 'logstash-devutils'
26
26
  end
@@ -17,9 +17,9 @@ describe LogStash::Filters::Json do
17
17
  CONFIG
18
18
 
19
19
  sample '{ "hello": "world", "list": [ 1, 2, 3 ], "hash": { "k": "v" } }' do
20
- insist { subject["hello"] } == "world"
21
- insist { subject["list" ].to_a } == [1,2,3] # to_a for JRuby + JrJacksom which creates Java ArrayList
22
- insist { subject["hash"] } == { "k" => "v" }
20
+ insist { subject.get("hello") } == "world"
21
+ insist { subject.get("list" ).to_a } == [1,2,3] # to_a for JRuby + JrJacksom which creates Java ArrayList
22
+ insist { subject.get("hash") } == { "k" => "v" }
23
23
  end
24
24
  end
25
25
 
@@ -35,9 +35,9 @@ describe LogStash::Filters::Json do
35
35
  CONFIG
36
36
 
37
37
  sample '{ "hello": "world", "list": [ 1, 2, 3 ], "hash": { "k": "v" } }' do
38
- insist { subject["data"]["hello"] } == "world"
39
- insist { subject["data"]["list" ].to_a } == [1,2,3] # to_a for JRuby + JrJacksom which creates Java ArrayList
40
- insist { subject["data"]["hash"] } == { "k" => "v" }
38
+ insist { subject.get("data")["hello"] } == "world"
39
+ insist { subject.get("data")["list" ].to_a } == [1,2,3] # to_a for JRuby + JrJacksom which creates Java ArrayList
40
+ insist { subject.get("data")["hash"] } == { "k" => "v" }
41
41
  end
42
42
  end
43
43
 
@@ -54,8 +54,8 @@ describe LogStash::Filters::Json do
54
54
  CONFIG
55
55
 
56
56
  sample "invalid json" do
57
- insist { subject["tags"] }.include?("_jsonparsefailure")
58
- insist { subject["tags"] }.include?("_custom_failure_tag")
57
+ insist { subject.get("tags") }.include?("_jsonparsefailure")
58
+ insist { subject.get("tags") }.include?("_custom_failure_tag")
59
59
  end
60
60
  end
61
61
 
@@ -69,8 +69,8 @@ describe LogStash::Filters::Json do
69
69
  CONFIG
70
70
 
71
71
  sample "{ \"@timestamp\": \"2013-10-19T00:14:32.996Z\" }" do
72
- insist { subject["@timestamp"] }.is_a?(LogStash::Timestamp)
73
- insist { LogStash::Json.dump(subject["@timestamp"]) } == "\"2013-10-19T00:14:32.996Z\""
72
+ insist { subject.get("@timestamp") }.is_a?(LogStash::Timestamp)
73
+ insist { LogStash::Json.dump(subject.get("@timestamp")) } == "\"2013-10-19T00:14:32.996Z\""
74
74
  end
75
75
  end
76
76
 
@@ -85,8 +85,8 @@ describe LogStash::Filters::Json do
85
85
  CONFIG
86
86
 
87
87
  sample({ "example" => "{ \"hello\": \"world\" }" }) do
88
- insist { subject["example"] }.is_a?(Hash)
89
- insist { subject["example"]["hello"] } == "world"
88
+ insist { subject.get("example") }.is_a?(Hash)
89
+ insist { subject.get("example")["hello"] } == "world"
90
90
  end
91
91
  end
92
92
 
@@ -102,8 +102,8 @@ describe LogStash::Filters::Json do
102
102
  CONFIG
103
103
 
104
104
  sample '[ { "k": "v" }, { "l": [1, 2, 3] } ]' do
105
- insist { subject["data"][0]["k"] } == "v"
106
- insist { subject["data"][1]["l"].to_a } == [1,2,3] # to_a for JRuby + JrJacksom which creates Java ArrayList
105
+ insist { subject.get("data")[0]["k"] } == "v"
106
+ insist { subject.get("data")[1]["l"].to_a } == [1,2,3] # to_a for JRuby + JrJacksom which creates Java ArrayList
107
107
  end
108
108
  end
109
109
 
@@ -127,11 +127,11 @@ describe LogStash::Filters::Json do
127
127
  end
128
128
 
129
129
  it "uses an array to store the tags" do
130
- expect(event['tags']).to be_a(Array)
130
+ expect(event.get('tags')).to be_a(Array)
131
131
  end
132
132
 
133
133
  it "add a json parser failure tag" do
134
- expect(event['tags']).to include("_jsonparsefailure")
134
+ expect(event.get('tags')).to include("_jsonparsefailure")
135
135
  end
136
136
 
137
137
  context "there are two different errors added" do
@@ -139,11 +139,11 @@ describe LogStash::Filters::Json do
139
139
  let(:event) { LogStash::Event.new("message" => message, "tags" => ["_anotherkinfoffailure"] ) }
140
140
 
141
141
  it "pile the different error messages" do
142
- expect(event['tags']).to include("_jsonparsefailure")
142
+ expect(event.get('tags')).to include("_jsonparsefailure")
143
143
  end
144
144
 
145
145
  it "keep the former error messages on the list" do
146
- expect(event['tags']).to include("_anotherkinfoffailure")
146
+ expect(event.get('tags')).to include("_anotherkinfoffailure")
147
147
  end
148
148
  end
149
149
  end
@@ -152,7 +152,7 @@ describe LogStash::Filters::Json do
152
152
  let(:message) { "[1, 2, 3]" }
153
153
 
154
154
  it "adds the failure tag" do
155
- expect(event['tags']).to include("_jsonparsefailure")
155
+ expect(event.get('tags')).to include("_jsonparsefailure")
156
156
  end
157
157
  end
158
158
 
@@ -170,8 +170,8 @@ describe LogStash::Filters::Json do
170
170
 
171
171
  it "should set timestamp to current time" do
172
172
  expect(event.timestamp).to be_a(LogStash::Timestamp)
173
- expect(event["tags"]).to include(LogStash::Event::TIMESTAMP_FAILURE_TAG)
174
- expect(event[LogStash::Event::TIMESTAMP_FAILURE_FIELD]).to eq("foobar")
173
+ expect(event.get("tags")).to include(LogStash::Event::TIMESTAMP_FAILURE_TAG)
174
+ expect(event.get(LogStash::Event::TIMESTAMP_FAILURE_FIELD)).to eq("foobar")
175
175
  end
176
176
  end
177
177
  end
metadata CHANGED
@@ -1,44 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: '1.0'
19
- name: logstash-core-plugin-api
20
- prerelease: false
19
+ version: '2.0'
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: logstash-devutils
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
- name: logstash-devutils
34
- prerelease: false
35
34
  type: :development
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- 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
41
+ description: This gem is a Logstash plugin required to be installed on top of the
42
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
43
+ gem is not a stand-alone program
42
44
  email: info@elastic.co
43
45
  executables: []
44
46
  extensions: []
@@ -59,7 +61,7 @@ licenses:
59
61
  metadata:
60
62
  logstash_plugin: 'true'
61
63
  logstash_group: filter
62
- post_install_message:
64
+ post_install_message:
63
65
  rdoc_options: []
64
66
  require_paths:
65
67
  - lib
@@ -74,10 +76,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
76
  - !ruby/object:Gem::Version
75
77
  version: '0'
76
78
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.4.8
79
- signing_key:
79
+ rubyforge_project:
80
+ rubygems_version: 2.5.1
81
+ signing_key:
80
82
  specification_version: 4
81
- 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.
83
+ summary: This is a JSON parsing filter. It takes an existing field which contains
84
+ JSON and expands it into an actual data structure within the Logstash event.
82
85
  test_files:
83
86
  - spec/filters/json_spec.rb