1313require "pathname"
1414require "aws-sdk"
1515require "logstash/outputs/s3/patch"
16+ require "uri"
1617
1718Aws . eager_autoload!
1819
6465# This is an example of logstash config:
6566# [source,ruby]
6667# output {
67- # s3{
68+ # s3 {
6869# access_key_id => "crazy_key" (required)
6970# secret_access_key => "monkey_access_key" (required)
71+ # endpoint => "http://127.0.0.1:8080" (optional, used for non-AWS endpoints, default = "")
7072# region => "eu-west-1" (optional, default = "us-east-1")
7173# bucket => "your_bucket" (required)
7274# size_file => 2048 (optional) - Bytes
@@ -106,6 +108,10 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
106108 # S3 bucket
107109 config :bucket , :validate => :string , :required => true
108110
111+ # Specify a custom endpoint for use with non-AWS S3 implementations, e.g.,
112+ # Ceph. Provide a URL in the format http://127.0.0.1:8080/
113+ config :endpoint , :validate => :string
114+
109115 # 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.
110116 # If you have tags then it will generate a specific size file for every tags
111117 ##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 +276,7 @@ def full_options
270276 options = Hash . new
271277 options [ :s3_signature_version ] = @signature_version if @signature_version
272278 options . merge ( aws_options_hash )
279+ . merge ( endpoint_options )
273280 end
274281
275282 def normalize_key ( prefix_key )
@@ -286,6 +293,18 @@ def upload_options
286293 }
287294 end
288295
296+ def endpoint_options
297+ if @endpoint
298+ uri = URI ( @endpoint )
299+ {
300+ :endpoint => @endpoint ,
301+ :force_path_style => true ,
302+ }
303+ else
304+ { }
305+ end
306+ end
307+
289308 private
290309 # We start a task in the background for check for stale files and make sure we rotate them to S3 if needed.
291310 def start_periodic_check
0 commit comments