@@ -49,6 +49,10 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
49
49
# similar events to the same 'type'. String expansion `%{foo}` works here.
50
50
config :index_type , :validate => :string
51
51
52
+ # A routing override to be applied to all processed events.
53
+ # This can be dynamic using the `%{foo}` syntax.
54
+ config :routing , :validate => :string
55
+
52
56
# Starting in Logstash 1.3 (unless you set option `manage_template` to false)
53
57
# a default mapping template for Elasticsearch will be applied, if you do not
54
58
# already have one set to match the index pattern defined (default of
@@ -117,7 +121,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
117
121
# Run the Elasticsearch server embedded in this process.
118
122
# This option is useful if you want to run a single Logstash process that
119
123
# handles log processing and indexing; it saves you from needing to run
120
- # a separate Elasticsearch process. An example use case is
124
+ # a separate Elasticsearch process. An example use case is
121
125
# proof-of-concept testing.
122
126
# WARNING: This is not recommended for production use!
123
127
config :embedded , :validate => :boolean , :default => false
@@ -250,7 +254,7 @@ def register
250
254
client_settings [ "network.host" ] = @bind_host if @bind_host
251
255
client_settings [ "transport.tcp.port" ] = @bind_port if @bind_port
252
256
client_settings [ "client.transport.sniff" ] = @sniffing
253
-
257
+
254
258
if @node_name
255
259
client_settings [ "node.name" ] = @node_name
256
260
else
@@ -382,7 +386,7 @@ def get_template
382
386
def receive ( event )
383
387
return unless output? ( event )
384
388
385
- # block until we have not maxed out our
389
+ # block until we have not maxed out our
386
390
# retry queue. This is applying back-pressure
387
391
# to slow down the receive-rate
388
392
@retry_flush_mutex . synchronize {
@@ -393,11 +397,11 @@ def receive(event)
393
397
394
398
# Set the 'type' value for the index.
395
399
type = @index_type ? event . sprintf ( @index_type ) : ( event [ "type" ] || "logs" )
396
-
397
400
index = event . sprintf ( @index )
398
-
399
401
document_id = @document_id ? event . sprintf ( @document_id ) : nil
400
- buffer_receive ( [ event . sprintf ( @action ) , { :_id => document_id , :_index => index , :_type => type } , event ] )
402
+ routing = @routing ? event . sprintf ( @routing ) : nil
403
+
404
+ buffer_receive ( [ event . sprintf ( @action ) , { :_id => document_id , :_index => index , :_type => type , :_routing => routing } , event ] )
401
405
end # def receive
402
406
403
407
public
@@ -447,19 +451,19 @@ def teardown
447
451
448
452
@retry_teardown_requested . make_true
449
453
# First, make sure retry_timer_thread is stopped
450
- # to ensure we do not signal a retry based on
454
+ # to ensure we do not signal a retry based on
451
455
# the retry interval.
452
456
Thread . kill ( @retry_timer_thread )
453
457
@retry_timer_thread . join
454
- # Signal flushing in the case that #retry_flush is in
458
+ # Signal flushing in the case that #retry_flush is in
455
459
# the process of waiting for a signal.
456
460
@retry_flush_mutex . synchronize { @retry_queue_needs_flushing . signal }
457
- # Now, #retry_flush is ensured to not be in a state of
461
+ # Now, #retry_flush is ensured to not be in a state of
458
462
# waiting and can be safely joined into the main thread
459
463
# for further final execution of an in-process remaining call.
460
464
@retry_thread . join
461
465
462
- # execute any final actions along with a proceeding retry for any
466
+ # execute any final actions along with a proceeding retry for any
463
467
# final actions that did not succeed.
464
468
buffer_flush ( :final => true )
465
469
retry_flush
@@ -544,11 +548,11 @@ def generate_jks cert_path
544
548
end
545
549
546
550
private
547
- # in charge of submitting any actions in @retry_queue that need to be
551
+ # in charge of submitting any actions in @retry_queue that need to be
548
552
# retried
549
553
#
550
554
# This method is not called concurrently. It is only called by @retry_thread
551
- # and once that thread is ended during the teardown process, a final call
555
+ # and once that thread is ended during the teardown process, a final call
552
556
# to this method is done upon teardown in the main thread.
553
557
def retry_flush ( )
554
558
unless @retry_queue . empty?
0 commit comments