logstash-filter-json 2.0.3 → 2.0.4

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: 40d60f723d2d12a8b176d226b14d27e4f7b59adf
4
- data.tar.gz: 09b010f8cd92b795c6af10eaf4b07ef908515768
3
+ metadata.gz: 4d63e1a61fa9445004bb7885f6a538f3a2d0f111
4
+ data.tar.gz: 01e6536b5b3299872db076c92f82086214b208e8
5
5
  SHA512:
6
- metadata.gz: 9c2bc48511c1b4cae1f9c776479cde3b5558b9e7055971938e1329b5028af7ca6f645049216c4fa0dc0f43003f3ef458e79a6c46469ffe419c93a95882c37d3b
7
- data.tar.gz: 4ad8488fb033dcd70f161e62f3a41f457650fbec31612dc177893af0867431f16936f3d564bf640ecad9e3f7a21f72896331ad7c5426e6862d7e4e4c9eaebc6a
6
+ metadata.gz: 977c862cf4042499c38c0feb4b3f3cdaca9a530b5c40d93c71513f4294c4babfe820f6ea593b66af61a46419c1858d01f3abfbce53db2563fcd9e182c4771c04
7
+ data.tar.gz: 0a699c7e3a8ec591e0c8810cb91f51e53e8ac7ae7f02ba64a995abb30e77e89d78180602f3db52fe518a4ac4d79bfc6dcaf5866de39e5259f799f149d3a3d4b4
@@ -1,3 +1,6 @@
1
+ ## 2.0.4
2
+ - Added an option to configure the tags set when a `JSON` parsing error occur #20
3
+
1
4
  ## 2.0.3
2
5
  - Refactored field references, better timestamp handling, code & specs cleanups
3
6
 
@@ -46,7 +46,9 @@ class LogStash::Filters::Json < LogStash::Filters::Base
46
46
  # NOTE: if the `target` field already exists, it will be overwritten!
47
47
  config :target, :validate => :string
48
48
 
49
- JSONPARSEFAILURE_TAG = "_jsonparsefailure"
49
+ # Append values to the `tags` field when there has been no
50
+ # successful match
51
+ config :tag_on_failure, :validate => :array, :default => ["_jsonparsefailure"]
50
52
 
51
53
  def register
52
54
  # Nothing to do here
@@ -61,7 +63,7 @@ class LogStash::Filters::Json < LogStash::Filters::Base
61
63
  begin
62
64
  parsed = LogStash::Json.load(source)
63
65
  rescue => e
64
- event.tag(JSONPARSEFAILURE_TAG)
66
+ @tag_on_failure.each{|tag| event.tag(tag)}
65
67
  @logger.warn("Error parsing json", :source => @source, :raw => source, :exception => e)
66
68
  return
67
69
  end
@@ -70,7 +72,7 @@ class LogStash::Filters::Json < LogStash::Filters::Base
70
72
  event[@target] = parsed
71
73
  else
72
74
  unless parsed.is_a?(Hash)
73
- event.tag(JSONPARSEFAILURE_TAG)
75
+ @tag_on_failure.each{|tag| event.tag(tag)}
74
76
  @logger.warn("Parsed JSON object/hash requires a target configuration option", :source => @source, :raw => source)
75
77
  return
76
78
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-json'
4
- s.version = '2.0.3'
4
+ s.version = '2.0.4'
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"
@@ -48,12 +48,14 @@ describe LogStash::Filters::Json do
48
48
  # Parse message as JSON, store the results in the 'data' field'
49
49
  source => "message"
50
50
  target => "data"
51
+ tag_on_failure => ["_jsonparsefailure","_custom_failure_tag"]
51
52
  }
52
53
  }
53
54
  CONFIG
54
55
 
55
56
  sample "invalid json" do
56
57
  insist { subject["tags"] }.include?("_jsonparsefailure")
58
+ insist { subject["tags"] }.include?("_custom_failure_tag")
57
59
  end
58
60
  end
59
61
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-json
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-17 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core