This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Masaki Yoshida
committed
Oct 1, 2014
0 parents
commit c3c5037
Showing
7 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'fluent-plugin-s3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Amazon S3 output plugin for (Fluentd)[http://github.com/fluent/fluentd] | ||
|
||
## Overview | ||
|
||
[fluent-plugin-s3](https://github.com/fluent/fluent-plugin-s3) with time_slice_duration | ||
|
||
## Configuration | ||
|
||
``` | ||
<match pattern> | ||
type s3 | ||
|
||
aws_key_id YOUR_AWS_KEY_ID | ||
aws_sec_key YOUR_AWS_SECRET/KEY | ||
s3_bucket YOUR_S3_BUCKET_NAME | ||
s3_endpoint s3-ap-northeast-1.amazonaws.com | ||
s3_object_key_format %{path}%{time_slice}_%{index}.%{file_extension} | ||
path logs/ | ||
buffer_path /var/log/fluent/s3 | ||
|
||
time_slice_format %Y%m%d-%H:%M | ||
time_slice_duration 3600 # <- slice by 30min. | ||
time_slice_wait 10m | ||
utc | ||
</match> | ||
``` | ||
# License | ||
Apache License, Version 2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks | ||
|
||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |test| | ||
test.libs << 'lib' << 'test' | ||
test.test_files = FileList['test/test_*.rb'] | ||
test.verbose = true | ||
end | ||
|
||
task :default => [:build] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# encoding: utf-8 | ||
$:.push File.expand_path('../lib', __FILE__) | ||
|
||
Gem::Specification.new do |gem| | ||
gem.name = "fluent-plugin-s3-duration" | ||
gem.description = "Amazon S3 output plugin for Fluentd event collector, with time_slice_duration" | ||
gem.homepage = "https://github.com/vasilyjp/fluent-plugin-s3-duration" | ||
gem.summary = gem.description | ||
gem.version = File.read("VERSION").strip | ||
gem.authors = ["Masaki Yoshida"] | ||
gem.email = "[email protected]" | ||
gem.has_rdoc = false | ||
#gem.platform = Gem::Platform::RUBY | ||
gem.files = `git ls-files`.split("\n") | ||
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
gem.require_paths = ['lib'] | ||
|
||
gem.add_dependency "fluent-plugin-s3" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Fluentd | ||
require 'fluent/plugin/out_s3' | ||
|
||
class S3DurationOutput < Fluent::S3Output | ||
Fluent::Plugin.register_output('s3_duration', self) | ||
|
||
config_param :time_slice_duration, :integer, :default => 0 | ||
|
||
def filter_duration(time) | ||
if @time_slice_duration != 0 | ||
Time.at((time.to_i / @time_slice_duration).to_i * @time_slice_duration) | ||
else | ||
time | ||
end | ||
end | ||
|
||
def configure(conf) | ||
super | ||
@time_slice_duration = conf['time_slice_duration'].to_i | ||
if @localtime | ||
@time_slicer = Proc.new {|time| | ||
filter_duration(Time.at(time)).strftime(@time_slice_format) | ||
} | ||
else | ||
@time_slicer = Proc.new {|time| | ||
filter_duration(Time.at(time)).utc.strftime(@time_slice_format) | ||
} | ||
end | ||
end | ||
end | ||
end |