mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
- Add MongoDB output
This commit is contained in:
parent
6805a6ef03
commit
4c38c9d8fe
1 changed files with 24 additions and 0 deletions
24
lib/outputs/mongodb.rb
Normal file
24
lib/outputs/mongodb.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require "logstash/namespace"
|
||||
require "logstash/event"
|
||||
require "uri"
|
||||
require "em-mongo"
|
||||
|
||||
class LogStash::Outputs::Mongodb
|
||||
def initialize(url, config={}, &block)
|
||||
@url = url
|
||||
@url = URI.parse(url) if url.is_a? String
|
||||
@config = config
|
||||
end
|
||||
|
||||
def register
|
||||
# Port?
|
||||
# Authentication?
|
||||
db = @url.path[1..-1] # Skip leading '/'
|
||||
@mongodb = EventMachine::Mongo::Connection.new(@url.host).db(db)
|
||||
end # def register
|
||||
|
||||
def receive(event)
|
||||
puts "Got: #{event}"
|
||||
@mongodb.collection("events").insert(event.to_hash)
|
||||
end # def event
|
||||
end # class LogStash::Outputs::Websocket
|
Loading…
Add table
Add a link
Reference in a new issue