fluent-plugin-s3 1.7.1 → 1.7.2
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 +4 -4
- data/ChangeLog +5 -0
- data/VERSION +1 -1
- data/docs/howto.md +1 -1
- data/docs/input.md +4 -0
- data/lib/fluent/plugin/in_s3.rb +23 -5
- data/lib/fluent/plugin/out_s3.rb +2 -2
- data/test/test_in_s3.rb +49 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1450176cd690d79412b7522ce8e67163c2f3c9c1f87941e57d6b3f3410bdf330
|
4
|
+
data.tar.gz: ee66229b8cd65ef2507feb5229d54322ed2f076e2daefb3f32e3b0e2ba47c634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0428c1da0ef734a65d86aec878374636cf4bfd10ed2ab06578d3d8a9cc8ee607e62b4a85c05144599dec2167995dbd836b70cb7cfb66f38fc38d5e82dc1073a
|
7
|
+
data.tar.gz: bb4d7820ff8fa7fa3e58092b69fc78bb4804d92854206fb61c4efa21b415519eff682cf64763a9ec237f30f8997ab20b0b395bb8f1f17a8c88a9c63b3381b02b
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Release 1.7.2 - 2022/10/19
|
2
|
+
|
3
|
+
* in_s3: Add `event_bridge_mode` parameter
|
4
|
+
* out_s3: Fix `s3_object_key_format` check to allow `%{hex_random}` as well as `%{uuid_flush}` or `${chunk_id}`
|
5
|
+
|
1
6
|
Release 1.7.1 - 2022/07/15
|
2
7
|
|
3
8
|
* in_s3: Add `match_regexp` parameter to selectively download S3 files based on the object key
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.
|
1
|
+
1.7.2
|
data/docs/howto.md
CHANGED
@@ -7,7 +7,7 @@ downstream processors to better identify the source of a given record.
|
|
7
7
|
|
8
8
|
# IAM Policy
|
9
9
|
|
10
|
-
The following is an example for a IAM policy needed to write to an s3 bucket (matches my-s3bucket/logs, my-s3bucket
|
10
|
+
The following is an example for a IAM policy needed to write to an s3 bucket (matches my-s3bucket/logs, my-s3bucket/test, etc.).
|
11
11
|
|
12
12
|
{
|
13
13
|
"Version": "2012-10-17",
|
data/docs/input.md
CHANGED
@@ -101,3 +101,7 @@ The long polling interval. Default is 20.
|
|
101
101
|
### retry_error_interval
|
102
102
|
|
103
103
|
Interval to retry polling SQS if polling unsuccessful, in seconds. Default is 300.
|
104
|
+
|
105
|
+
### event_bridge_mode
|
106
|
+
When true, Amazon S3 Event Notification should be configured using the EventBridge integration. Default is false.
|
107
|
+
See [Configure S3 event notification using EventBridge](https://docs.aws.amazon.com/AmazonS3/latest/userguide/EventBridge.html) for additional information.
|
data/lib/fluent/plugin/in_s3.rb
CHANGED
@@ -110,6 +110,8 @@ module Fluent::Plugin
|
|
110
110
|
config_param :wait_time_seconds, :integer, default: 20
|
111
111
|
desc "Polling error retry interval."
|
112
112
|
config_param :retry_error_interval, :integer, default: 300
|
113
|
+
desc "Event bridge mode"
|
114
|
+
config_param :event_bridge_mode, :bool, default: false
|
113
115
|
end
|
114
116
|
|
115
117
|
desc "Tag string"
|
@@ -205,10 +207,9 @@ module Fluent::Plugin
|
|
205
207
|
begin
|
206
208
|
body = Yajl.load(message.body)
|
207
209
|
log.debug(body)
|
208
|
-
next unless body
|
210
|
+
next unless is_valid_queue(body) # skip test queue
|
209
211
|
if @match_regexp
|
210
|
-
|
211
|
-
raw_key = s3["object"]["key"]
|
212
|
+
raw_key = get_raw_key(body)
|
212
213
|
key = CGI.unescape(raw_key)
|
213
214
|
next unless @match_regexp.match?(key)
|
214
215
|
end
|
@@ -226,6 +227,24 @@ module Fluent::Plugin
|
|
226
227
|
end
|
227
228
|
end
|
228
229
|
|
230
|
+
def is_valid_queue(body)
|
231
|
+
if @sqs.event_bridge_mode
|
232
|
+
log.debug("checking for eventbridge property")
|
233
|
+
!!body["detail"]
|
234
|
+
else
|
235
|
+
log.debug("checking for Records property")
|
236
|
+
!!body["Records"]
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def get_raw_key(body)
|
241
|
+
if @sqs.event_bridge_mode
|
242
|
+
body["detail"]["object"]["key"]
|
243
|
+
else
|
244
|
+
body["Records"].first["s3"]["object"]["key"]
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
229
248
|
def setup_credentials
|
230
249
|
options = {}
|
231
250
|
credentials_options = {}
|
@@ -318,8 +337,7 @@ module Fluent::Plugin
|
|
318
337
|
end
|
319
338
|
|
320
339
|
def process(body)
|
321
|
-
|
322
|
-
raw_key = s3["object"]["key"]
|
340
|
+
raw_key = get_raw_key(body)
|
323
341
|
key = CGI.unescape(raw_key)
|
324
342
|
|
325
343
|
io = @bucket.object(key).get.body
|
data/lib/fluent/plugin/out_s3.rb
CHANGED
@@ -471,8 +471,8 @@ module Fluent::Plugin
|
|
471
471
|
end
|
472
472
|
|
473
473
|
is_working_on_parallel = @buffer_config.flush_thread_count > 1 || system_config.workers > 1
|
474
|
-
if is_working_on_parallel && ['${chunk_id}', '%{uuid_flush}'].none? { |key| @s3_object_key_format.include?(key) }
|
475
|
-
log.warn "No ${chunk_id} or %{
|
474
|
+
if is_working_on_parallel && ['${chunk_id}', '%{uuid_flush}', '%{hex_random}'].none? { |key| @s3_object_key_format.include?(key) }
|
475
|
+
log.warn "No ${chunk_id}, %{uuid_flush} or %{hex_random} in s3_object_key_format with multiple flush threads or multiple workers. Recommend to set ${chunk_id}, %{uuid_flush} or %{hex_random} to avoid data lost by object conflict"
|
476
476
|
end
|
477
477
|
end
|
478
478
|
|
data/test/test_in_s3.rb
CHANGED
@@ -166,9 +166,9 @@ buffer_type memory
|
|
166
166
|
aws_key_id sqs_test_key_id
|
167
167
|
</sqs>
|
168
168
|
EOS
|
169
|
-
|
170
|
-
|
171
|
-
|
169
|
+
create_driver(conf)
|
170
|
+
}
|
171
|
+
end
|
172
172
|
|
173
173
|
def test_sqs_with_invalid_aws_keys_missing_key_id
|
174
174
|
assert_raise(Fluent::ConfigError, "sqs/aws_key_id or sqs/aws_sec_key is missing") {
|
@@ -677,4 +677,50 @@ EOS
|
|
677
677
|
d.run {}
|
678
678
|
end
|
679
679
|
end
|
680
|
+
|
681
|
+
def test_event_bridge_mode
|
682
|
+
setup_mocks
|
683
|
+
d = create_driver("
|
684
|
+
aws_key_id test_key_id
|
685
|
+
aws_sec_key test_sec_key
|
686
|
+
s3_bucket test_bucket
|
687
|
+
buffer_type memory
|
688
|
+
check_apikey_on_start false
|
689
|
+
store_as text
|
690
|
+
format none
|
691
|
+
<sqs>
|
692
|
+
event_bridge_mode true
|
693
|
+
queue_name test_queue
|
694
|
+
queue_owner_aws_account_id 123456789123
|
695
|
+
</sqs>
|
696
|
+
")
|
697
|
+
|
698
|
+
s3_object = stub(Object.new)
|
699
|
+
s3_response = stub(Object.new)
|
700
|
+
s3_response.body { StringIO.new("aaa") }
|
701
|
+
s3_object.get { s3_response }
|
702
|
+
@s3_bucket.object(anything).at_least(1) { s3_object }
|
703
|
+
|
704
|
+
body = {
|
705
|
+
"detail" => {
|
706
|
+
"object" => {
|
707
|
+
"key" => "test_key"
|
708
|
+
}
|
709
|
+
}
|
710
|
+
}
|
711
|
+
|
712
|
+
message = Struct::StubMessage.new(1, 1, Yajl.dump(body))
|
713
|
+
@sqs_poller.get_messages(anything, anything) do |config, stats|
|
714
|
+
config.before_request.call(stats) if config.before_request
|
715
|
+
stats.request_count += 1
|
716
|
+
if stats.request_count >= 1
|
717
|
+
d.instance.instance_variable_set(:@running, false)
|
718
|
+
end
|
719
|
+
[message]
|
720
|
+
end
|
721
|
+
d.run(expect_emits: 1)
|
722
|
+
events = d.events
|
723
|
+
assert_equal({ "message" => "aaa" }, events.first[2])
|
724
|
+
end
|
725
|
+
|
680
726
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|