Skip to content

Commit

Permalink
Merge pull request sensu#536 from gswallow/master
Browse files Browse the repository at this point in the history
Change message format handed to Logstash.
  • Loading branch information
kalabiyau committed Apr 23, 2014
2 parents 644a3b6 + 1454bf3 commit 217ae24
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions handlers/notification/logstash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,24 @@ 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,
: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']
}
logstash_msg[:type] = settings['logstash']['type'] if settings['logstash'].has_key?('type')
redis.lpush(settings['logstash']['list'], logstash_msg.to_json)
end
end

0 comments on commit 217ae24

Please sign in to comment.