Class: Fluent::ElasticsearchOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::ElasticsearchOutput
- Defined in:
- lib/fluent/plugin/out_elasticsearch.rb
Instance Attribute Summary collapse
-
#es ⇒ Object
readonly
register plugin first.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ ElasticsearchOutput
constructor
A new instance of ElasticsearchOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ ElasticsearchOutput
Returns a new instance of ElasticsearchOutput.
12 13 14 15 |
# File 'lib/fluent/plugin/out_elasticsearch.rb', line 12 def initialize require 'elasticsearch' super end |
Instance Attribute Details
#es ⇒ Object (readonly)
register plugin first.
5 6 7 |
# File 'lib/fluent/plugin/out_elasticsearch.rb', line 5 def es @es end |
Instance Method Details
#configure(conf) ⇒ Object
17 18 19 |
# File 'lib/fluent/plugin/out_elasticsearch.rb', line 17 def configure(conf) super end |
#format(tag, time, record) ⇒ Object
31 32 33 |
# File 'lib/fluent/plugin/out_elasticsearch.rb', line 31 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
27 28 29 |
# File 'lib/fluent/plugin/out_elasticsearch.rb', line 27 def shutdown super end |
#start ⇒ Object
21 22 23 24 25 |
# File 'lib/fluent/plugin/out_elasticsearch.rb', line 21 def start super es_url = "#{self.host}:#{self.port}" @es = Elasticsearch::Client.new hosts: [es_url] end |
#write(chunk) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fluent/plugin/out_elasticsearch.rb', line 35 def write(chunk) bulk_items = [] chunk.msgpack_each do |tag, time, record| bulk_items << { :index => { :_index => self.index, :_type => tag, :data => { :tag => tag, :time => time, :record => record } } } end ## now bulk index @es.bulk :index => self.index, :body => bulk_items end |