Skip to content
Closed
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
12 changes: 7 additions & 5 deletions lib/logstash/outputs/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# S3 plugin allows you to do something complex, let's explain:)

# S3 outputs create temporary files into "/opt/logstash/S3_temp/". If you want, you can change the path at the start of register method.
# S3 outputs create temporary files into "/opt/logstash/S3_temp/" or in to the temp_directory you specify in your conf. If
# This files have a special name, for example:

# ls.s3.ip-10-228-27-95.2013-04-18T10.00.tag_hello.part0.txt
Expand Down Expand Up @@ -72,7 +72,7 @@
# time_file => 5 (optional)
# format => "plain" (optional)
# canned_acl => "private" (optional. Options are "private", "public_read", "public_read_write", "authenticated_read". Defaults to "private" )
# }
# temp_directory => "/tmp/s3_temp" (optional. Defaults to "/opt/logstash/S3_temp/")
# }

# We analize this:
Expand Down Expand Up @@ -135,6 +135,9 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
# 0 stay all time on listerner, beware if you specific 0 and size_file 0, because you will not put the file on bucket,
# for now the only thing this plugin can do is to put the file when logstash restart.
config :time_file, :validate => :number, :default => 0

#Set the directory where temporary files are stored.
config :temp_directory, :validate => :string, :default => "/opt/logstash/S3_temp/"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the default should be the system's temporary directory. Dir.tmpdir usually reports this.


# The event format you want to store in files. Defaults to plain text.
config :format, :validate => [ "json", "plain", "nil" ], :default => "plain"
Expand Down Expand Up @@ -204,7 +207,7 @@ def write_on_bucket (file_data, file_basename)
def getFinalPath

@pass_time = Time.now
return @temp_directory+"ls.s3."+Socket.gethostname+"."+(@pass_time).strftime("%Y-%m-%dT%H.%M")
return @temp_directory+"/ls.s3."+Socket.gethostname+"."+(@pass_time).strftime("%Y-%m-%dT%H.%M")
Copy link
Contributor

Choose a reason for hiding this comment

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

File.join should be used here to build paths. I know there are inconsistencies with this in the codebase.


end

Expand Down Expand Up @@ -253,7 +256,6 @@ def newFile (flag)
public
def register
require "aws-sdk"
@temp_directory = "/opt/logstash/S3_temp/"

if (@tags.size != 0)
@tag_path = ""
Expand All @@ -266,7 +268,7 @@ def register
@logger.debug "S3: Directory "+@temp_directory+" doesn't exist, let's make it!"
Dir.mkdir(@temp_directory)
else
@logger.debug "S3: Directory "+@temp_directory+" exist, nothing to do"
@logger.debug "S3: Directory "+@temp_directory+" exists, nothing to do"
end

if (@restore == true )
Expand Down