Class: DLogger::Output::SplunkStorm
- Defined in:
- lib/dlogger/outputs/em/splunkstorm.rb
Constant Summary collapse
- API_VERSION =
1
- ENDPOINT =
'inputs/http'
Instance Method Summary collapse
- #dispatch(msg, metadata) ⇒ Object
-
#initialize(url, opts = {}) ⇒ SplunkStorm
constructor
A new instance of SplunkStorm.
Constructor Details
#initialize(url, opts = {}) ⇒ SplunkStorm
Returns a new instance of SplunkStorm.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dlogger/outputs/em/splunkstorm.rb', line 13 def initialize(url, opts = {}) @url = "#{url}/#{API_VERSION}/#{ENDPOINT}" @access_token = opts.delete(:access_token) @event_params = { :sourcetype => 'json_auto_timestamp', :host => opts.delete(:host), :project => opts.delete(:project) } raise ":access_token required" unless @access_token raise ":host required" unless @event_params[:host] raise ":project required" unless @event_params[:project] raise "unknown options: #{opts.inspect}" unless opts.empty? end |
Instance Method Details
#dispatch(msg, metadata) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dlogger/outputs/em/splunkstorm.rb', line 31 def dispatch(msg, ) = .merge(:message => msg) http = EM::HttpRequest.new(@url).post( :query => @event_params, :head => {'authorization' => [@access_token, 'x']}, :body => Yajl::Encoder.encode() ) # http.errback do # p "ERR: #{http.response_header}" # end end |