fluent-plugin-sndacs 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +34 -0
- data/README.md +16 -0
- data/Rakefile +4 -0
- data/fluent-plugin-sndacs.gemspec +14 -0
- data/lib/fluent/plugin/out_sndacs.rb +56 -0
- metadata +82 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fluent-plugin-sndacs (0.0.2)
|
5
|
+
fluentd (~> 0.10.28)
|
6
|
+
sndacs (~> 0.2.4)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
cool.io (1.1.0)
|
12
|
+
iobuffer (>= 1.0.0)
|
13
|
+
fluentd (0.10.28)
|
14
|
+
cool.io (~> 1.1.0)
|
15
|
+
http_parser.rb (~> 0.5.1)
|
16
|
+
json (>= 1.4.3)
|
17
|
+
msgpack (~> 0.4.4)
|
18
|
+
yajl-ruby (~> 1.0)
|
19
|
+
http_parser.rb (0.5.3)
|
20
|
+
iobuffer (1.1.2)
|
21
|
+
json (1.7.5)
|
22
|
+
mime-types (1.19)
|
23
|
+
msgpack (0.4.7)
|
24
|
+
proxies (0.2.1)
|
25
|
+
sndacs (0.2.4)
|
26
|
+
mime-types
|
27
|
+
proxies (~> 0.2.0)
|
28
|
+
yajl-ruby (1.1.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
fluent-plugin-sndacs!
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Sndacs output plugin for Fluent event collector
|
2
|
+
=====
|
3
|
+
|
4
|
+
Configuration
|
5
|
+
-----
|
6
|
+
|
7
|
+
```
|
8
|
+
<match pattern>
|
9
|
+
type sndacs
|
10
|
+
|
11
|
+
access_key_id YOUR_ACCESS_KEY
|
12
|
+
secret_access_key YOUR_SECRET_KEY
|
13
|
+
bucket YOUR_BUCKET
|
14
|
+
buffer_path /var/log/fluent/sndacs
|
15
|
+
</match>
|
16
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = 'fluent-plugin-sndacs'
|
3
|
+
gem.description = 'Sndacs output plugin for Fluent event collector'
|
4
|
+
gem.homepage = 'https://github.com/sparkle/fluent-plugin-sndacs'
|
5
|
+
gem.summary = gem.description
|
6
|
+
gem.version = '0.0.2'
|
7
|
+
gem.authors = 'Sparkle'
|
8
|
+
gem.email = 'popeast@gmail.com'
|
9
|
+
gem.files = `git ls-files`.split("\n")
|
10
|
+
|
11
|
+
gem.add_dependency 'fluentd', '~>0.10.28'
|
12
|
+
gem.add_dependency 'sndacs', '~>0.2.4'
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Fluent
|
2
|
+
class SndacsOutput < Fluent::TimeSlicedOutput
|
3
|
+
Fluent::Plugin.register_output('sndacs', self)
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
require 'tempfile'
|
8
|
+
require 'zlib'
|
9
|
+
|
10
|
+
#A quick fix for the encoding problem
|
11
|
+
#see https://github.com/fluent/fluentd/issues/76
|
12
|
+
encoding = Encoding.default_internal
|
13
|
+
Encoding.default_internal = nil
|
14
|
+
require 'sndacs'
|
15
|
+
Encoding.default_internal = encoding
|
16
|
+
end
|
17
|
+
|
18
|
+
config_param :access_key_id, :string
|
19
|
+
config_param :secret_access_key, :string
|
20
|
+
config_param :bucket, :string
|
21
|
+
|
22
|
+
def configure(conf)
|
23
|
+
super
|
24
|
+
|
25
|
+
@formatter = TimeFormatter.new(nil, @localtime)
|
26
|
+
end
|
27
|
+
|
28
|
+
def start
|
29
|
+
super
|
30
|
+
service = Sndacs::Service.new(:access_key_id => @access_key_id,
|
31
|
+
:secret_access_key => @secret_access_key)
|
32
|
+
@bucket_ = service.buckets.find(@bucket)
|
33
|
+
end
|
34
|
+
|
35
|
+
def format(tag, time, record)
|
36
|
+
"#{@formatter.format(time)}\t#{tag}\t#{record.to_json}\n"
|
37
|
+
end
|
38
|
+
|
39
|
+
def write(chunk)
|
40
|
+
i = 1
|
41
|
+
while true
|
42
|
+
object = @bucket_.objects.build("#{chunk.key}_#{i}.gz")
|
43
|
+
break unless object.exists?
|
44
|
+
i += 1
|
45
|
+
end
|
46
|
+
|
47
|
+
file = Tempfile.new("sndacs-")
|
48
|
+
Zlib::GzipWriter.open(file) do |writer|
|
49
|
+
chunk.write_to(writer)
|
50
|
+
end
|
51
|
+
|
52
|
+
object.content = File.read(file)
|
53
|
+
object.save
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-sndacs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sparkle
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.10.28
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.10.28
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sndacs
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.2.4
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.4
|
46
|
+
description: Sndacs output plugin for Fluent event collector
|
47
|
+
email: popeast@gmail.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- Gemfile
|
53
|
+
- Gemfile.lock
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- fluent-plugin-sndacs.gemspec
|
57
|
+
- lib/fluent/plugin/out_sndacs.rb
|
58
|
+
homepage: https://github.com/sparkle/fluent-plugin-sndacs
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.23
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Sndacs output plugin for Fluent event collector
|
82
|
+
test_files: []
|