cloud_watch_logs_poller 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloud_watch_logs_poller/process.rb +24 -4
- data/lib/cloud_watch_logs_poller/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4641f0ec6db0d868154a40d3ac82a525c00d57ad3b51297a2078341397455a85
|
4
|
+
data.tar.gz: 486c7f3b586fbca8b079231df5f8bf979c5112aab5d04110a1ad983adee87570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d9d853b1ee7192cca26901b1f4ae8a72a21652c3935b090f7a98dc757f5abcd7903a65bdf480c5654c5c7596db7520331289383a2a2c92a7bab0840193a989
|
7
|
+
data.tar.gz: f146bb5eb28ce03faf8198ceed4df78db65ea57e8d716d0096dc19b09b3c325c1405482fa91c5eaad5a8d319dfb209acc18e6fff787b5d88b93ba67c0b8e7332
|
@@ -4,7 +4,7 @@ module CloudWatchLogsPoller
|
|
4
4
|
@client = Aws::CloudWatchLogs::Client.new
|
5
5
|
@interval = interval
|
6
6
|
@debug = debug
|
7
|
-
@
|
7
|
+
@event_ids_by_timestamp = {}
|
8
8
|
end
|
9
9
|
|
10
10
|
def execute(log_group_name:, log_stream_name_prefix: nil, filter_pattern: nil, start_time: Time.now, &block)
|
@@ -16,24 +16,37 @@ module CloudWatchLogsPoller
|
|
16
16
|
interleaved: true
|
17
17
|
}
|
18
18
|
|
19
|
+
debug_log("start_time = #{params[:start_time]}")
|
20
|
+
|
19
21
|
loop do
|
20
22
|
loop do
|
21
23
|
result = @client.filter_log_events(params)
|
22
24
|
result.events.each do |event|
|
23
|
-
|
25
|
+
timestamp = event.timestamp&.to_i
|
26
|
+
event_id = event.event_id
|
27
|
+
|
28
|
+
debug_log("timestamp = #{timestamp}")
|
24
29
|
|
25
|
-
@
|
30
|
+
@event_ids_by_timestamp[timestamp] ||= Set.new
|
31
|
+
next if @event_ids_by_timestamp[timestamp].include?(event_id)
|
32
|
+
|
33
|
+
@event_ids_by_timestamp[timestamp] << event_id
|
26
34
|
block.call(Event.convert_from_filtered_log_event(event))
|
27
35
|
end
|
28
36
|
|
29
37
|
debug_log(params)
|
30
|
-
debug_log(result)
|
31
38
|
|
39
|
+
@event_ids_by_timestamp = get_latest_events_and_timestamp
|
32
40
|
break unless result.next_token
|
33
41
|
|
34
42
|
params[:next_token] = result.next_token
|
35
43
|
end
|
36
44
|
|
45
|
+
newest_timestamp = @event_ids_by_timestamp.keys.max
|
46
|
+
params[:start_time] = newest_timestamp unless newest_timestamp.nil?
|
47
|
+
params[:next_token] = nil
|
48
|
+
@event_ids_by_timestamp = {}
|
49
|
+
|
37
50
|
sleep(@interval)
|
38
51
|
end
|
39
52
|
rescue Interrupt
|
@@ -42,6 +55,13 @@ module CloudWatchLogsPoller
|
|
42
55
|
|
43
56
|
private
|
44
57
|
|
58
|
+
def get_latest_events_and_timestamp
|
59
|
+
newest_timestamp = @event_ids_by_timestamp.keys.max
|
60
|
+
return {} if newest_timestamp.nil?
|
61
|
+
|
62
|
+
{newest_timestamp => @event_ids_by_timestamp[newest_timestamp]}
|
63
|
+
end
|
64
|
+
|
45
65
|
def debug_log(message)
|
46
66
|
return unless @debug
|
47
67
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_watch_logs_poller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takahiro Ooishi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-cloudwatchlogs
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.1.2
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Polling Cloud Watch Logs
|