File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,6 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
129
129
130
130
# Enable tracking the value of a given field to be used as a cursor
131
131
# TODO: main concerns
132
- # * schedule overlap needs to be disabled (hardcoded as enabled)
133
132
# * using anything other than _event.timestamp easily leads to data loss
134
133
# * the first "synchronization run can take a long time"
135
134
# * checkpointing is only safe to do after each run (not per document)
@@ -271,7 +270,7 @@ class LogStash::Inputs::Elasticsearch < LogStash::Inputs::Base
271
270
272
271
# Allow scheduled runs to overlap (enabled by default). Setting to false will
273
272
# only start a new scheduled run after the previous one completes.
274
- config :schedule_overlap , :validate => :string
273
+ config :schedule_overlap , :validate => :boolean
275
274
276
275
# If set, the _source of each hit will be added nested under the target instead of at the top-level
277
276
config :target , :validate => :field_reference
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ def checkpoint_cursor
35
35
36
36
def converge_last_value
37
37
return if @last_value_hashmap . empty?
38
- # TODO this implicitly assumes that the way to converge the value among slices is to pick the highest and we can't assume that
39
- new_last_value = @last_value_hashmap . reduceValues ( 1 , lambda { | v1 , v2 | Time . parse ( v1 ) < Time . parse ( v2 ) ? v2 : v1 } )
38
+ new_last_value = @last_value_hashmap . reduceValues ( 1000 , lambda { | v1 , v2 | Java :: java . time . Instant . parse ( v1 ) . isBefore ( Java :: java . time . Instant . parse ( v2 ) ) ? v2 : v1 } )
39
+ logger . trace? && logger . trace ( "converge_last_value: got #{ @last_value_hashmap . values . inspect } . won: #{ new_last_value } " )
40
40
return if new_last_value == @last_value
41
41
@last_value = new_last_value
42
42
logger . info "New cursor value for field \" #{ @tracking_field } \" is: #{ new_last_value } "
@@ -49,7 +49,10 @@ def record_last_value(event)
49
49
end
50
50
51
51
def inject_cursor ( query_json )
52
- query_json . gsub ( ":last_value" , @last_value . to_s )
52
+ # ":present" means "now - 30s" to avoid grabbing partially visible data in the PIT
53
+ result = query_json . gsub ( ":last_value" , @last_value . to_s ) . gsub ( ":present" , Java ::java . time . Instant . now . minusSeconds ( 30 ) . to_s )
54
+ logger . debug ( "inject_cursor: injected values for ':last_value' and ':present'" , :query => result )
55
+ result
53
56
end
54
57
end
55
58
end ; end ; end
You can’t perform that action at this time.
0 commit comments