From b2257d7e8a17696fb7d0f1451a7ce2fe5c14320f Mon Sep 17 00:00:00 2001 From: Greg Swallow Date: Tue, 1 Apr 2014 09:53:41 -0400 Subject: [PATCH 1/3] Change message format handed to Logstash. Matches https://logstash.jira.com/browse/LOGSTASH-675 --- handlers/notification/logstash.rb | 35 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/handlers/notification/logstash.rb b/handlers/notification/logstash.rb index 261388ba9..40828ba38 100755 --- a/handlers/notification/logstash.rb +++ b/handlers/notification/logstash.rb @@ -36,24 +36,23 @@ def handle redis = Redis.new(:host => settings['logstash']['server'], :port => settings['logstash']['port']) time = Time.now.utc.iso8601 logstash_msg = { - :@source => ::Socket.gethostname, - :@type => settings['logstash']['type'], - :@tags => ["sensu-#{action_to_string}"], - :@message => @event['check']['output'], - :@fields => { - :host => @event['client']['name'], - :timestamp => @event['check']['issued'], - :address => @event['client']['address'], - :check_name => @event['check']['name'], - :command => @event['check']['command'], - :status => @event['check']['status'], - :flapping => @event['check']['flapping'], - :occurrences => @event['occurrences'], - :flapping => @event['check']['flapping'], - :occurrences => @event['occurrences'], - :action => @event['action'] - }, - :@timestamp => time + :@timestamp => time, + :@version => 1, + :source => ::Socket.gethostname, + :type => settings['logstash']['type'], + :tags => ["sensu-#{action_to_string}"], + :message => @event['check']['output'], + :host => @event['client']['name'], + :timestamp => @event['check']['issued'], + :address => @event['client']['address'], + :check_name => @event['check']['name'], + :command => @event['check']['command'], + :status => @event['check']['status'], + :flapping => @event['check']['flapping'], + :occurrences => @event['occurrences'], + :flapping => @event['check']['flapping'], + :occurrences => @event['occurrences'], + :action => @event['action'] } redis.lpush(settings['logstash']['list'], logstash_msg.to_json) end From e657e01722624eb9cd0e7ebc13c298b34efdb606 Mon Sep 17 00:00:00 2001 From: Greg Swallow Date: Wed, 2 Apr 2014 13:55:28 -0400 Subject: [PATCH 2/3] Type is not mandatory for Logstash's schema v1. --- handlers/notification/logstash.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/handlers/notification/logstash.rb b/handlers/notification/logstash.rb index 40828ba38..98d15550c 100755 --- a/handlers/notification/logstash.rb +++ b/handlers/notification/logstash.rb @@ -54,6 +54,7 @@ def handle :occurrences => @event['occurrences'], :action => @event['action'] } + logstash_msg[:type] = settings['logstash']['type'] if settings['logstash'].has_key?('type') redis.lpush(settings['logstash']['list'], logstash_msg.to_json) end end From 1454bf36c06c514bcf03e94b77d0a7890f7ef1f9 Mon Sep 17 00:00:00 2001 From: Greg Swallow Date: Wed, 2 Apr 2014 16:01:24 -0400 Subject: [PATCH 3/3] Oops. --- handlers/notification/logstash.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/handlers/notification/logstash.rb b/handlers/notification/logstash.rb index 98d15550c..07c49ddf2 100755 --- a/handlers/notification/logstash.rb +++ b/handlers/notification/logstash.rb @@ -39,7 +39,6 @@ def handle :@timestamp => time, :@version => 1, :source => ::Socket.gethostname, - :type => settings['logstash']['type'], :tags => ["sensu-#{action_to_string}"], :message => @event['check']['output'], :host => @event['client']['name'],