Sha256: 70e020dcd9b6d006d4d3b798d136bb9a1000be34158eb3d8e5f5285af2e5de26

Contents?: true

Size: 844 Bytes

Versions: 2

Compression:

Stored size: 844 Bytes

Contents

require 'logstash/namespace'
require 'logstash/outputs/base'
require 'logstash/outputs/timetree/timetree'

class LogStash::Outputs::Neo4j < LogStash::Outputs::Base

  config_name 'neo4j'

  # The path within your file system where the neo4j database is located
  config :path, :validate => :string, :required => true

  attr_reader :tree

  def register
    require 'neo4j'
    if Neo4j::Session.current.nil?
      @session = ::Neo4j::Session.open(:embedded_db, @path, auto_commit: true)
      @session.start
    end
    @session = Neo4j::Session.current
    @tree = Neo4jrb::TimeTree.new(@session)
  end

  def receive(event)
    return unless output?(event)
    payload = event.to_hash
    timestamp = payload["@timestamp"].time
    @tree.add_event(timestamp, payload)
  end

  def teardown
    @session.shutdown
    @session.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-output-neo4j-0.9.1-java lib/logstash/outputs/neo4j.rb
logstash-output-neo4j-0.9.0-java lib/logstash/outputs/neo4j.rb