logstash-output-awslogs 0.1.18 → 0.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/outputs/awslogs.rb +33 -14
- data/logstash-output-awslogs.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b230422347a67d44cc5a3277e024f0935866278c754396142f3cb6b1c0d6a4d
|
4
|
+
data.tar.gz: fff343b28f5fcb63a47f1ceaa5da80014d2be023fd06addbe4b1cd9c797901d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b827cfe658efb98103088f829d7d5ae147171d0d1bd1656c50ab1364ffd708bd411fb372226d293653c59937729984676a57e6db16874afc4f7d12c59b0650e
|
7
|
+
data.tar.gz: 637271353ffdef124f9133cce332635225620b3d8a32aeae69cb5a32a6e723c8dcf0ac443f3560ad467e04df77e603610c41516ce5d55360cba3d63dca3e8703
|
@@ -30,7 +30,7 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
30
30
|
to_send = {}
|
31
31
|
sequence_tokens = {}
|
32
32
|
|
33
|
-
events_and_encoded.each do |event,
|
33
|
+
events_and_encoded.each do |event, encoded|
|
34
34
|
event_log_stream_name = event.sprintf(log_stream_name)
|
35
35
|
event_log_group_name = event.sprintf(log_group_name)
|
36
36
|
|
@@ -38,31 +38,48 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
38
38
|
unless to_send.keys.include? next_sequence_token_key
|
39
39
|
to_send.store(next_sequence_token_key, [])
|
40
40
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
if event.get('message').empty?
|
42
|
+
to_send[next_sequence_token_key].push(
|
43
|
+
timestamp: (event.timestamp.time.to_f * 1000).to_int,
|
44
|
+
message: encoded
|
45
|
+
)
|
46
|
+
else
|
47
|
+
to_send[next_sequence_token_key].push(
|
48
|
+
timestamp: (event.timestamp.time.to_f * 1000).to_int,
|
49
|
+
message: event.get('message')
|
50
|
+
)
|
51
|
+
end
|
45
52
|
end
|
46
53
|
|
54
|
+
group_names = []
|
47
55
|
to_send.each do |event_log_names, _events|
|
48
56
|
event_log_group_name = event_log_names[0]
|
49
|
-
|
57
|
+
event_log_stream_name = event_log_names[1]
|
58
|
+
next_sequence_token_key = [event_log_group_name, event_log_stream_name]
|
59
|
+
next if @next_sequence_tokens.keys.include? next_sequence_token_key
|
60
|
+
unless group_names.include? event_log_group_name
|
61
|
+
group_names.push(event_log_group_name)
|
62
|
+
end
|
63
|
+
end
|
50
64
|
|
51
|
-
|
65
|
+
group_names.each do |log_group_name|
|
66
|
+
unless sequence_tokens.keys.include? log_group_name
|
67
|
+
sequence_tokens.store(log_group_name, {})
|
68
|
+
end
|
52
69
|
begin
|
53
|
-
@client.describe_log_streams({log_group_name:
|
70
|
+
@client.describe_log_streams({log_group_name: log_group_name}).each do |response|
|
54
71
|
response.log_streams.each do |log_stream_data|
|
55
|
-
unless log_stream_data.upload_sequence_token
|
56
|
-
sequence_tokens[
|
72
|
+
unless log_stream_data.upload_sequence_token&.empty?
|
73
|
+
sequence_tokens[log_group_name][log_stream_data.log_stream_name.to_s] = log_stream_data.upload_sequence_token.to_s
|
57
74
|
end
|
58
75
|
end
|
59
76
|
end
|
60
77
|
rescue Aws::CloudWatchLogs::Errors::ResourceNotFoundException => e
|
61
|
-
@logger.info(
|
78
|
+
@logger.info("Will create log group #{log_group_name} and retry")
|
62
79
|
begin
|
63
|
-
@client.create_log_group({log_group_name:
|
80
|
+
@client.create_log_group({log_group_name: log_group_name})
|
64
81
|
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException => e
|
65
|
-
@logger.info("Log group #{
|
82
|
+
@logger.info("Log group #{log_group_name} already exists")
|
66
83
|
end
|
67
84
|
retry
|
68
85
|
rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
|
@@ -86,7 +103,7 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
86
103
|
|
87
104
|
if @next_sequence_tokens.keys.include? next_sequence_token_key
|
88
105
|
send_opts[:sequence_token] = @next_sequence_tokens[next_sequence_token_key]
|
89
|
-
elsif
|
106
|
+
elsif !sequence_tokens[event_log_group_name][event_log_stream_name]&.empty?
|
90
107
|
send_opts[:sequence_token] = sequence_tokens[event_log_group_name][event_log_stream_name]
|
91
108
|
else
|
92
109
|
begin
|
@@ -107,6 +124,8 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
107
124
|
rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
|
108
125
|
@logger.info('Creating log streams throttling, retry')
|
109
126
|
retry
|
127
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException => e
|
128
|
+
@logger.info("Log stream #{send_opts[:log_stream_name]} already exists")
|
110
129
|
end
|
111
130
|
end
|
112
131
|
begin
|