logstash-filter-json_schema 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: a3c82fba22ea5ac41e32543390a6d70ac0969b211256f6662f10584601257a54
4
- data.tar.gz: ef302dbb24a1aefc1e651b4d6ec6ebc39118be0032d5d739e79497e41a66049d
3
+ metadata.gz: d5fefdaf07853d10fb971174dee7ec4d39c23063fde17b4f3bca7a6e0ecc9e42
4
+ data.tar.gz: 23064a42d45678ed8ed8c48c2e5ae5fb03d25ab8163362c8beac744046231409
5
5
  SHA512:
6
- metadata.gz: c1740df3136ad4c27a37ed3399060d406d60949cb85d6ff14a3e9cbb62dc0dbd1f647c1dfbbdcfde0e9b6e1965d130324b94daf0bb8f3358a0793d9db5f30111
7
- data.tar.gz: 457b27b8da85ffde7ce5a86786608b2953c8b08dae354b4df27748a9022a2289aea648162a163f7932c5b48abd3f207c8d20b6aa3d3c76b7faa7f2df8b0cd5ed
6
+ metadata.gz: 985dbc1ccaeb7fea939e99735683322b3f328f24a5b795def682fb14bd52bbd740e1565093425571b7a925c47edcc2145bbed7d84b07c315de352a3e565fbe0e
7
+ data.tar.gz: 713a44e1d7aadb241d58372aee407e4067b36470cfe8d96e1e0c75f50df8a917f45383391915db2dfbdc42bb4976d3f251dae3ce73d7b7ea1b86a2dae96630cd
@@ -24,14 +24,23 @@ class LogStash::Filters::JsonSchema < LogStash::Filters::Base
24
24
  public
25
25
  def filter(event)
26
26
  body = event.get("message")
27
- if !JSON::Validator.validate(@schema, body)
28
- tags = event.get("tags")
29
- tags = [] if !tags
30
- tags.push("jsonschemafailure")
31
- event.set("tags", tags)
27
+ begin
28
+ if !JSON::Validator.validate(@schema, body)
29
+ tag_as_schema_failure(event)
30
+ end
31
+ rescue Exception => e
32
+ logger.error("Exception thrown while validating entry", { "schema" => @schema, "log entry" => body, "exception" => e})
33
+ tag_as_schema_failure(event)
32
34
  end
33
35
 
34
36
  # filter_matched should go in the last line of our successful code
35
37
  filter_matched(event)
36
38
  end # def filter
39
+
40
+ def tag_as_schema_failure(event)
41
+ tags = event.get("tags")
42
+ tags = [] if !tags
43
+ tags.push("jsonschemafailure")
44
+ event.set("tags", tags)
45
+ end
37
46
  end # class LogStash::Filters::JsonSchema
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-json_schema'
3
- s.version = '0.1.0'
3
+ s.version = '0.2.0'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'Validates json input against a provided schema (https://json-schema.org)'
6
6
  s.homepage = 'https://github.com/pluralsight/logstash-filter-json_schema'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Sorensen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-16 00:00:00.000000000 Z
12
+ date: 2018-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement