Here’s my simple extension:
require ‘sensu/extension’
module Sensu
module Extension
class ServiceAlert < Handlerdef name "service-alert" end def description "Extension/handler that relays alerts of services" end def definition { :type => "extension", :name => name, :filters => ["filter_refresh"] } end def run(event) message = Response.prepare(event) yield "#{message}", 0 end end class Response def self.prepare(event) { service: self.check_alias(event), status: self.action_status(event), output: self.check_output(event) } end ... end
end
end
This works great and as advertised. The problem is that every time an event is filtered, my sensu-server log outputs the entire settings to the log file.
{“timestamp”:“2019-02-13T13:31:07.260314+0100”,“level”:“info”,“message”:“event was filtered”, … ,“settings”: <this objects, although a single line, actually spans about 100 lines.>
It logs my entire settings every time an even is filtered. This consists of rabbitmq config, all of my checks, handlers, relays, filters, etc. This is annoying specially when filtering hundreds of events in a small space of time.
When the handler does need to fire, it works fine and just outputs what I want and some extra info:
{“timestamp”:“2019-02-13T13:44:13.603596+0100”,“level”:“info”,“message”:“handler extension output”,“extension”:{“type”:“extension”,“name”:“service-alert”,“filters”:[“filter_refresh”],“severities”:[“unknown”,“critical”,“warning”,“ok”]},“event”:{“id”:“977ec44d-f3ad-4129-b516-68fa82cd6858”},“output”:“…”,“status”:0}
Is there a way I can avoid logging settings everytime the event is filtered?
Note, this does not happen when using a plugin handler where the log line does not output settings and as a consequence the log output is reasonable.
Sensu: 0.29