fluent-plugin-s3 1.1.11 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e034c8d5e4ae06a88f405bfe396d2c1c960da096b5010d4b45902765b00eaa6a
4
- data.tar.gz: 679865ce71becff176745c0fcb051a6120313c5127d4ad70a8333b263c5eb67d
3
+ metadata.gz: 26e0fd779938910c499dfdd043c253b90167c05c585945fddcaa37985302cbff
4
+ data.tar.gz: fe09d0a34580eeea82b3538f7e7fe8fcbc85e42dcb1d7dd5cedfbfeeefdfbe56
5
5
  SHA512:
6
- metadata.gz: b0e0bf4a2072b9589e0e27ed84806c00d1fcc1ba47e70d1a628017aa7981993372b2afd7ee04d1eee5c558c2d485c3128ec64318b34fd802b8c1759fa311d71d
7
- data.tar.gz: 6fd057fd51ce0aeed1fd64c2a39a405ee329f0b96cb92dc09faeac37f4d679fc0d7951d827f8ea0b0eda513a99f9cd89ab171b795933b1d8a44294d025fac7c8
6
+ metadata.gz: aec5991826999db113542e9e313b03a2ca018d3b7143ca745f45a211f0ce3e3c66c1b5b84c087b3e5d654aeb8b840db1580e5b6911bd182b7fb1a4131ee317ce
7
+ data.tar.gz: 575fcd019697834d1ff5aef35a456fa7b5a54ec8c3f565285b50195ca1f5d67a24738d39973e9f7d7e9e15bac398ac96d494ffc1907e5cd6271385242cf36521
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Release 1.2.0 - 2019/10/17
2
+
3
+ * out_s3: Add bucket_lifecycle_rule section to set bucket's lifecycle
4
+
1
5
  Release 1.1.11 - 2019/06/17
2
6
 
3
7
  * in_s3: Add add_object_metadata parameter
data/README.md CHANGED
@@ -5,9 +5,6 @@ alt="Build Status" />](https://travis-ci.org/fluent/fluent-plugin-s3) [<img
5
5
  src="https://codeclimate.com/github/fluent/fluent-plugin-s3/badges/gpa.svg"
6
6
  />](https://codeclimate.com/github/fluent/fluent-plugin-s3)
7
7
 
8
- ## PR
9
- **it will be greatful that the plugin can push log to owner S3 Storage like Ceph S3.**
10
-
11
8
  ## Overview
12
9
 
13
10
  **s3** output plugin buffers event logs in local file and upload it to S3
@@ -569,6 +566,16 @@ It would be useful when you use S3 compatible storage that accepts only signatur
569
566
 
570
567
  Given a threshold to treat events as delay, output warning logs if delayed events were put into s3.
571
568
 
569
+ **bucket_lifecycle_rule**
570
+
571
+ Specify one or more lifecycle rules for the bucket
572
+
573
+ <bucket_lifecycle_rule>
574
+ id UNIQUE_ID_FOR_THE_RULE
575
+ prefix OPTIONAL_PREFIX # Objects whose keys begin with this prefix will be affected by the rule. If not specified all objects of the bucket will be affected
576
+ expiration_days NUMBER_OF_DAYS # The number of days before the object will expire
577
+ </bucket_lifecycle_rule>
578
+
572
579
  ## Input: Setup
573
580
 
574
581
  1. Create new [SQS](https://aws.amazon.com/documentation/sqs/) queue (use same region as S3)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.11
1
+ 1.2.0
@@ -124,6 +124,14 @@ module Fluent::Plugin
124
124
  config_param :warn_for_delay, :time, default: nil
125
125
  desc "Arbitrary S3 metadata headers to set for the object"
126
126
  config_param :s3_metadata, :hash, default: nil
127
+ config_section :bucket_lifecycle_rule, param_name: :bucket_lifecycle_rules, multi: true do
128
+ desc "A unique ID for this rule"
129
+ config_param :id, :string
130
+ desc "Objects whose keys begin with this prefix will be affected by the rule. If not specified all objects of the bucket will be affected"
131
+ config_param :prefix, :string, default: ''
132
+ desc "The number of days before the object will expire"
133
+ config_param :expiration_days, :integer
134
+ end
127
135
 
128
136
  DEFAULT_FORMAT_TYPE = "out_file"
129
137
 
@@ -217,6 +225,7 @@ module Fluent::Plugin
217
225
 
218
226
  check_apikeys if @check_apikey_on_start
219
227
  ensure_bucket if @check_bucket
228
+ ensure_bucket_lifecycle
220
229
 
221
230
  super
222
231
  end
@@ -373,6 +382,30 @@ module Fluent::Plugin
373
382
  end
374
383
  end
375
384
 
385
+ def ensure_bucket_lifecycle
386
+ unless @bucket_lifecycle_rules.empty?
387
+ old_rules = get_bucket_lifecycle_rules
388
+ new_rules = @bucket_lifecycle_rules.sort_by { |rule| rule.id }.map do |rule|
389
+ { id: rule.id, expiration: { days: rule.expiration_days }, prefix: rule.prefix, status: "Enabled" }
390
+ end
391
+
392
+ unless old_rules == new_rules
393
+ log.info "Configuring bucket lifecycle rules for #{@s3_bucket} on #{@s3_endpoint}"
394
+ @bucket.lifecycle_configuration.put({ lifecycle_configuration: { rules: new_rules } })
395
+ end
396
+ end
397
+ end
398
+
399
+ def get_bucket_lifecycle_rules
400
+ begin
401
+ @bucket.lifecycle_configuration.rules.sort_by { |rule| rule[:id] }.map do |rule|
402
+ { id: rule[:id], expiration: { days: rule[:expiration][:days] }, prefix: rule[:prefix], status: rule[:status] }
403
+ end
404
+ rescue Aws::S3::Errors::NoSuchLifecycleConfiguration
405
+ []
406
+ end
407
+ end
408
+
376
409
  def process_s3_object_key_format
377
410
  %W(%{uuid} %{uuid:random} %{uuid:hostname} %{uuid:timestamp}).each { |ph|
378
411
  if @s3_object_key_format.include?(ph)
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.1.11
4
+ version: 1.2.0
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: 2019-06-17 00:00:00.000000000 Z
12
+ date: 2019-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd