@@ -74,6 +74,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
74
74
require 'logstash/inputs/elasticsearch/paginated_search'
75
75
require 'logstash/inputs/elasticsearch/aggregation'
76
76
require 'logstash/inputs/elasticsearch/cursor_tracker'
77
+ require 'logstash/inputs/elasticsearch/esql'
77
78
78
79
include LogStash ::PluginMixins ::ECSCompatibilitySupport ( :disabled , :v1 , :v8 => :v1 )
79
80
include LogStash ::PluginMixins ::ECSCompatibilitySupport ::TargetCheck
@@ -125,20 +126,6 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
125
126
# by this pipeline input.
126
127
config :slices , :validate => :number
127
128
128
- # Enable tracking the value of a given field to be used as a cursor
129
- # Main concerns:
130
- # * using anything other than _event.timestamp easily leads to data loss
131
- # * the first "synchronization run can take a long time"
132
- config :tracking_field , :validate => :string
133
-
134
- # Define the initial seed value of the tracking_field
135
- config :tracking_field_seed , :validate => :string , :default => "1970-01-01T00:00:00.000000000Z"
136
-
137
- # The location of where the tracking field value will be stored
138
- # The value is persisted after each scheduled run (and not per result)
139
- # If it's not set it defaults to '${path.data}/plugins/inputs/elasticsearch/<pipeline_id>/last_run_value'
140
- config :last_run_metadata_path , :validate => :string
141
-
142
129
# If set, include Elasticsearch document information such as index, type, and
143
130
# the id in the event.
144
131
#
@@ -265,10 +252,6 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
265
252
# exactly once.
266
253
config :schedule , :validate => :string
267
254
268
- # Allow scheduled runs to overlap (enabled by default). Setting to false will
269
- # only start a new scheduled run after the previous one completes.
270
- config :schedule_overlap , :validate => :boolean
271
-
272
255
# If set, the _source of each hit will be added nested under the target instead of at the top-level
273
256
config :target , :validate => :field_reference
274
257
@@ -347,30 +330,16 @@ def register
347
330
348
331
setup_query_executor
349
332
350
- setup_cursor_tracker
351
-
352
333
@client
353
334
end
354
335
355
336
def run ( output_queue )
356
337
if @schedule
357
- scheduler . cron ( @schedule , :overlap => @schedule_overlap ) do
358
- @query_executor . do_run ( output_queue , get_query_object ( ) )
359
- end
338
+ scheduler . cron ( @schedule ) { @query_executor . do_run ( output_queue ) }
360
339
scheduler . join
361
340
else
362
- @query_executor . do_run ( output_queue , get_query_object ( ) )
363
- end
364
- end
365
-
366
- def get_query_object
367
- if @cursor_tracker
368
- query = @cursor_tracker . inject_cursor ( @query )
369
- @logger . debug ( "new query is #{ query } " )
370
- else
371
- query = @query
341
+ @query_executor . do_run ( output_queue )
372
342
end
373
- LogStash ::Json . load ( query )
374
343
end
375
344
376
345
##
@@ -380,11 +349,6 @@ def push_hit(hit, output_queue, root_field = '_source')
380
349
event = event_from_hit ( hit , root_field )
381
350
decorate ( event )
382
351
output_queue << event
383
- record_last_value ( event )
384
- end
385
-
386
- def record_last_value ( event )
387
- @cursor_tracker . record_last_value ( event ) if @tracking_field
388
352
end
389
353
390
354
def event_from_hit ( hit , root_field )
@@ -678,28 +642,6 @@ def setup_query_executor
678
642
end
679
643
end
680
644
681
- def setup_cursor_tracker
682
- return unless @tracking_field
683
- return unless @query_executor . is_a? ( LogStash ::Inputs ::Elasticsearch ::SearchAfter )
684
-
685
- if @resolved_search_api != "search_after" || @response_type != "hits"
686
- raise ConfigurationError . new ( "The `tracking_field` feature can only be used with `search_after` non-aggregation queries" )
687
- end
688
-
689
- @cursor_tracker = CursorTracker . new ( last_run_metadata_path : last_run_metadata_path ,
690
- tracking_field : @tracking_field ,
691
- tracking_field_seed : @tracking_field_seed )
692
- @query_executor . cursor_tracker = @cursor_tracker
693
- end
694
-
695
- def last_run_metadata_path
696
- return @last_run_metadata_path if @last_run_metadata_path
697
-
698
- last_run_metadata_path = ::File . join ( LogStash ::SETTINGS . get_value ( "path.data" ) , "plugins" , "inputs" , "elasticsearch" , pipeline_id , "last_run_value" )
699
- FileUtils . mkdir_p ::File . dirname ( last_run_metadata_path )
700
- last_run_metadata_path
701
- end
702
-
703
645
def get_transport_client_class
704
646
# LS-core includes `elasticsearch` gem. The gem is composed of two separate gems: `elasticsearch-api` and `elasticsearch-transport`
705
647
# And now `elasticsearch-transport` is old, instead we have `elastic-transport`.
0 commit comments