Class: MongoAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/mongoprofile.rb,
lib/logstash/test.rb

Overview

class LogStash::Inputs::Mongoprofile

Instance Method Summary collapse

Constructor Details

#initialize(url, collection, client_host) ⇒ MongoAccessor

Returns a new instance of MongoAccessor.



39
40
41
42
43
44
45
# File 'lib/logstash/test.rb', line 39

def initialize(url, collection, client_host)
  connection = Mongo::Client.new(url)

  @mongodb = connection.database
  @collection = @mongodb.collection(collection)
  @client_host = client_host
end

Instance Method Details

#get_documents(limit) ⇒ Object



51
52
53
# File 'lib/logstash/test.rb', line 51

def get_documents(limit)
  @collection.find({:client => {:$ne => @client_host}}).limit(limit).sort(:ts => 1)
end

#get_documents_by_ts(date, limit) ⇒ Object



47
48
49
# File 'lib/logstash/test.rb', line 47

def get_documents_by_ts(date, limit)
  @collection.find({:ts => {:$gt => DateTime.parse(date) + 0.00002}, :client => {:$ne => @client_host}}).limit(limit).sort(:ts => 1)
end