Skip to content

Commit

Permalink
Allow non-AWS endpoints
Browse files Browse the repository at this point in the history
This is useful for local Ceph S3 deployments.  Fixes #10.  Fixes #65.
  • Loading branch information
Andrew Gaul authored and gaul committed Jan 27, 2017
1 parent e5ee0bd commit 3586d84
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.0.6
- Support for non-AWS endpoints

## 4.0.5
- Delete the file on disk after they are succesfully uploaded to S3 #122 #120
- Added logging when an exception occur in the Uploader's `on_complete` callback
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Contributors:
* Nick Ethier (nickethier)
* Pier-Hugues Pellerin (ph)
* Richard Pijnenburg (electrical)
* Andrew Gaul (andrewgaul)

Note: If you've sent us patches, bug reports, or otherwise contributed to
Logstash, and you aren't on the list above and want to be, please let us know
Expand Down
21 changes: 20 additions & 1 deletion lib/logstash/outputs/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require "pathname"
require "aws-sdk"
require "logstash/outputs/s3/patch"
require "uri"

Aws.eager_autoload!

Expand Down Expand Up @@ -64,9 +65,10 @@
# This is an example of logstash config:
# [source,ruby]
# output {
# s3{
# s3 {
# access_key_id => "crazy_key" (required)
# secret_access_key => "monkey_access_key" (required)
# endpoint => "http://127.0.0.1:8080" (optional, used for non-AWS endpoints, default = "")
# region => "eu-west-1" (optional, default = "us-east-1")
# bucket => "your_bucket" (required)
# size_file => 2048 (optional) - Bytes
Expand Down Expand Up @@ -106,6 +108,10 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
# S3 bucket
config :bucket, :validate => :string, :required => true

# Specify a custom endpoint for use with non-AWS S3 implementations, e.g.,
# Ceph. Provide a URL in the format http://127.0.0.1:8080/
config :endpoint, :validate => :string

# 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.
# If you have tags then it will generate a specific size file for every tags
##NOTE: define size of file is the better thing, because generate a local temporary file on disk and then put it in bucket.
Expand Down Expand Up @@ -270,6 +276,7 @@ def full_options
options = Hash.new
options[:s3_signature_version] = @signature_version if @signature_version
options.merge(aws_options_hash)
.merge(endpoint_options)
end

def normalize_key(prefix_key)
Expand All @@ -286,6 +293,18 @@ def upload_options
}
end

def endpoint_options
if @endpoint
uri = URI(@endpoint)
{
:endpoint => @endpoint,
:force_path_style => true,
}
else
{}
end
end

private
# We start a task in the background for check for stale files and make sure we rotate them to S3 if needed.
def start_periodic_check
Expand Down

0 comments on commit 3586d84

Please sign in to comment.