fluent-plugin-cloudwatch-logs 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f405e2301a22e37b9768748f88df73b9ecba6e1b5311f78992c9117b45da95f8
|
4
|
+
data.tar.gz: 51973be01ee296b0fcb5f7abb26605c0f67385fea4449b7bc301281667185406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0439979ebd2e1e4d5bc8876ad652a1c790ff311f6857bfcf7f9a9d1748d66bea5acb01944939947ac8d1171d76faaadd40b6bf7238c32eef61efb995aa067087'
|
7
|
+
data.tar.gz: b6de5f1d520370a5a2fadba7da8960a11b3ded740155d7f6efa05db686a30bc3ed6e854274ed968ecd4a421dcbef6b01dccc259e5daa9dce3ca5570b4668163e
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Ryota Arai"]
|
10
10
|
spec.email = ["ryota.arai@gmail.com"]
|
11
11
|
spec.summary = %q{CloudWatch Logs Plugin for Fluentd}
|
12
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.homepage = "https://github.com/fluent-plugins-nursery/fluent-plugin-cloudwatch-logs"
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -4,6 +4,7 @@ require 'yajl'
|
|
4
4
|
|
5
5
|
module Fluent::Plugin
|
6
6
|
class CloudwatchLogsOutput < Output
|
7
|
+
include Fluent::MessagePackFactory::Mixin
|
7
8
|
Fluent::Plugin.register_output('cloudwatch_logs', self)
|
8
9
|
|
9
10
|
helpers :compat_parameters, :inject
|
@@ -12,6 +13,7 @@ module Fluent::Plugin
|
|
12
13
|
|
13
14
|
config_param :aws_key_id, :string, :default => nil, :secret => true
|
14
15
|
config_param :aws_sec_key, :string, :default => nil, :secret => true
|
16
|
+
config_param :aws_instance_profile_credentials_retries, :integer, default: nil
|
15
17
|
config_param :aws_use_sts, :bool, default: false
|
16
18
|
config_param :aws_sts_role_arn, :string, default: nil
|
17
19
|
config_param :aws_sts_session_name, :string, default: 'fluentd'
|
@@ -83,6 +85,7 @@ module Fluent::Plugin
|
|
83
85
|
options = {}
|
84
86
|
options[:region] = @region if @region
|
85
87
|
options[:endpoint] = @endpoint if @endpoint
|
88
|
+
options[:instance_profile_credentials_retries] = @aws_instance_profile_credentials_retries if @aws_instance_profile_credentials_retries
|
86
89
|
|
87
90
|
if @aws_use_sts
|
88
91
|
Aws.config[:region] = options[:region]
|
@@ -108,7 +111,7 @@ module Fluent::Plugin
|
|
108
111
|
|
109
112
|
def format(tag, time, record)
|
110
113
|
record = inject_values_to_record(tag, time, record)
|
111
|
-
[tag, time, record].
|
114
|
+
msgpack_packer.pack([tag, time, record]).to_s
|
112
115
|
end
|
113
116
|
|
114
117
|
def formatted_to_msgpack_binary?
|
@@ -208,7 +211,7 @@ module Fluent::Plugin
|
|
208
211
|
|
209
212
|
events = []
|
210
213
|
rs.each do |t, time, record|
|
211
|
-
time_ms = time * 1000
|
214
|
+
time_ms = (time.to_f * 1000).floor
|
212
215
|
|
213
216
|
scrub_record!(record)
|
214
217
|
if @message_keys
|
@@ -50,6 +50,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
50
50
|
time = event_time
|
51
51
|
d.run(default_tag: fluentd_tag, flush: true) do
|
52
52
|
d.feed(time, {'cloudwatch' => 'logs1'})
|
53
|
+
# Addition converts EventTime to seconds
|
53
54
|
d.feed(time + 1, {'cloudwatch' => 'logs2'})
|
54
55
|
end
|
55
56
|
|
@@ -58,12 +59,12 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
58
59
|
logs = d.logs
|
59
60
|
events = get_log_events
|
60
61
|
assert_equal(2, events.size)
|
61
|
-
assert_equal(time.
|
62
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
62
63
|
assert_equal('{"cloudwatch":"logs1"}', events[0].message)
|
63
64
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
64
65
|
assert_equal('{"cloudwatch":"logs2"}', events[1].message)
|
65
66
|
|
66
|
-
assert(logs.any?{|log| log.include?("
|
67
|
+
assert(logs.any?{|log| log.include?("Called PutLogEvents API") })
|
67
68
|
end
|
68
69
|
|
69
70
|
def test_write_utf8
|
@@ -79,7 +80,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
79
80
|
|
80
81
|
events = get_log_events
|
81
82
|
assert_equal(1, events.size)
|
82
|
-
assert_equal(time.
|
83
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
83
84
|
assert_equal('{"cloudwatch":"これは日本語です"}', events[0].message)
|
84
85
|
end
|
85
86
|
|
@@ -105,7 +106,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
105
106
|
assert_equal(3, events.size)
|
106
107
|
assert_equal((time.to_i - 60 * 60 * 25) * 1000, events[0].timestamp)
|
107
108
|
assert_equal('{"cloudwatch":"logs0"}', events[0].message)
|
108
|
-
assert_equal((time.
|
109
|
+
assert_equal((time.to_f * 1000).floor, events[1].timestamp)
|
109
110
|
assert_equal('{"cloudwatch":"logs1"}', events[1].message)
|
110
111
|
assert_equal((time.to_i + 1) * 1000, events[2].timestamp)
|
111
112
|
assert_equal('{"cloudwatch":"logs2"}', events[2].message)
|
@@ -131,7 +132,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
131
132
|
|
132
133
|
events = get_log_events
|
133
134
|
assert_equal(2, events.size)
|
134
|
-
assert_equal(time.
|
135
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
135
136
|
assert_equal('message1 logs1', events[0].message)
|
136
137
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
137
138
|
assert_equal('message2 logs2', events[1].message)
|
@@ -158,7 +159,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
158
159
|
|
159
160
|
events = get_log_events
|
160
161
|
assert_equal(2, events.size)
|
161
|
-
assert_equal(time.
|
162
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
162
163
|
assert_equal('message1 l', events[0].message)
|
163
164
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
164
165
|
assert_equal('message2 l', events[1].message)
|
@@ -184,7 +185,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
184
185
|
|
185
186
|
events = get_log_events(fluentd_tag)
|
186
187
|
assert_equal(2, events.size)
|
187
|
-
assert_equal(time.
|
188
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
188
189
|
assert_equal('message1 logs1', events[0].message)
|
189
190
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
190
191
|
assert_equal('message2 logs2', events[1].message)
|
@@ -210,7 +211,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
210
211
|
|
211
212
|
events = get_log_events(log_group_name, fluentd_tag)
|
212
213
|
assert_equal(2, events.size)
|
213
|
-
assert_equal(time.
|
214
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
214
215
|
assert_equal('message1 logs1', events[0].message)
|
215
216
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
216
217
|
assert_equal('message2 logs2', events[1].message)
|
@@ -237,7 +238,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
237
238
|
|
238
239
|
events = get_log_events
|
239
240
|
assert_equal(2, events.size)
|
240
|
-
assert_equal(time.
|
241
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
241
242
|
assert_equal("{\"cloudwatch\":\"logs1\",\"time\":\"#{Time.at(time.to_r).utc.strftime("%Y-%m-%dT%H:%M:%SZ")}\"}", events[0].message)
|
242
243
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
243
244
|
assert_equal("{\"cloudwatch\":\"logs2\",\"time\":\"#{Time.at((time+1).to_r).utc.strftime("%Y-%m-%dT%H:%M:%SZ")}\"}", events[1].message)
|
@@ -264,7 +265,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
264
265
|
|
265
266
|
events = get_log_events
|
266
267
|
assert_equal(2, events.size)
|
267
|
-
assert_equal(time.
|
268
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
268
269
|
assert_equal("{\"cloudwatch\":\"logs1\",\"time\":\"#{Time.at(time.to_r).strftime("%Y-%m-%dT%H:%M:%S%:z")}\"}", events[0].message)
|
269
270
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
270
271
|
assert_equal("{\"cloudwatch\":\"logs2\",\"time\":\"#{Time.at((time+1).to_r).to_time.strftime("%Y-%m-%dT%H:%M:%S%:z")}\"}", events[1].message)
|
@@ -298,7 +299,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
298
299
|
|
299
300
|
logs = d.logs
|
300
301
|
# Call API once for each stream
|
301
|
-
assert_equal(2, logs.select {|l| l =~ /
|
302
|
+
assert_equal(2, logs.select {|l| l =~ /Called PutLogEvents API/ }.size)
|
302
303
|
|
303
304
|
sleep 10
|
304
305
|
|
@@ -335,7 +336,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
335
336
|
|
336
337
|
events = get_log_events(log_group_name, log_stream_name)
|
337
338
|
assert_equal(1, events.size)
|
338
|
-
assert_equal(time.
|
339
|
+
assert_equal((time.to_f * 1000).floor, events[0].timestamp)
|
339
340
|
assert_equal({'cloudwatch' => 'logs1', 'message' => 'message1'}, JSON.parse(events[0].message))
|
340
341
|
end
|
341
342
|
|
@@ -420,7 +421,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
420
421
|
end
|
421
422
|
end
|
422
423
|
|
423
|
-
assert_match(/failed to set retention policy for Log group/, d.
|
424
|
+
assert_match(/failed to set retention policy for Log group/, d.logs[0])
|
424
425
|
end
|
425
426
|
|
426
427
|
def test_log_group_aws_tags_key
|
@@ -529,6 +530,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
529
530
|
|
530
531
|
def test_retrying_on_throttling_exception
|
531
532
|
resp = mock()
|
533
|
+
resp.expects(:rejected_log_events_info)
|
532
534
|
resp.expects(:next_sequence_token)
|
533
535
|
client = Aws::CloudWatchLogs::Client.new
|
534
536
|
client.stubs(:put_log_events).
|
@@ -542,7 +544,7 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
542
544
|
end
|
543
545
|
|
544
546
|
logs = d.logs
|
545
|
-
assert_equal(
|
547
|
+
assert_equal(1, logs.select {|l| l =~ /Called PutLogEvents API/ }.size)
|
546
548
|
assert_equal(1, logs.select {|l| l =~ /failed to PutLogEvents/ }.size)
|
547
549
|
assert_equal(1, logs.select {|l| l =~ /retry succeeded/ }.size)
|
548
550
|
end
|
@@ -551,7 +553,6 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
551
553
|
client = Aws::CloudWatchLogs::Client.new
|
552
554
|
client.stubs(:put_log_events).
|
553
555
|
raises(Aws::CloudWatchLogs::Errors::ThrottlingException.new(nil, "error"))
|
554
|
-
|
555
556
|
time = Fluent::Engine.now
|
556
557
|
d = create_driver(<<-EOC)
|
557
558
|
#{default_config}
|
@@ -566,7 +567,7 @@ put_log_events_retry_limit 1
|
|
566
567
|
end
|
567
568
|
|
568
569
|
logs = d.logs
|
569
|
-
assert_equal(
|
570
|
+
assert_equal(0, logs.select {|l| l =~ /Called PutLogEvents API/ }.size)
|
570
571
|
assert_equal(3, logs.select {|l| l =~ /failed to PutLogEvents/ }.size)
|
571
572
|
assert_equal(1, logs.select {|l| l =~ /failed to PutLogEvents and discard logs/ }.size)
|
572
573
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-cloudwatch-logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -115,7 +115,7 @@ files:
|
|
115
115
|
- test/plugin/test_in_cloudwatch_logs.rb
|
116
116
|
- test/plugin/test_out_cloudwatch_logs.rb
|
117
117
|
- test/test_helper.rb
|
118
|
-
homepage: https://github.com/
|
118
|
+
homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-cloudwatch-logs
|
119
119
|
licenses:
|
120
120
|
- MIT
|
121
121
|
metadata: {}
|