logstash-output-awslogs 1.1.0 → 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/Gemfile +2 -1
- data/lib/logstash/outputs/awslogs.rb +30 -39
- data/logstash-output-awslogs.gemspec +2 -1
- metadata +15 -1
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/Gemfile
CHANGED
@@ -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,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.1'
|
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,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Klyba
|
@@ -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
|