Class: LogStash::Filters::JsonSchema

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/filters/json_schema.rb

Overview

This filter will validate the message against a json schema provided in the configuration.

It adds a jsonschemafailure tag if the message does not validate

Instance Method Summary collapse

Instance Method Details

#filter(event) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/logstash/filters/json_schema.rb', line 25

def filter(event)
  body = event.get("message")
  if !JSON::Validator.validate(@schema, body)
    tags = event.get("tags")
    tags = [] if !tags
    tags.push("jsonschemafailure")
    event.set("tags", tags)
  end

  # filter_matched should go in the last line of our successful code
  filter_matched(event)
end

#registerObject



20
21
22
# File 'lib/logstash/filters/json_schema.rb', line 20

def register
  # Add instance variables 
end