awful 0.0.113 → 0.0.114
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/cloudwatch_logs.rb +77 -0
- data/lib/awful/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01a6c5c4cfaa87df52056a81a6d9e88f1bd17ee2
|
4
|
+
data.tar.gz: 4e86f9c9696f9045c75859c7ebb4f7bccd48367e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef7957611ed02f45d76b2826fa48ec87379eec54b2aa301f4b12665a0c51d112ba1ec05754d08fdb280e1abcf342c0adaa6b40534c1a42e139fc677ca360f459
|
7
|
+
data.tar.gz: 472d3018fa664a200dbd50616c794f7d786242923435fe48976fb4d05a2963e6c7c4e0ef0f0acd670cb27850fdc4b756b2e6f7f98523fe23ae2ff48080803a67
|
@@ -51,5 +51,82 @@ module Awful
|
|
51
51
|
logs.delete_log_group(log_group_name: name)
|
52
52
|
end
|
53
53
|
|
54
|
+
desc 'streams GROUP [PREFIX]', 'list log streams for GROUP'
|
55
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
56
|
+
method_option :limit, aliases: '-n', default: 50, desc: 'Count to limit returned results'
|
57
|
+
method_option :alpha, aliases: '-a', default: false, desc: 'Order by name'
|
58
|
+
def streams(group, prefix = nil)
|
59
|
+
next_token = nil
|
60
|
+
log_streams = []
|
61
|
+
loop do
|
62
|
+
response = logs.describe_log_streams(
|
63
|
+
log_group_name: group,
|
64
|
+
log_stream_name_prefix: prefix,
|
65
|
+
order_by: options[:alpha] ? 'LogStreamName' : 'LastEventTime',
|
66
|
+
descending: (not options[:alpha]), # want desc order if by time for most recent first
|
67
|
+
limit: options[:limit],
|
68
|
+
next_token: next_token
|
69
|
+
)
|
70
|
+
log_streams = log_streams + response.log_streams
|
71
|
+
next_token = response.next_token
|
72
|
+
break if next_token.nil?
|
73
|
+
break if log_streams.count >= options[:limit].to_i
|
74
|
+
end
|
75
|
+
log_streams.tap do |streams|
|
76
|
+
if options[:long]
|
77
|
+
print_table streams.map { |s| [s.log_stream_name, Time.at(s.last_event_timestamp.to_i/1000)] }
|
78
|
+
else
|
79
|
+
puts streams.map(&:log_stream_name)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
no_commands do
|
85
|
+
def latest_stream(group)
|
86
|
+
logs.describe_log_streams(
|
87
|
+
log_group_name: group,
|
88
|
+
order_by: 'LastEventTime',
|
89
|
+
descending: true,
|
90
|
+
limit: 1
|
91
|
+
).log_streams.first
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
desc 'latest GROUP', 'get name of latest stream for GROUP'
|
96
|
+
def latest(group)
|
97
|
+
latest_stream(group).tap do |stream|
|
98
|
+
puts stream.log_stream_name
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
desc 'events GROUP [STREAM]', 'get log events from given, or latest, stream'
|
103
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
104
|
+
method_option :limit, aliases: '-n', default: 50, desc: 'Count to limit returned results'
|
105
|
+
def events(group, stream = nil)
|
106
|
+
next_token = nil
|
107
|
+
events = []
|
108
|
+
loop do
|
109
|
+
response = logs.get_log_events(
|
110
|
+
log_group_name: group,
|
111
|
+
log_stream_name: stream || latest_stream(group).log_stream_name,
|
112
|
+
start_from_head: true,
|
113
|
+
limit: options[:limit],
|
114
|
+
next_token: next_token
|
115
|
+
)
|
116
|
+
break if response.events.count == 0 # break on no results as token does not get to nil
|
117
|
+
events = events + response.events
|
118
|
+
next_token = response.next_backward_token
|
119
|
+
break if events.count >= options[:limit].to_i
|
120
|
+
break if next_token.nil? # not sure if this is ever set to nil
|
121
|
+
end
|
122
|
+
events.tap do |ev|
|
123
|
+
if options[:long]
|
124
|
+
print_table ev.map { |e| [Time.at(e.timestamp.to_i/1000), e.message] }
|
125
|
+
else
|
126
|
+
puts ev.map(&:message)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
54
131
|
end
|
55
132
|
end
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.114
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|