Skip to content

Allow non-AWS endpoints #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.0.14
- Support for non-AWS endpoints

## 4.0.13
- Update gemspec summary

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Contributors:
* Richard Pijnenburg (electrical)
* Jake Landis (jakelandis)
* Armin Braun (original-brownbear)
* Andrew Gaul (gaul)

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
25 changes: 24 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,11 @@
# 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 = "")
# force_path_style => false (optional, used for non-AWS endpoints, default = false)
# region => "eu-west-1" (optional, default = "us-east-1")
# bucket => "your_bucket" (required)
# size_file => 2048 (optional) - Bytes
Expand Down Expand Up @@ -106,6 +109,13 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "endpoint" the best name?

Is http the right scheme for the url? Citing existing exsample:

  • s3cmd allows s3:// uri
  • s3cmd config has host_base and host_bucket for setting hostnames different from AWS S3.
  • hadoop uses s3a:// (and older s3n and s3)
  • boto allows users to set the host for the endpoint, but not a URL (based on my probably-incomplete research)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Endpoint is the name in the AWS documentation, but it's NOT a URL, it's a host and port.
  • Eg boto.s3.S3Connection has a host parameter that takes an optional port, eg 127.0.0.1:8080.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some users want HTTP on trusted networks and others HTTPS on the wider Internet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be available through the mixin all the aws like plugins use

So no need to implement it here.

Only the force_path_style setting below is s3 specific, can you respin this PR to only add that setting?


# When false, specify the bucket in the subdomain. When true, specify the bucket in the path.
config :force_path_style, :validate => :boolean, :default => false

# 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 +280,7 @@ def full_options
options = Hash.new
options[: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 +297,18 @@ def upload_options
}
end

def endpoint_options
if @endpoint
uri = URI(@endpoint)
{
:endpoint => @endpoint,
:force_path_style => @force_path_style,
}
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