logstash-filter-json_schema 0.1.0 → 0.2.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/lib/logstash/filters/json_schema.rb +14 -5
- data/logstash-filter-json_schema.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5fefdaf07853d10fb971174dee7ec4d39c23063fde17b4f3bca7a6e0ecc9e42
|
4
|
+
data.tar.gz: 23064a42d45678ed8ed8c48c2e5ae5fb03d25ab8163362c8beac744046231409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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.
|
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.
|
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-
|
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
|