mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
- small refactor improves performance 2x
This commit is contained in:
parent
d85da86fca
commit
ba8c230b6c
1 changed files with 2 additions and 11 deletions
|
@ -151,21 +151,13 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
||||||
public
|
public
|
||||||
def receive(event)
|
def receive(event)
|
||||||
return unless output?(event)
|
return unless output?(event)
|
||||||
buffer_receive([event, index, type])
|
buffer_receive([event, event.sprintf(@index), event.sprintf(@index_type)])
|
||||||
end # def receive
|
end # def receive
|
||||||
|
|
||||||
def flush(events, teardown=false)
|
def flush(events, teardown=false)
|
||||||
request = @client.bulk
|
request = @client.bulk
|
||||||
events.each do |event, index, type|
|
events.each do |event, index, type|
|
||||||
index = event.sprintf(@index)
|
type = "logs" if type.empty?
|
||||||
|
|
||||||
# Set the 'type' value for the index.
|
|
||||||
if @index_type.nil?
|
|
||||||
type = event["type"] || "logs"
|
|
||||||
else
|
|
||||||
type = event.sprintf(@index_type)
|
|
||||||
end
|
|
||||||
|
|
||||||
if @document_id
|
if @document_id
|
||||||
request.index(index, type, event.sprintf(@document_id), event.to_json)
|
request.index(index, type, event.sprintf(@document_id), event.to_json)
|
||||||
else
|
else
|
||||||
|
@ -173,7 +165,6 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on(:success) { }
|
|
||||||
request.execute
|
request.execute
|
||||||
end # def flush
|
end # def flush
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue