logstash-output-awslogs 1.1.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTORS +1 -0
- data/Gemfile +2 -1
- data/lib/logstash/outputs/awslogs.rb +30 -40
- data/logstash-output-awslogs.gemspec +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f29bdc8b680f033bac338ae4613bc72e73403fbc7664c4c8eba78a0f497fdf3
|
4
|
+
data.tar.gz: 9b1e38924b1a1994ef71b69a4475f01d99e72345182b5aa1e8a0194b84cf98d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9900328521269d53376e645216989c7c01647f26c1290b8dc88edd5732521a0555fadeb00ad0f4b9674c8b5336b6b550bf62715e92e3be5cd4ec3b5142292cca
|
7
|
+
data.tar.gz: 51d83fb4c44a8850b848dbc4900f96db80c0fa2521b7b9cf4726bfed3cf97ef7cb72d45ea69413d8f54062fc81773789d58c07177349690fa3766f9b92a7c548
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTORS
CHANGED
@@ -3,6 +3,7 @@ reports, or in general have helped logstash along its way.
|
|
3
3
|
|
4
4
|
Contributors:
|
5
5
|
* - Ricky Cook (rickycook)
|
6
|
+
* - Anton Klyba (anarhyst266)
|
6
7
|
|
7
8
|
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
9
|
Logstash, and you aren't on the list above and want to be, please let us know
|
data/Gemfile
CHANGED
@@ -4,10 +4,9 @@ require 'logstash/outputs/base'
|
|
4
4
|
require 'logstash/namespace'
|
5
5
|
require 'logstash/plugin_mixins/aws_config'
|
6
6
|
require 'aws-sdk-cloudwatchlogs'
|
7
|
+
require 'json'
|
7
8
|
|
8
|
-
Aws.eager_autoload!
|
9
9
|
|
10
|
-
# An awslogs output that does nothing.
|
11
10
|
class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
12
11
|
include LogStash::PluginMixins::AwsConfig::V2
|
13
12
|
|
@@ -18,19 +17,16 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
18
17
|
config :log_stream_name, validate: :string, required: true
|
19
18
|
|
20
19
|
public
|
21
|
-
|
22
20
|
def register
|
23
21
|
@client = Aws::CloudWatchLogs::Client.new(aws_options_hash)
|
24
22
|
@next_sequence_tokens = {}
|
25
23
|
end # def register
|
26
24
|
|
27
25
|
public
|
28
|
-
|
29
|
-
def multi_receive_encoded(events_and_encoded)
|
26
|
+
def multi_receive(events)
|
30
27
|
to_send = {}
|
31
|
-
sequence_tokens = {}
|
32
28
|
|
33
|
-
|
29
|
+
events.each do |event|
|
34
30
|
event_log_stream_name = event.sprintf(log_stream_name)
|
35
31
|
event_log_group_name = event.sprintf(log_group_name)
|
36
32
|
|
@@ -38,17 +34,10 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
38
34
|
unless to_send.keys.include? next_sequence_token_key
|
39
35
|
to_send.store(next_sequence_token_key, [])
|
40
36
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
)
|
46
|
-
else
|
47
|
-
to_send[next_sequence_token_key].push(
|
48
|
-
timestamp: (event.timestamp.time.to_f * 1000).to_int,
|
49
|
-
message: encoded
|
50
|
-
)
|
51
|
-
end
|
37
|
+
to_send[next_sequence_token_key].push(
|
38
|
+
timestamp: (event.timestamp.time.to_f * 1000).to_int,
|
39
|
+
message: event.to_hash.sort.to_h.to_json
|
40
|
+
)
|
52
41
|
end
|
53
42
|
|
54
43
|
|
@@ -57,6 +46,8 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
57
46
|
event_log_stream_name = event_log_names[1]
|
58
47
|
next_sequence_token_key = [event_log_group_name, event_log_stream_name]
|
59
48
|
|
49
|
+
log_events.sort_by!{ |event| event[:timestamp] }
|
50
|
+
|
60
51
|
ident_opts = {
|
61
52
|
log_group_name: event_log_group_name,
|
62
53
|
log_stream_name: event_log_stream_name
|
@@ -64,32 +55,31 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
64
55
|
send_opts = ident_opts.merge(
|
65
56
|
log_events: log_events
|
66
57
|
)
|
67
|
-
|
68
58
|
if @next_sequence_tokens.keys.include? next_sequence_token_key
|
69
59
|
send_opts[:sequence_token] = @next_sequence_tokens[next_sequence_token_key]
|
60
|
+
end
|
61
|
+
begin
|
62
|
+
resp = @client.put_log_events(send_opts)
|
63
|
+
@next_sequence_tokens.store(next_sequence_token_key, resp.next_sequence_token)
|
64
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceNotFoundException
|
65
|
+
@logger.info('Will create log group/stream and retry')
|
66
|
+
begin
|
67
|
+
@client.create_log_group({log_group_name: send_opts[:log_group_name]})
|
68
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException
|
69
|
+
@logger.info("Log group #{send_opts[:log_group_name]} already exists")
|
70
|
+
end
|
70
71
|
begin
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@logger.info('Will create log group/stream and retry')
|
75
|
-
begin
|
76
|
-
@client.create_log_group({log_group_name: send_opts[:log_group_name]})
|
77
|
-
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException => e
|
78
|
-
@logger.info("Log group #{send_opts[:log_group_name]} already exists")
|
79
|
-
end
|
80
|
-
begin
|
81
|
-
@client.create_log_stream({log_group_name: send_opts[:log_group_name], log_stream_name: send_opts[:log_stream_name]})
|
82
|
-
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException => e
|
83
|
-
@logger.info("Log stream #{send_opts[:log_stream_name]} already exists")
|
84
|
-
end
|
85
|
-
retry
|
86
|
-
rescue Aws::CloudWatchLogs::Errors::InvalidSequenceTokenException => e
|
87
|
-
send_opts[:sequence_token] = e.expected_sequence_token
|
88
|
-
retry
|
89
|
-
rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
|
90
|
-
@logger.info('Logs throttling, retry')
|
91
|
-
retry
|
72
|
+
@client.create_log_stream({log_group_name: send_opts[:log_group_name], log_stream_name: send_opts[:log_stream_name]})
|
73
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException
|
74
|
+
@logger.info("Log stream #{send_opts[:log_stream_name]} already exists")
|
92
75
|
end
|
76
|
+
retry
|
77
|
+
rescue Aws::CloudWatchLogs::Errors::InvalidSequenceTokenException => e
|
78
|
+
send_opts[:sequence_token] = e.expected_sequence_token
|
79
|
+
retry
|
80
|
+
rescue Aws::CloudWatchLogs::Errors::ThrottlingException
|
81
|
+
@logger.info('Logs throttling, retry')
|
82
|
+
retry
|
93
83
|
end
|
94
84
|
end
|
95
85
|
end # def multi_receive_encodeds
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-awslogs'
|
3
|
-
s.version = '1.1.
|
3
|
+
s.version = '1.1.2'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = 'Writes events to AWS CloudWatch logs.'
|
6
6
|
s.homepage = 'https://github.com/Anarhyst266/logstash-output-awslogs'
|
@@ -21,5 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency "logstash-codec-plain"
|
22
22
|
s.add_runtime_dependency "aws-sdk-cloudwatchlogs", '~> 1'
|
23
23
|
s.add_runtime_dependency "logstash-integration-aws"
|
24
|
+
s.add_runtime_dependency "json"
|
24
25
|
s.add_development_dependency "logstash-devutils"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-awslogs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Klyba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core-plugin-api
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: logstash-devutils
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|