mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Merge branch 'master' of github.com:logstash/logstash
This commit is contained in:
commit
0b961c1c1c
1 changed files with 16 additions and 6 deletions
|
@ -1,18 +1,28 @@
|
|||
require "logstash/outputs/base"
|
||||
require "logstash/namespace"
|
||||
require "em-mongo"
|
||||
require "mongo"
|
||||
|
||||
class LogStash::Outputs::Mongodb < LogStash::Outputs::Base
|
||||
|
||||
config_name "mongodb"
|
||||
|
||||
config :host, :validate => :string, :required => true
|
||||
config :port, :validate => :number
|
||||
config :database, :validate => :string, :required => true
|
||||
config :collection, :validate => :string, :required => true
|
||||
|
||||
public
|
||||
def initialize(params)
|
||||
super
|
||||
|
||||
@port ||= Mongo::Connection::DEFAULT_PORT
|
||||
end
|
||||
|
||||
public
|
||||
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)
|
||||
# TODO(petef): support authentication
|
||||
# TODO(petef): check for errors
|
||||
@mongodb = Mongo::Connection.new(@host, @port).db(@database)
|
||||
end # def register
|
||||
|
||||
public
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue