Class: LogStash::Outputs::ElasticSearchRiver

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

Overview

This output lets you store logs in elasticsearch. It’s similar to the ‘elasticsearch’ output but improves performance by using a queue server, rabbitmq, to send data to elasticsearch.

Upon startup, this output will automatically contact an elasticsearch cluster and configure it to read from the queue to which we write.

You can learn more about elasticseasrch at <elasticsearch.org> More about the elasticsearch rabbitmq river plugin: <github.com/elasticsearch/elasticsearch-river-rabbitmq/blob/master/README.md>

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

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

Instance Method Details

#receive(event) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/logstash/outputs/elasticsearch_river.rb', line 202

def receive(event)
  return unless output?(event)
  # River events have a format of
  # "action\ndata\n"
  # where 'action' is index or delete, data is the data to index.
  header = { "index" => { "_index" => event.sprintf(@index), "_type" => event.sprintf(@index_type) } }
  if !@document_id.nil?
    header["index"]["_id"] = event.sprintf(@document_id)
  end

  @mq.publish_serialized(header.to_json + "\n" + event.to_json + "\n")
end

#registerObject



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/logstash/outputs/elasticsearch_river.rb', line 88

def register

  # TODO(sissel): find a better way of declaring where the elasticsearch
  # libraries are
  # TODO(sissel): can skip this step if we're running from a jar.
  jarpath = File.join(File.dirname(__FILE__), "../../../vendor/**/*.jar")
  Dir[jarpath].each do |jar|
      require jar
  end
  prepare_river
end