13
13
require "pathname"
14
14
require "aws-sdk"
15
15
require "logstash/outputs/s3/patch"
16
+ require "uri"
16
17
17
18
Aws . eager_autoload!
18
19
64
65
# This is an example of logstash config:
65
66
# [source,ruby]
66
67
# output {
67
- # s3{
68
+ # s3 {
68
69
# access_key_id => "crazy_key" (required)
69
70
# secret_access_key => "monkey_access_key" (required)
71
+ # endpoint => "http://127.0.0.1:8080" (optional, used for non-AWS endpoints, default = "")
72
+ # force_path_style => false (optional, used for non-AWS endpoints, default = false)
70
73
# region => "eu-west-1" (optional, default = "us-east-1")
71
74
# bucket => "your_bucket" (required)
72
75
# size_file => 2048 (optional) - Bytes
@@ -106,6 +109,13 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
106
109
# S3 bucket
107
110
config :bucket , :validate => :string , :required => true
108
111
112
+ # Specify a custom endpoint for use with non-AWS S3 implementations, e.g.,
113
+ # Ceph. Provide a URL in the format http://127.0.0.1:8080/
114
+ config :endpoint , :validate => :string
115
+
116
+ # When false, specify the bucket in the subdomain. When true, specify the bucket in the path.
117
+ config :force_path_style , :validate => :bool , :default => false
118
+
109
119
# Set the size of file in bytes, this means that files on bucket when have dimension > file_size, they are stored in two or more file.
110
120
# If you have tags then it will generate a specific size file for every tags
111
121
##NOTE: define size of file is the better thing, because generate a local temporary file on disk and then put it in bucket.
@@ -270,6 +280,7 @@ def full_options
270
280
options = Hash . new
271
281
options [ :s3_signature_version ] = @signature_version if @signature_version
272
282
options . merge ( aws_options_hash )
283
+ . merge ( endpoint_options )
273
284
end
274
285
275
286
def normalize_key ( prefix_key )
@@ -286,6 +297,18 @@ def upload_options
286
297
}
287
298
end
288
299
300
+ def endpoint_options
301
+ if @endpoint
302
+ uri = URI ( @endpoint )
303
+ {
304
+ :endpoint => @endpoint ,
305
+ :force_path_style => @force_path_style ,
306
+ }
307
+ else
308
+ { }
309
+ end
310
+ end
311
+
289
312
private
290
313
# We start a task in the background for check for stale files and make sure we rotate them to S3 if needed.
291
314
def start_periodic_check
0 commit comments