Class: LogStash::Outputs::PagerDuty
- Defined in:
- lib/logstash/outputs/pagerduty.rb
Overview
PagerDuty output Send specific events to PagerDuty for alerting
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Outputs::Base
Instance Method Details
#receive(event) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/logstash/outputs/pagerduty.rb', line 52 def receive(event) return unless output?(event) pd_event = Hash.new pd_event[:service_key] = "#{@service_key}" pd_event[:incident_key] = event.sprintf(@incident_key) pd_event[:event_type] = "#{@event_type}" pd_event[:description] = event.sprintf(@description) pd_event[:details] = Hash.new @details.each do |key, value| @logger.debug("PD Details added:" , key => event.sprintf(value)) pd_event[:details]["#{key}"] = event.sprintf(value) end pd_event[:details][:tags] = @tags if @tags @logger.info("PD Event", :event => pd_event) begin request = Net::HTTP::Post.new(@pd_uri.path) request.body = pd_event.to_json @logger.debug("PD Request", :request => request.inspect) response = @client.request(request) @logger.debug("PD Response", :response => response.body) rescue Exception => e @logger.debug("PD Unhandled exception", :pd_error => e.backtrace) end end |
#register ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/logstash/outputs/pagerduty.rb', line 38 def register require 'net/https' require 'uri' @pd_uri = URI.parse(@pdurl) @client = Net::HTTP.new(@pd_uri.host, @pd_uri.port) if @pd_uri.scheme == "https" @client.use_ssl = true #@client.verify_mode = OpenSSL::SSL::VERIFY_PEER # PagerDuty cert doesn't verify oob @client.verify_mode = OpenSSL::SSL::VERIFY_NONE end end |