class LogStash::Outputs::Pushover
Event notification through Pushover
. Currently only supports plain messages (event) and no further configuration options are submitted.
Public Instance Methods
receive(event)
click to toggle source
# File lib/logstash/outputs/pushover.rb, line 55 def receive(event) return unless output?(event) @logger.info("Pushover event", :event => event) # If requested, add any logstash tags to the message message = event.to_s if @add_tags message += " tags: " + @tags.join(',') if @tags end begin request = Net::HTTP::Post.new(@api_uri.path) request.set_form_data({ :token => @app_token, :user => @user_key, :message => event }) # XXX: For any additional configuration keys, add them to the request. response = @client response.use_ssl = true response.verify_mode = OpenSSL::SSL::VERIFY_PEER response.start do |http| r = http.request(request) if status = r.body.match(/"status":(\d+)/)[1] != 1 @logger.warn("API error", :status => status) end end rescue Exception => e @logger.warn("Failed to push notification", :event => event, :exception => e, :backtrace => e.backtrace) end end
register()
click to toggle source
# File lib/logstash/outputs/pushover.rb, line 47 def register require 'net/https' require 'uri' @api_uri = URI.parse(@api_url) @client = Net::HTTP.new(@api_uri.host, @api_uri.port) end