Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Masaki Yoshida committed Oct 1, 2014
0 parents commit c3c5037
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'fluent-plugin-s3'
28 changes: 28 additions & 0 deletions README.rdoc
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
13 changes: 13 additions & 0 deletions Rakefile
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
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1
20 changes: 20 additions & 0 deletions fluent-plugin-s3-duration.gemspec
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
31 changes: 31 additions & 0 deletions lib/fluent/plugin/out_s3_duration.rb
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

0 comments on commit c3c5037

Please sign in to comment.