fluentd 0.10.32 → 0.10.33
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- data/.gitignore +20 -0
- data/.rvmrc +1 -0
- data/ChangeLog +13 -0
- data/Gemfile +3 -0
- data/Rakefile +4 -58
- data/fluent.conf +17 -8
- data/fluentd.gemspec +25 -155
- data/lib/fluent/buffer.rb +11 -0
- data/lib/fluent/config.rb +23 -0
- data/lib/fluent/input.rb +9 -8
- data/lib/fluent/mixin.rb +1 -0
- data/lib/fluent/output.rb +10 -7
- data/lib/fluent/plugin/in_monitor_agent.rb +288 -0
- data/lib/fluent/version.rb +1 -1
- metadata +49 -31
- data/VERSION +0 -1
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Gemfile.lock
|
2
|
+
INSTALL
|
3
|
+
NEWS
|
4
|
+
Makefile
|
5
|
+
Makefile.in
|
6
|
+
README
|
7
|
+
ac
|
8
|
+
aclocal.m4
|
9
|
+
autom4te.cache
|
10
|
+
confdefs.h
|
11
|
+
config.log
|
12
|
+
config.status
|
13
|
+
configure
|
14
|
+
deps/
|
15
|
+
fluent-cat
|
16
|
+
fluent-gem
|
17
|
+
fluentd
|
18
|
+
pkg/*
|
19
|
+
test/tmp/*
|
20
|
+
make_dist.sh
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.3
|
data/ChangeLog
CHANGED
@@ -1,4 +1,17 @@
|
|
1
1
|
|
2
|
+
Release 0.10.33 - 2013/03/28
|
3
|
+
|
4
|
+
* add in_monitor_agent
|
5
|
+
* switched from jeweler to bundler
|
6
|
+
* updated dependency for msgpack from '~> 0.4.4' to '~> 0.4.4 OR ~> 0.5.4'
|
7
|
+
* dded PluginId module so that in_monitor_agent can search plugins by id
|
8
|
+
* BufferedOutput: added queued_chunk_flush_interval option to insert delay
|
9
|
+
time before flushing queued chunks
|
10
|
+
* BufferedOutput: randomize retry interval to prevent multiple servers from
|
11
|
+
bursting network traffic at the same time
|
12
|
+
* Configurable: sets @config instance variable
|
13
|
+
|
14
|
+
|
2
15
|
Release 0.10.32 - 2013/03/04
|
3
16
|
|
4
17
|
* in_tail: fixed the nil error problem which occurs with pos_file option
|
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,52 +1,9 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
2
4
|
require 'rake/testtask'
|
3
5
|
require 'rake/clean'
|
4
6
|
|
5
|
-
begin
|
6
|
-
require 'jeweler'
|
7
|
-
Jeweler::Tasks.new do |gemspec|
|
8
|
-
gemspec.name = "fluentd"
|
9
|
-
gemspec.summary = "Fluent event collector"
|
10
|
-
gemspec.author = "Sadayuki Furuhashi"
|
11
|
-
gemspec.email = "frsyuki@gmail.com"
|
12
|
-
gemspec.homepage = "http://fluentd.org/"
|
13
|
-
gemspec.has_rdoc = false
|
14
|
-
gemspec.require_paths = ["lib"]
|
15
|
-
gemspec.add_dependency "msgpack", "~> 0.4.4"
|
16
|
-
gemspec.add_dependency "json", ">= 1.4.3"
|
17
|
-
gemspec.add_dependency "yajl-ruby", "~> 1.0"
|
18
|
-
gemspec.add_dependency "cool.io", "~> 1.1.0"
|
19
|
-
gemspec.add_dependency "http_parser.rb", "~> 0.5.1"
|
20
|
-
gemspec.add_development_dependency "rake", ">= 0.9.2"
|
21
|
-
gemspec.add_development_dependency "rr", ">= 1.0.0"
|
22
|
-
gemspec.add_development_dependency "timecop", ">= 0.3.0"
|
23
|
-
gemspec.add_development_dependency "jeweler", ">= 1.0.0"
|
24
|
-
gemspec.test_files = Dir["test/**/*.rb"]
|
25
|
-
gemspec.files = Dir["bin/**/*", "lib/**/*", "test/**/*.rb"] +
|
26
|
-
%w[fluent.conf VERSION AUTHORS Rakefile COPYING fluentd.gemspec Gemfile]
|
27
|
-
gemspec.executables = ['fluentd', 'fluent-cat', 'fluent-gem', 'fluent-debug']
|
28
|
-
gemspec.required_ruby_version = '>= 1.9.2'
|
29
|
-
end
|
30
|
-
Jeweler::GemcutterTasks.new
|
31
|
-
rescue LoadError
|
32
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
33
|
-
end
|
34
|
-
|
35
|
-
VERSION_FILE = "lib/fluent/version.rb"
|
36
|
-
|
37
|
-
file VERSION_FILE => ["VERSION"] do |t|
|
38
|
-
version = File.read("VERSION").strip
|
39
|
-
File.open(VERSION_FILE, "w") {|f|
|
40
|
-
f.write <<EOF
|
41
|
-
module Fluent
|
42
|
-
|
43
|
-
VERSION = '#{version}'
|
44
|
-
|
45
|
-
end
|
46
|
-
EOF
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
7
|
task :test => [:base_test]
|
51
8
|
|
52
9
|
Rake::TestTask.new(:base_test) do |t|
|
@@ -56,15 +13,4 @@ Rake::TestTask.new(:base_test) do |t|
|
|
56
13
|
#t.warning = true
|
57
14
|
end
|
58
15
|
|
59
|
-
|
60
|
-
task :mv_gemfile do
|
61
|
-
File.rename "Gemfile", "Gemfile.bak" rescue nil
|
62
|
-
end
|
63
|
-
|
64
|
-
# workaround for fluentd >= 0 dependency
|
65
|
-
task :revert_gemfile do
|
66
|
-
File.rename "Gemfile.bak", "Gemfile" rescue nil
|
67
|
-
end
|
68
|
-
|
69
|
-
task :default => [VERSION_FILE, :mv_gemfile, :build, :revert_gemfile]
|
70
|
-
|
16
|
+
task :default => [:test, :build]
|
data/fluent.conf
CHANGED
@@ -26,6 +26,15 @@
|
|
26
26
|
# tag apache.access
|
27
27
|
#</source>
|
28
28
|
|
29
|
+
# Listen HTTP for monitoring
|
30
|
+
# http://localhost:24220/api/plugins
|
31
|
+
# http://localhost:24220/api/plugins?type=TYPE
|
32
|
+
# http://localhost:24220/api/plugins?tag=MYTAG
|
33
|
+
<source>
|
34
|
+
type monitor_agent
|
35
|
+
port 24220
|
36
|
+
</source>
|
37
|
+
|
29
38
|
# Listen DRb for debug
|
30
39
|
<source>
|
31
40
|
type debug_agent
|
@@ -44,14 +53,14 @@
|
|
44
53
|
type stdout
|
45
54
|
</match>
|
46
55
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
56
|
+
# match tag=system.** and forward to another fluent server
|
57
|
+
<match system.**>
|
58
|
+
type forward
|
59
|
+
host 192.168.0.11
|
60
|
+
<secondary>
|
61
|
+
host 192.168.0.12
|
62
|
+
</secondary>
|
63
|
+
</match>
|
55
64
|
|
56
65
|
## match tag=myapp.** and forward and write to file
|
57
66
|
#<match myapp.**>
|
data/fluentd.gemspec
CHANGED
@@ -1,160 +1,30 @@
|
|
1
|
-
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
require File.expand_path('../lib/fluent/version', __FILE__)
|
5
2
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "fluentd"
|
5
|
+
gem.version = Fluent::VERSION # see lib/fluent/version.rb
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"ChangeLog",
|
17
|
-
"README",
|
18
|
-
"README.rdoc"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
"AUTHORS",
|
22
|
-
"COPYING",
|
23
|
-
"Gemfile",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"bin/fluent-cat",
|
27
|
-
"bin/fluent-gem",
|
28
|
-
"bin/fluentd",
|
29
|
-
"fluent.conf",
|
30
|
-
"fluentd.gemspec",
|
31
|
-
"lib/fluent/buffer.rb",
|
32
|
-
"lib/fluent/command/cat.rb",
|
33
|
-
"lib/fluent/command/fluentd.rb",
|
34
|
-
"lib/fluent/config.rb",
|
35
|
-
"lib/fluent/engine.rb",
|
36
|
-
"lib/fluent/env.rb",
|
37
|
-
"lib/fluent/event.rb",
|
38
|
-
"lib/fluent/input.rb",
|
39
|
-
"lib/fluent/load.rb",
|
40
|
-
"lib/fluent/log.rb",
|
41
|
-
"lib/fluent/match.rb",
|
42
|
-
"lib/fluent/mixin.rb",
|
43
|
-
"lib/fluent/output.rb",
|
44
|
-
"lib/fluent/parser.rb",
|
45
|
-
"lib/fluent/plugin.rb",
|
46
|
-
"lib/fluent/plugin/buf_file.rb",
|
47
|
-
"lib/fluent/plugin/buf_memory.rb",
|
48
|
-
"lib/fluent/plugin/buf_zfile.rb",
|
49
|
-
"lib/fluent/plugin/in_exec.rb",
|
50
|
-
"lib/fluent/plugin/in_forward.rb",
|
51
|
-
"lib/fluent/plugin/in_http.rb",
|
52
|
-
"lib/fluent/plugin/in_status.rb",
|
53
|
-
"lib/fluent/plugin/in_stream.rb",
|
54
|
-
"lib/fluent/plugin/in_syslog.rb",
|
55
|
-
"lib/fluent/plugin/in_tail.rb",
|
56
|
-
"lib/fluent/plugin/out_copy.rb",
|
57
|
-
"lib/fluent/plugin/out_exec.rb",
|
58
|
-
"lib/fluent/plugin/out_exec_filter.rb",
|
59
|
-
"lib/fluent/plugin/out_file.rb",
|
60
|
-
"lib/fluent/plugin/out_forward.rb",
|
61
|
-
"lib/fluent/plugin/out_null.rb",
|
62
|
-
"lib/fluent/plugin/out_roundrobin.rb",
|
63
|
-
"lib/fluent/plugin/out_stdout.rb",
|
64
|
-
"lib/fluent/plugin/out_stream.rb",
|
65
|
-
"lib/fluent/plugin/out_test.rb",
|
66
|
-
"lib/fluent/process.rb",
|
67
|
-
"lib/fluent/status.rb",
|
68
|
-
"lib/fluent/supervisor.rb",
|
69
|
-
"lib/fluent/test.rb",
|
70
|
-
"lib/fluent/test/base.rb",
|
71
|
-
"lib/fluent/test/input_test.rb",
|
72
|
-
"lib/fluent/test/output_test.rb",
|
73
|
-
"lib/fluent/version.rb",
|
74
|
-
"test/config.rb",
|
75
|
-
"test/helper.rb",
|
76
|
-
"test/match.rb",
|
77
|
-
"test/mixin.rb",
|
78
|
-
"test/plugin/in_exec.rb",
|
79
|
-
"test/plugin/in_forward.rb",
|
80
|
-
"test/plugin/in_http.rb",
|
81
|
-
"test/plugin/in_stream.rb",
|
82
|
-
"test/plugin/out_copy.rb",
|
83
|
-
"test/plugin/out_exec.rb",
|
84
|
-
"test/plugin/out_exec_filter.rb",
|
85
|
-
"test/plugin/out_file.rb",
|
86
|
-
"test/plugin/out_forward.rb",
|
87
|
-
"test/plugin/out_roundrobin.rb",
|
88
|
-
"test/plugin/out_stream.rb"
|
89
|
-
]
|
90
|
-
s.homepage = "http://fluentd.org/"
|
91
|
-
s.require_paths = ["lib"]
|
92
|
-
s.required_ruby_version = Gem::Requirement.new("~> 1.9.2")
|
93
|
-
s.rubygems_version = "1.8.12"
|
94
|
-
s.summary = "Fluent event collector"
|
95
|
-
s.test_files = ["test/config.rb", "test/helper.rb", "test/match.rb", "test/mixin.rb", "test/plugin/in_exec.rb", "test/plugin/in_forward.rb", "test/plugin/in_http.rb", "test/plugin/in_stream.rb", "test/plugin/out_copy.rb", "test/plugin/out_exec.rb", "test/plugin/out_exec_filter.rb", "test/plugin/out_file.rb", "test/plugin/out_forward.rb", "test/plugin/out_roundrobin.rb", "test/plugin/out_stream.rb"]
|
7
|
+
gem.authors = ["Sadayuki Furuhashi"]
|
8
|
+
gem.email = ["frsyuki@gmail.com"]
|
9
|
+
gem.description = %q{Fluentd is an event collector system. It is a generalized version of syslogd, which handles JSON objects for its log messages}
|
10
|
+
gem.summary = %q{Fluentd event collector}
|
11
|
+
gem.homepage = "http://fluentd.org/"
|
96
12
|
|
97
|
-
|
98
|
-
|
13
|
+
gem.files = `git ls-files`.split($\)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.has_rdoc = false
|
99
18
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
s.add_development_dependency(%q<rr>, [">= 1.0.0"])
|
108
|
-
s.add_development_dependency(%q<timecop>, [">= 0.3.0"])
|
109
|
-
s.add_development_dependency(%q<jeweler>, [">= 1.0.0"])
|
110
|
-
s.add_runtime_dependency(%q<msgpack>, ["~> 0.4.4"])
|
111
|
-
s.add_runtime_dependency(%q<json>, [">= 1.4.3"])
|
112
|
-
s.add_runtime_dependency(%q<yajl-ruby>, ["~> 1.0"])
|
113
|
-
s.add_runtime_dependency(%q<cool.io>, ["~> 1.1.0"])
|
114
|
-
s.add_runtime_dependency(%q<http_parser.rb>, ["~> 0.5.1"])
|
115
|
-
s.add_development_dependency(%q<rake>, [">= 0.9.2"])
|
116
|
-
s.add_development_dependency(%q<rr>, [">= 1.0.0"])
|
117
|
-
s.add_development_dependency(%q<timecop>, [">= 0.3.0"])
|
118
|
-
s.add_development_dependency(%q<jeweler>, [">= 1.0.0"])
|
119
|
-
else
|
120
|
-
s.add_dependency(%q<fluentd>, [">= 0"])
|
121
|
-
s.add_dependency(%q<rake>, [">= 0.9.2"])
|
122
|
-
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
123
|
-
s.add_dependency(%q<timecop>, [">= 0.3.0"])
|
124
|
-
s.add_dependency(%q<jeweler>, [">= 1.0.0"])
|
125
|
-
s.add_dependency(%q<rake>, [">= 0.9.2"])
|
126
|
-
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
127
|
-
s.add_dependency(%q<timecop>, [">= 0.3.0"])
|
128
|
-
s.add_dependency(%q<jeweler>, [">= 1.0.0"])
|
129
|
-
s.add_dependency(%q<msgpack>, ["~> 0.4.4"])
|
130
|
-
s.add_dependency(%q<json>, [">= 1.4.3"])
|
131
|
-
s.add_dependency(%q<yajl-ruby>, ["~> 1.0"])
|
132
|
-
s.add_dependency(%q<cool.io>, ["~> 1.1.0"])
|
133
|
-
s.add_dependency(%q<http_parser.rb>, ["~> 0.5.1"])
|
134
|
-
s.add_dependency(%q<rake>, [">= 0.9.2"])
|
135
|
-
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
136
|
-
s.add_dependency(%q<timecop>, [">= 0.3.0"])
|
137
|
-
s.add_dependency(%q<jeweler>, [">= 1.0.0"])
|
138
|
-
end
|
139
|
-
else
|
140
|
-
s.add_dependency(%q<fluentd>, [">= 0"])
|
141
|
-
s.add_dependency(%q<rake>, [">= 0.9.2"])
|
142
|
-
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
143
|
-
s.add_dependency(%q<timecop>, [">= 0.3.0"])
|
144
|
-
s.add_dependency(%q<jeweler>, [">= 1.0.0"])
|
145
|
-
s.add_dependency(%q<rake>, [">= 0.9.2"])
|
146
|
-
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
147
|
-
s.add_dependency(%q<timecop>, [">= 0.3.0"])
|
148
|
-
s.add_dependency(%q<jeweler>, [">= 1.0.0"])
|
149
|
-
s.add_dependency(%q<msgpack>, ["~> 0.4.4"])
|
150
|
-
s.add_dependency(%q<json>, [">= 1.4.3"])
|
151
|
-
s.add_dependency(%q<yajl-ruby>, ["~> 1.0"])
|
152
|
-
s.add_dependency(%q<cool.io>, ["~> 1.1.0"])
|
153
|
-
s.add_dependency(%q<http_parser.rb>, ["~> 0.5.1"])
|
154
|
-
s.add_dependency(%q<rake>, [">= 0.9.2"])
|
155
|
-
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
156
|
-
s.add_dependency(%q<timecop>, [">= 0.3.0"])
|
157
|
-
s.add_dependency(%q<jeweler>, [">= 1.0.0"])
|
158
|
-
end
|
159
|
-
end
|
19
|
+
gem.required_ruby_version = '>= 1.9.2'
|
20
|
+
|
21
|
+
gem.add_runtime_dependency(%q<msgpack>, [">= 0.4.4", "!= 0.5.0", "!= 0.5.1", "!= 0.5.2", "!= 0.5.3", "< 0.6.0"])
|
22
|
+
gem.add_runtime_dependency(%q<json>, [">= 1.4.3"])
|
23
|
+
gem.add_runtime_dependency(%q<yajl-ruby>, ["~> 1.0"])
|
24
|
+
gem.add_runtime_dependency(%q<cool.io>, ["~> 1.1.0"])
|
25
|
+
gem.add_runtime_dependency(%q<http_parser.rb>, ["~> 0.5.1"])
|
160
26
|
|
27
|
+
gem.add_development_dependency(%q<rake>, [">= 0.9.2"])
|
28
|
+
gem.add_development_dependency(%q<rr>, [">= 1.0.0"])
|
29
|
+
gem.add_development_dependency(%q<timecop>, [">= 0.3.0"])
|
30
|
+
end
|
data/lib/fluent/buffer.rb
CHANGED
@@ -219,6 +219,17 @@ class BasicBuffer < Buffer
|
|
219
219
|
@queue.size
|
220
220
|
end
|
221
221
|
|
222
|
+
def total_queued_chunk_size
|
223
|
+
total = 0
|
224
|
+
@map.each_value {|c|
|
225
|
+
total += c.size
|
226
|
+
}
|
227
|
+
@queue.each {|c|
|
228
|
+
total += c.size
|
229
|
+
}
|
230
|
+
total
|
231
|
+
end
|
232
|
+
|
222
233
|
#def new_chunk(key)
|
223
234
|
#end
|
224
235
|
|
data/lib/fluent/config.rb
CHANGED
@@ -233,6 +233,8 @@ end
|
|
233
233
|
|
234
234
|
|
235
235
|
module Configurable
|
236
|
+
attr_reader :config
|
237
|
+
|
236
238
|
def self.included(mod)
|
237
239
|
mod.extend(ClassMethods)
|
238
240
|
end
|
@@ -245,6 +247,8 @@ module Configurable
|
|
245
247
|
end
|
246
248
|
|
247
249
|
def configure(conf)
|
250
|
+
@config = conf
|
251
|
+
|
248
252
|
self.class.config_params.each_pair {|name,(block,opts)|
|
249
253
|
varname = :"@#{name}"
|
250
254
|
if val = conf[name.to_s]
|
@@ -356,5 +360,24 @@ module Configurable
|
|
356
360
|
end
|
357
361
|
|
358
362
|
|
363
|
+
module PluginId
|
364
|
+
def configure(conf)
|
365
|
+
@id = conf['id']
|
366
|
+
super
|
367
|
+
end
|
368
|
+
|
369
|
+
def require_id
|
370
|
+
unless @id
|
371
|
+
raise ConfigError, "'id' parameter is required"
|
372
|
+
end
|
373
|
+
@id
|
374
|
+
end
|
375
|
+
|
376
|
+
def plugin_id
|
377
|
+
@id ? @id : "object:#{object_id.to_s(16)}"
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
|
359
382
|
end
|
360
383
|
|
data/lib/fluent/input.rb
CHANGED
@@ -20,20 +20,21 @@ module Fluent
|
|
20
20
|
|
21
21
|
class Input
|
22
22
|
include Configurable
|
23
|
+
include PluginId
|
23
24
|
|
24
|
-
|
25
|
+
def initialize
|
25
26
|
super
|
26
|
-
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
+
def configure(conf)
|
29
30
|
super
|
30
|
-
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
def start
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
def shutdown
|
37
|
+
end
|
37
38
|
end
|
38
39
|
|
39
40
|
|
data/lib/fluent/mixin.rb
CHANGED
data/lib/fluent/output.rb
CHANGED
@@ -48,6 +48,7 @@ end
|
|
48
48
|
|
49
49
|
class Output
|
50
50
|
include Configurable
|
51
|
+
include PluginId
|
51
52
|
|
52
53
|
def initialize
|
53
54
|
super
|
@@ -164,6 +165,7 @@ class BufferedOutput < Output
|
|
164
165
|
config_param :retry_limit, :integer, :default => 17
|
165
166
|
config_param :retry_wait, :time, :default => 1.0
|
166
167
|
config_param :num_threads, :integer, :default => 1
|
168
|
+
config_param :queued_chunk_flush_interval, :time, :default => 1
|
167
169
|
|
168
170
|
def configure(conf)
|
169
171
|
super
|
@@ -301,7 +303,7 @@ class BufferedOutput < Output
|
|
301
303
|
end
|
302
304
|
|
303
305
|
if has_next
|
304
|
-
return
|
306
|
+
return Engine.now + @queued_chunk_flush_interval
|
305
307
|
else
|
306
308
|
return time + 1 # TODO 1
|
307
309
|
end
|
@@ -370,12 +372,13 @@ class BufferedOutput < Output
|
|
370
372
|
|
371
373
|
def calc_retry_wait
|
372
374
|
# TODO retry pattern
|
373
|
-
if @error_history.size <= @retry_limit
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
375
|
+
wait = if @error_history.size <= @retry_limit
|
376
|
+
@retry_wait * (2 ** (@error_history.size-1))
|
377
|
+
else
|
378
|
+
# secondary retry
|
379
|
+
@retry_wait * (2 ** (@error_history.size-2-@retry_limit))
|
380
|
+
end
|
381
|
+
wait + (rand * (wait / 4.0) - (wait / 8.0))
|
379
382
|
end
|
380
383
|
|
381
384
|
def write_abort
|
@@ -0,0 +1,288 @@
|
|
1
|
+
#
|
2
|
+
# Fluent
|
3
|
+
#
|
4
|
+
# Copyright (C) 2011 FURUHASHI Sadayuki
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module Fluent
|
19
|
+
|
20
|
+
class MonitorAgentInput < Input
|
21
|
+
Plugin.register_input('monitor_agent', self)
|
22
|
+
|
23
|
+
require 'webrick'
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
require 'cgi'
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
config_param :bind, :string, :default => '0.0.0.0'
|
31
|
+
config_param :port, :integer, :default => 24220
|
32
|
+
|
33
|
+
class MonitorServlet < WEBrick::HTTPServlet::AbstractServlet
|
34
|
+
def initialize(server, agent)
|
35
|
+
@agent = agent
|
36
|
+
end
|
37
|
+
|
38
|
+
def do_GET(req, res)
|
39
|
+
begin
|
40
|
+
code, header, body = process(req, res)
|
41
|
+
rescue
|
42
|
+
code, header, body = render_json_error(500, {
|
43
|
+
'message '=> 'Internal Server Error',
|
44
|
+
'error' => "#{$!}",
|
45
|
+
'backgrace'=> $!.backtrace,
|
46
|
+
})
|
47
|
+
end
|
48
|
+
|
49
|
+
# set response code, header and body
|
50
|
+
res.status = code
|
51
|
+
header.each_pair {|k,v|
|
52
|
+
res[k] = v
|
53
|
+
}
|
54
|
+
res.body = body
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_object(req, res)
|
58
|
+
unless req.path_info == ""
|
59
|
+
return render_json_error(404, "Not found")
|
60
|
+
end
|
61
|
+
|
62
|
+
# parse ?=query string
|
63
|
+
if req.query_string
|
64
|
+
begin
|
65
|
+
qs = CGI.parse(req.query_string)
|
66
|
+
rescue
|
67
|
+
return render_json_error(400, "Invalid query string")
|
68
|
+
end
|
69
|
+
else
|
70
|
+
qs = Hash.new {|h,k| [] }
|
71
|
+
end
|
72
|
+
|
73
|
+
# if ?debug=1 is set, set :with_debug_info for get_monitor_info
|
74
|
+
# and :pretty_json for render_json_error
|
75
|
+
opts = {}
|
76
|
+
if s = qs['debug'] and s[0]
|
77
|
+
opts[:with_debug_info] = true
|
78
|
+
opts[:pretty_json] = true
|
79
|
+
end
|
80
|
+
|
81
|
+
if tags = qs['tag'] and tag = tags[0]
|
82
|
+
# ?tag= to search an output plugin by match pattern
|
83
|
+
if obj = @agent.plugin_info_by_tag(tag, opts)
|
84
|
+
list = [obj]
|
85
|
+
else
|
86
|
+
list = []
|
87
|
+
end
|
88
|
+
|
89
|
+
elsif plugin_ids = qs['id'] and plugin_id = plugin_ids[0]
|
90
|
+
# ?id= to search a plugin by 'id <plugin_id>' config param
|
91
|
+
if obj = @agent.plugin_info_by_id(plugin_id, opts)
|
92
|
+
list = [obj]
|
93
|
+
else
|
94
|
+
list = []
|
95
|
+
end
|
96
|
+
|
97
|
+
elsif types = qs['type'] and type = types[0]
|
98
|
+
# ?type= to search plugins by 'type <type>' config param
|
99
|
+
list = @agent.plugins_info_by_type(type, opts)
|
100
|
+
|
101
|
+
else
|
102
|
+
# otherwise show all plugins
|
103
|
+
list = @agent.plugins_info_all(opts)
|
104
|
+
end
|
105
|
+
|
106
|
+
return list, opts
|
107
|
+
end
|
108
|
+
|
109
|
+
def render_json(obj, opts={})
|
110
|
+
render_json_error(200, obj, opts)
|
111
|
+
end
|
112
|
+
|
113
|
+
def render_json_error(code, obj, opts={})
|
114
|
+
if opts[:pretty_json]
|
115
|
+
js = JSON.pretty_generate(obj)
|
116
|
+
else
|
117
|
+
js = obj.to_json
|
118
|
+
end
|
119
|
+
[code, {'Content-Type'=>'application/json'}, js]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class LTSVMonitorServlet < MonitorServlet
|
124
|
+
def process(req, res)
|
125
|
+
list, opts = build_object(req, res)
|
126
|
+
return unless list
|
127
|
+
|
128
|
+
normalized = JSON.parse(list.to_json)
|
129
|
+
|
130
|
+
text = ''
|
131
|
+
|
132
|
+
normalized.map {|hash|
|
133
|
+
row = []
|
134
|
+
hash.each_pair {|k,v|
|
135
|
+
unless v.is_a?(Hash) || v.is_a?(Array)
|
136
|
+
row << "#{k}:#{v}"
|
137
|
+
end
|
138
|
+
}
|
139
|
+
text << row.join("\t") << "\n"
|
140
|
+
}
|
141
|
+
|
142
|
+
[200, {'Content-Type'=>'text/plain'}, text]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class JSONMonitorServlet < MonitorServlet
|
147
|
+
def process(req, res)
|
148
|
+
list, opts = build_object(req, res)
|
149
|
+
return unless list
|
150
|
+
|
151
|
+
render_json({
|
152
|
+
'plugins' => list
|
153
|
+
}, opts)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def start
|
158
|
+
$log.debug "listening monitoring http server on http://#{@bind}:#{@port}/api/plugins"
|
159
|
+
@srv = WEBrick::HTTPServer.new({
|
160
|
+
:BindAddress => @bind,
|
161
|
+
:Port => @port,
|
162
|
+
:Logger => WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
|
163
|
+
:AccessLog => [],
|
164
|
+
})
|
165
|
+
@srv.mount('/api/plugins', LTSVMonitorServlet, self)
|
166
|
+
@srv.mount('/api/plugins.json', JSONMonitorServlet, self)
|
167
|
+
@thread = Thread.new {
|
168
|
+
@srv.start
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
def shutdown
|
173
|
+
if @srv
|
174
|
+
@srv.shutdown
|
175
|
+
@srv = nil
|
176
|
+
end
|
177
|
+
if @thread
|
178
|
+
@thread.join
|
179
|
+
@thread = nil
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
MONITOR_INFO = {
|
184
|
+
'plugin_id' => 'plugin_id',
|
185
|
+
'type' => 'config["type"]',
|
186
|
+
'output_plugin' => 'is_a?(::Fluent::Output)',
|
187
|
+
'buffer_queue_length' => '@buffer.queue_size',
|
188
|
+
'buffer_total_queued_size' => '@buffer.total_queued_chunk_size',
|
189
|
+
'retry_count' => '@error_history.size',
|
190
|
+
'config' => 'config',
|
191
|
+
}
|
192
|
+
|
193
|
+
def all_plugins
|
194
|
+
array = []
|
195
|
+
|
196
|
+
# get all input plugins
|
197
|
+
array.concat Engine.sources
|
198
|
+
|
199
|
+
# get all output plugins
|
200
|
+
Engine.matches.each {|m|
|
201
|
+
MonitorAgentInput.collect_children(m.output, array)
|
202
|
+
}
|
203
|
+
|
204
|
+
array
|
205
|
+
end
|
206
|
+
|
207
|
+
# get nexted plugins (such as <store> of the copy plugin)
|
208
|
+
# from the plugin `pe` recursively
|
209
|
+
def self.collect_children(pe, array=[])
|
210
|
+
array << pe
|
211
|
+
if pe.is_a?(MultiOutput) && pe.respond_to?(:outputs)
|
212
|
+
pe.outputs.each {|nop|
|
213
|
+
collect_children(nop, array)
|
214
|
+
}
|
215
|
+
end
|
216
|
+
array
|
217
|
+
end
|
218
|
+
|
219
|
+
# try to match the tag and get the info from the
|
220
|
+
# matched output plugin
|
221
|
+
def plugin_info_by_tag(tag, opts={})
|
222
|
+
m = Engine.match(tag)
|
223
|
+
if m
|
224
|
+
pe = m.output
|
225
|
+
get_monitor_info(pe, opts)
|
226
|
+
else
|
227
|
+
nil
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# search a plugin by plugin_id
|
232
|
+
def plugin_info_by_id(plugin_id, opts={})
|
233
|
+
found = all_plugins.find {|pe|
|
234
|
+
pe.respond_to?(:plugin_id) && pe.plugin_id.to_s == plugin_id
|
235
|
+
}
|
236
|
+
if found
|
237
|
+
get_monitor_info(found, opts)
|
238
|
+
else
|
239
|
+
nil
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
# This method returns an array because
|
244
|
+
# multiple plugins could have the same type
|
245
|
+
def plugins_info_by_type(type, opts={})
|
246
|
+
array = all_plugins.select {|pe|
|
247
|
+
pe.config['type'] == type rescue nil
|
248
|
+
}
|
249
|
+
array.map {|pe|
|
250
|
+
get_monitor_info(pe, opts)
|
251
|
+
}
|
252
|
+
end
|
253
|
+
|
254
|
+
def plugins_info_all(opts={})
|
255
|
+
all_plugins.map {|pe|
|
256
|
+
get_monitor_info(pe, opts)
|
257
|
+
}
|
258
|
+
end
|
259
|
+
|
260
|
+
# get monitor info from the plugin `pe` and return a hash object
|
261
|
+
def get_monitor_info(pe, opts={})
|
262
|
+
obj = {}
|
263
|
+
|
264
|
+
# run MONITOR_INFO in plugins' instance context and store the info to obj
|
265
|
+
MONITOR_INFO.each_pair {|key,code|
|
266
|
+
begin
|
267
|
+
obj[key] = pe.instance_eval(code)
|
268
|
+
rescue
|
269
|
+
end
|
270
|
+
}
|
271
|
+
|
272
|
+
# include all instance variables if :with_debug_info is set
|
273
|
+
if opts[:with_debug_info]
|
274
|
+
iv = {}
|
275
|
+
pe.instance_eval do
|
276
|
+
instance_variables.each {|sym|
|
277
|
+
key = sym.to_s[1..-1] # removes first '@'
|
278
|
+
iv[key] = instance_variable_get(sym)
|
279
|
+
}
|
280
|
+
end
|
281
|
+
obj['instance_variables'] = iv
|
282
|
+
end
|
283
|
+
|
284
|
+
obj
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
data/lib/fluent/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluentd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.33
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,54 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 0.4.4
|
22
|
+
- - ! '!='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.5.0
|
25
|
+
- - ! '!='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.5.1
|
28
|
+
- - ! '!='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.5.2
|
31
|
+
- - ! '!='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.3
|
34
|
+
- - <
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.6.0
|
22
37
|
type: :runtime
|
23
38
|
prerelease: false
|
24
39
|
version_requirements: !ruby/object:Gem::Requirement
|
25
40
|
none: false
|
26
41
|
requirements:
|
27
|
-
- -
|
42
|
+
- - ! '>='
|
28
43
|
- !ruby/object:Gem::Version
|
29
44
|
version: 0.4.4
|
45
|
+
- - ! '!='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.5.0
|
48
|
+
- - ! '!='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 0.5.1
|
51
|
+
- - ! '!='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.5.2
|
54
|
+
- - ! '!='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.5.3
|
57
|
+
- - <
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.6.0
|
30
60
|
- !ruby/object:Gem::Dependency
|
31
61
|
name: json
|
32
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,38 +169,26 @@ dependencies:
|
|
139
169
|
- - ! '>='
|
140
170
|
- !ruby/object:Gem::Version
|
141
171
|
version: 0.3.0
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 1.0.0
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 1.0.0
|
158
|
-
description:
|
159
|
-
email: frsyuki@gmail.com
|
172
|
+
description: Fluentd is an event collector system. It is a generalized version of
|
173
|
+
syslogd, which handles JSON objects for its log messages
|
174
|
+
email:
|
175
|
+
- frsyuki@gmail.com
|
160
176
|
executables:
|
161
|
-
- fluentd
|
162
177
|
- fluent-cat
|
163
|
-
- fluent-gem
|
164
178
|
- fluent-debug
|
179
|
+
- fluent-gem
|
180
|
+
- fluentd
|
165
181
|
extensions: []
|
166
|
-
extra_rdoc_files:
|
167
|
-
- ChangeLog
|
168
|
-
- README.rdoc
|
182
|
+
extra_rdoc_files: []
|
169
183
|
files:
|
184
|
+
- .gitignore
|
185
|
+
- .rvmrc
|
170
186
|
- AUTHORS
|
171
187
|
- COPYING
|
188
|
+
- ChangeLog
|
189
|
+
- Gemfile
|
190
|
+
- README.rdoc
|
172
191
|
- Rakefile
|
173
|
-
- VERSION
|
174
192
|
- bin/fluent-cat
|
175
193
|
- bin/fluent-debug
|
176
194
|
- bin/fluent-gem
|
@@ -201,6 +219,7 @@ files:
|
|
201
219
|
- lib/fluent/plugin/in_forward.rb
|
202
220
|
- lib/fluent/plugin/in_gc_stat.rb
|
203
221
|
- lib/fluent/plugin/in_http.rb
|
222
|
+
- lib/fluent/plugin/in_monitor_agent.rb
|
204
223
|
- lib/fluent/plugin/in_object_space.rb
|
205
224
|
- lib/fluent/plugin/in_status.rb
|
206
225
|
- lib/fluent/plugin/in_stream.rb
|
@@ -247,8 +266,6 @@ files:
|
|
247
266
|
- test/plugin/out_roundrobin.rb
|
248
267
|
- test/plugin/out_stdout.rb
|
249
268
|
- test/plugin/out_stream.rb
|
250
|
-
- ChangeLog
|
251
|
-
- README.rdoc
|
252
269
|
homepage: http://fluentd.org/
|
253
270
|
licenses: []
|
254
271
|
post_install_message:
|
@@ -272,7 +289,7 @@ rubyforge_project:
|
|
272
289
|
rubygems_version: 1.8.23
|
273
290
|
signing_key:
|
274
291
|
specification_version: 3
|
275
|
-
summary:
|
292
|
+
summary: Fluentd event collector
|
276
293
|
test_files:
|
277
294
|
- test/config.rb
|
278
295
|
- test/helper.rb
|
@@ -296,3 +313,4 @@ test_files:
|
|
296
313
|
- test/plugin/out_roundrobin.rb
|
297
314
|
- test/plugin/out_stdout.rb
|
298
315
|
- test/plugin/out_stream.rb
|
316
|
+
has_rdoc: false
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.10.32
|