logstash-output-awslogs 0.1.30 → 1.1.1
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/DEVELOPER.md +0 -0
- data/Gemfile +2 -1
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/lib/logstash/outputs/awslogs.rb +30 -39
- data/logstash-output-awslogs.gemspec +4 -3
- metadata +38 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e70a243f0906f2799aab77d0dbf1f29b7e07c6bea94485c37aa681dccf8b8f
|
4
|
+
data.tar.gz: 0f1621ab83b6955c5844857a82e58ec03581dbc0782c345d63cb4a9665dbd09f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9dbad4911570e8f125209a616f91ec835b2b7b339041068d7521db71c220058a11da0853b0108df0201d8c59656383f427ca450f4610f584d0298b548f1ed5d
|
7
|
+
data.tar.gz: 47fd4a9f146e9c42051b3744164f64d6cbfd3c651e4c7128926f9e48035a097ac9824d171c668edd03b357b65b8fbfee4d3a0c7305328ece96129135dafc33a5
|
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/DEVELOPER.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
@@ -4,10 +4,10 @@ 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
9
|
Aws.eager_autoload!
|
9
10
|
|
10
|
-
# An awslogs output that does nothing.
|
11
11
|
class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
12
12
|
include LogStash::PluginMixins::AwsConfig::V2
|
13
13
|
|
@@ -18,19 +18,16 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
18
18
|
config :log_stream_name, validate: :string, required: true
|
19
19
|
|
20
20
|
public
|
21
|
-
|
22
21
|
def register
|
23
22
|
@client = Aws::CloudWatchLogs::Client.new(aws_options_hash)
|
24
23
|
@next_sequence_tokens = {}
|
25
24
|
end # def register
|
26
25
|
|
27
26
|
public
|
28
|
-
|
29
|
-
def multi_receive_encoded(events_and_encoded)
|
27
|
+
def multi_receive(events)
|
30
28
|
to_send = {}
|
31
|
-
sequence_tokens = {}
|
32
29
|
|
33
|
-
|
30
|
+
events.each do |event|
|
34
31
|
event_log_stream_name = event.sprintf(log_stream_name)
|
35
32
|
event_log_group_name = event.sprintf(log_group_name)
|
36
33
|
|
@@ -38,17 +35,10 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
38
35
|
unless to_send.keys.include? next_sequence_token_key
|
39
36
|
to_send.store(next_sequence_token_key, [])
|
40
37
|
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
|
38
|
+
to_send[next_sequence_token_key].push(
|
39
|
+
timestamp: (event.timestamp.time.to_f * 1000).to_int,
|
40
|
+
message: event.to_hash.sort.to_h.to_json
|
41
|
+
)
|
52
42
|
end
|
53
43
|
|
54
44
|
|
@@ -57,6 +47,8 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
57
47
|
event_log_stream_name = event_log_names[1]
|
58
48
|
next_sequence_token_key = [event_log_group_name, event_log_stream_name]
|
59
49
|
|
50
|
+
log_events.sort_by!{ |event| event[:timestamp] }
|
51
|
+
|
60
52
|
ident_opts = {
|
61
53
|
log_group_name: event_log_group_name,
|
62
54
|
log_stream_name: event_log_stream_name
|
@@ -64,32 +56,31 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
|
|
64
56
|
send_opts = ident_opts.merge(
|
65
57
|
log_events: log_events
|
66
58
|
)
|
67
|
-
|
68
59
|
if @next_sequence_tokens.keys.include? next_sequence_token_key
|
69
60
|
send_opts[:sequence_token] = @next_sequence_tokens[next_sequence_token_key]
|
61
|
+
end
|
62
|
+
begin
|
63
|
+
resp = @client.put_log_events(send_opts)
|
64
|
+
@next_sequence_tokens.store(next_sequence_token_key, resp.next_sequence_token)
|
65
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceNotFoundException
|
66
|
+
@logger.info('Will create log group/stream and retry')
|
67
|
+
begin
|
68
|
+
@client.create_log_group({log_group_name: send_opts[:log_group_name]})
|
69
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException
|
70
|
+
@logger.info("Log group #{send_opts[:log_group_name]} already exists")
|
71
|
+
end
|
70
72
|
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
|
73
|
+
@client.create_log_stream({log_group_name: send_opts[:log_group_name], log_stream_name: send_opts[:log_stream_name]})
|
74
|
+
rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException
|
75
|
+
@logger.info("Log stream #{send_opts[:log_stream_name]} already exists")
|
92
76
|
end
|
77
|
+
retry
|
78
|
+
rescue Aws::CloudWatchLogs::Errors::InvalidSequenceTokenException => e
|
79
|
+
send_opts[:sequence_token] = e.expected_sequence_token
|
80
|
+
retry
|
81
|
+
rescue Aws::CloudWatchLogs::Errors::ThrottlingException
|
82
|
+
@logger.info('Logs throttling, retry')
|
83
|
+
retry
|
93
84
|
end
|
94
85
|
end
|
95
86
|
end # def multi_receive_encodeds
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-awslogs'
|
3
|
-
s.version = '
|
3
|
+
s.version = '1.1.1'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = 'Writes events to AWS CloudWatch logs.'
|
6
|
-
s.homepage = 'https://github.com/
|
6
|
+
s.homepage = 'https://github.com/Anarhyst266/logstash-output-awslogs'
|
7
7
|
s.authors = ['Anton Klyba']
|
8
8
|
s.email = 'anarhyst266+gems@gmail.com'
|
9
9
|
s.require_paths = ['lib']
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
# Gem dependencies
|
20
20
|
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
21
21
|
s.add_runtime_dependency "logstash-codec-plain"
|
22
|
-
s.add_runtime_dependency 'logstash-mixin-aws', '>= 4.3.0'
|
23
22
|
s.add_runtime_dependency "aws-sdk-cloudwatchlogs", '~> 1'
|
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,86 +1,100 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-awslogs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Klyba
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core-plugin-api
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - "~>"
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '2.0'
|
19
|
-
name: logstash-core-plugin-api
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: logstash-codec-plain
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
|
-
name: logstash-codec-plain
|
34
|
-
prerelease: false
|
35
34
|
type: :runtime
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk-cloudwatchlogs
|
42
43
|
requirement: !ruby/object:Gem::Requirement
|
43
44
|
requirements:
|
44
|
-
- - "
|
45
|
+
- - "~>"
|
45
46
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
|
47
|
+
version: '1'
|
48
|
+
type: :runtime
|
48
49
|
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: logstash-integration-aws
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
49
62
|
type: :runtime
|
63
|
+
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
56
71
|
requirement: !ruby/object:Gem::Requirement
|
57
72
|
requirements:
|
58
|
-
- - "
|
73
|
+
- - ">="
|
59
74
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
61
|
-
name: aws-sdk-cloudwatchlogs
|
62
|
-
prerelease: false
|
75
|
+
version: '0'
|
63
76
|
type: :runtime
|
77
|
+
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
84
|
+
name: logstash-devutils
|
70
85
|
requirement: !ruby/object:Gem::Requirement
|
71
86
|
requirements:
|
72
87
|
- - ">="
|
73
88
|
- !ruby/object:Gem::Version
|
74
89
|
version: '0'
|
75
|
-
name: logstash-devutils
|
76
|
-
prerelease: false
|
77
90
|
type: :development
|
91
|
+
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
|
-
description:
|
97
|
+
description:
|
84
98
|
email: anarhyst266+gems@gmail.com
|
85
99
|
executables: []
|
86
100
|
extensions: []
|
@@ -94,13 +108,13 @@ files:
|
|
94
108
|
- README.md
|
95
109
|
- lib/logstash/outputs/awslogs.rb
|
96
110
|
- logstash-output-awslogs.gemspec
|
97
|
-
homepage: https://github.com/
|
111
|
+
homepage: https://github.com/Anarhyst266/logstash-output-awslogs
|
98
112
|
licenses:
|
99
113
|
- Apache-2.0
|
100
114
|
metadata:
|
101
115
|
logstash_plugin: 'true'
|
102
116
|
logstash_group: output
|
103
|
-
post_install_message:
|
117
|
+
post_install_message:
|
104
118
|
rdoc_options: []
|
105
119
|
require_paths:
|
106
120
|
- lib
|
@@ -115,9 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
129
|
- !ruby/object:Gem::Version
|
116
130
|
version: '0'
|
117
131
|
requirements: []
|
118
|
-
|
119
|
-
|
120
|
-
signing_key:
|
132
|
+
rubygems_version: 3.0.3.1
|
133
|
+
signing_key:
|
121
134
|
specification_version: 4
|
122
135
|
summary: Writes events to AWS CloudWatch logs.
|
123
136
|
test_files: []
|