|
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 = "") |
70 | 72 | # region => "eu-west-1" (optional, default = "us-east-1")
|
71 | 73 | # bucket => "your_bucket" (required)
|
72 | 74 | # size_file => 2048 (optional) - Bytes
|
@@ -106,6 +108,10 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
|
106 | 108 | # S3 bucket
|
107 | 109 | config :bucket, :validate => :string, :required => true
|
108 | 110 |
|
| 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 | + |
109 | 115 | # 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 | 116 | # If you have tags then it will generate a specific size file for every tags
|
111 | 117 | ##NOTE: define size of file is the better thing, because generate a local temporary file on disk and then put it in bucket.
|
@@ -256,6 +262,7 @@ def full_options
|
256 | 262 | options = Hash.new
|
257 | 263 | options[:s3_signature_version] = @signature_version if @signature_version
|
258 | 264 | options.merge(aws_options_hash)
|
| 265 | + .merge(endpoint_options) |
259 | 266 | end
|
260 | 267 |
|
261 | 268 | def normalize_key(prefix_key)
|
@@ -288,6 +295,18 @@ def aws_service_endpoint(region)
|
288 | 295 | { :s3_endpoint => region == 'us-east-1' ? 's3.amazonaws.com' : "s3-#{region}.amazonaws.com"}
|
289 | 296 | end
|
290 | 297 |
|
| 298 | + def endpoint_options |
| 299 | + if @endpoint |
| 300 | + uri = URI(@endpoint) |
| 301 | + { |
| 302 | + :endpoint => @endpoint, |
| 303 | + :force_path_style => true, |
| 304 | + } |
| 305 | + else |
| 306 | + {} |
| 307 | + end |
| 308 | + end |
| 309 | + |
291 | 310 | def upload_options
|
292 | 311 | {
|
293 | 312 | :acl => @cannel_acl,
|
|
0 commit comments