From 4dfe88894d185cd43aa902f974c66bb5873b1959 Mon Sep 17 00:00:00 2001 From: Peak Xu Date: Fri, 5 Jun 2015 15:12:24 -0400 Subject: [PATCH] Filter out the log stream which have event timestamps which specify a non-overlapping interval with the period of interest --- lib/cwlogs-s3/command.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/cwlogs-s3/command.rb b/lib/cwlogs-s3/command.rb index 0aa06be..4af22d6 100644 --- a/lib/cwlogs-s3/command.rb +++ b/lib/cwlogs-s3/command.rb @@ -33,8 +33,13 @@ def execute log_group_name: command_options[:group], ) + start_ms = start.to_i * 1000 + end_ms = ending.to_i * 1000 + resp.each do |streams| streams[:log_streams].each do |stream| + next if stream[:last_event_timestamp] < start_ms + next if end_ms < stream[:first_event_timestamp] @stream_list.push stream[:log_stream_name] end end @@ -48,8 +53,8 @@ def execute resp = @cwl.get_log_events( log_group_name: command_options[:group], log_stream_name: stream, - start_time: start.to_i * 1000, - end_time: ending.to_i * 1000, + start_time: start_ms, + end_time: end_ms, start_from_head: true )