Class: LogStash::Outputs::Mongodb

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/mongodb.rb

Instance Attribute Summary

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LogStash::Outputs::Base

Instance Method Details

#receive(event) ⇒ Object



16
17
18
# File 'lib/logstash/outputs/mongodb.rb', line 16

def receive(event)
  @mongodb.collection(@collection).insert(event.to_hash)
end

#registerObject



7
8
9
10
11
12
13
# File 'lib/logstash/outputs/mongodb.rb', line 7

def register
  # TODO(sissel): Port?
  # TODO(sissel): Authentication?
  # db and collection are mongodb://.../db/collection
  unused, @db, @collection = @url.path.split("/", 3)
  @mongodb = EventMachine::Mongo::Connection.new(@url.host).db(@db)
end