fluentd 0.10.7 → 0.10.8

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/ChangeLog CHANGED
@@ -1,4 +1,16 @@
1
1
 
2
+ Release 0.10.8 - 2011/12/03
3
+
4
+ * Added Supervisor: restart process on SIGHUP or unexpected end of process
5
+ * Added -i commandline option which allows inline config
6
+ * Added TimeSlicedOutputTestDriver
7
+ * BufferedOutput outputs 'retry suceeded' message
8
+ * Use Gem::Specification instead of Gem.searcher which is obsoleted
9
+ * Added BasicBuffer#chunk_limit -> buffer_chunk_limit alias for backward
10
+ compatibility
11
+ * buf_file: fixed to work with keys which contains '/'
12
+
13
+
2
14
  Release 0.10.7 - 2011/11/16
3
15
 
4
16
  * Supports multi-threaded on buffered output plugins ('num_threads')
data/README CHANGED
@@ -47,6 +47,7 @@ An event consists of *tag*, *time* and *record*. Tag is a string separated with
47
47
  $ fluentd &
48
48
  $ echo '{"json":"message"}' | fluent-cat debug.test
49
49
 
50
+ == Meta
50
51
 
51
52
  Web site:: http://fluentd.org/
52
53
  Documents:: http://fluentd.org/doc/
@@ -55,3 +56,10 @@ Author:: Sadayuki Furuhashi
55
56
  Copyright:: (c) 2011 FURUHASHI Sadayuki
56
57
  License:: Apache License, Version 2.0
57
58
 
59
+ Contributed by:
60
+
61
+ * Eiichiro Iwata
62
+ * Masahiro Nakagawa
63
+ * Takashi Nagayasu
64
+ * Yuichi Tateno
65
+
@@ -44,6 +44,8 @@ An event consists of *tag*, *time* and *record*. Tag is a string separated with
44
44
  == Quick Start
45
45
 
46
46
  $ gem install fluentd
47
+ $ # install sample configuration file to the directory
48
+ $ sudo fluentd -s
47
49
  $ fluentd &
48
50
  $ echo '{"json":"message"}' | fluent-cat debug.test
49
51
 
@@ -56,10 +58,17 @@ Author:: Sadayuki Furuhashi
56
58
  Copyright:: (c) 2011 FURUHASHI Sadayuki
57
59
  License:: Apache License, Version 2.0
58
60
 
59
- Contributed by:
61
+ == Contributors:
60
62
 
61
- * Eiichiro Iwata
62
- * Masahiro Nakagawa
63
- * Takashi Nagayasu
64
- * Yuichi Tateno
63
+ Patches contributed by:
65
64
 
65
+ * {Abhishek Parolkar}[https://github.com/parolkar]
66
+ * {Eiichiro Iwata}[http://github.com/eiichiroi]
67
+ * {Francesc Esplugas}[https://github.com/fesplugas]
68
+ * {hirochachacha}[https://github.com/hirochachacha]
69
+ * {Masahiro Nakagawa}[https://github.com/repeatedly]
70
+ * {Sakuro Ozawa}[https://github.com/sakuro]
71
+ * Takashi Nagayasu
72
+ * {Tsuyoshi Ozawa}[https://github.com/oza]
73
+ * {uu59}[https://github.com/uu59]
74
+ * {Yuichi Tateno}[https://github.com/hotchpotch]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.7
1
+ 0.10.8
@@ -124,6 +124,11 @@ class BasicBuffer < Buffer
124
124
  config_param :buffer_chunk_limit, :size, :default => 256*1024*1024
125
125
  config_param :buffer_queue_limit, :integer, :default => 128
126
126
 
127
+ alias chunk_limit buffer_chunk_limit
128
+ alias chunk_limit= buffer_chunk_limit=
129
+ alias queue_limit buffer_queue_limit
130
+ alias queue_limit= buffer_queue_limit=
131
+
127
132
  def configure(conf)
128
133
  super
129
134
  end
@@ -25,26 +25,28 @@ op = OptionParser.new
25
25
  op.version = Fluent::VERSION
26
26
 
27
27
  # default values
28
- config_path = Fluent::DEFAULT_CONFIG_PATH
29
- plugin_dirs = [Fluent::DEFAULT_PLUGIN_DIR]
30
- log_level = Fluent::Log::LEVEL_INFO
31
- log_file = nil
32
- daemonize = false
33
- libs = []
34
- setup_path = nil
35
- chuser = nil
36
- chgroup = nil
28
+ opts = {
29
+ :config_path => Fluent::DEFAULT_CONFIG_PATH,
30
+ :plugin_dirs => [Fluent::DEFAULT_PLUGIN_DIR],
31
+ :log_level => Fluent::Log::LEVEL_INFO,
32
+ :log_path => nil,
33
+ :daemonize => false,
34
+ :libs => [],
35
+ :setup_path => nil,
36
+ :chuser => nil,
37
+ :chgroup => nil,
38
+ }
37
39
 
38
40
  op.on('-s', "--setup [DIR=#{File.dirname(Fluent::DEFAULT_CONFIG_PATH)}]", "install sample configuration file to the directory") {|s|
39
- setup_path = s || File.dirname(Fluent::DEFAULT_CONFIG_PATH)
41
+ opts[:setup_path] = s || File.dirname(Fluent::DEFAULT_CONFIG_PATH)
40
42
  }
41
43
 
42
- op.on('-c', '--config PATH', "config flie path (default: #{config_path})") {|s|
43
- config_path = s
44
+ op.on('-c', '--config PATH', "config flie path (default: #{Fluent::DEFAULT_CONFIG_PATH})") {|s|
45
+ opts[:config_path] = s
44
46
  }
45
47
 
46
48
  op.on('-p', '--plugin DIR', "add plugin directory") {|s|
47
- plugin_dirs << s
49
+ opts[:plugin_dirs] << s
48
50
  }
49
51
 
50
52
  op.on('-I PATH', "add library path") {|s|
@@ -52,32 +54,37 @@ op.on('-I PATH', "add library path") {|s|
52
54
  }
53
55
 
54
56
  op.on('-r NAME', "load library") {|s|
55
- libs << s
57
+ opts[:libs] << s
56
58
  }
57
59
 
58
60
  op.on('-d', '--daemon PIDFILE', "daemonize fluent process") {|s|
59
- daemonize = s
61
+ opts[:daemonize] = s
60
62
  }
61
63
 
62
64
  op.on('--user USER', "change user") {|s|
63
- chuser = s
65
+ opts[:chuser] = s
64
66
  }
65
67
 
66
68
  op.on('--group GROUP', "change group") {|s|
67
- chgroup = s
69
+ opts[:chgroup] = s
68
70
  }
69
71
 
70
72
  op.on('-o', '--log PATH', "log file path") {|s|
71
- log_file = s
73
+ opts[:log_path] = s
74
+ }
75
+
76
+ op.on('-i', '--inline-config CONFIG_STRING', "inline config which is appended to the config file on-fly") {|s|
77
+ opts[:inline_config] = s
72
78
  }
73
79
 
80
+
74
81
  op.on('-v', '--verbose', "increment verbose level (-v: debug, -vv: trace)", TrueClass) {|b|
75
82
  if b
76
- case log_level
83
+ case opts[:log_level]
77
84
  when Fluent::Log::LEVEL_INFO
78
- log_level = Fluent::Log::LEVEL_DEBUG
85
+ opts[:log_level] = Fluent::Log::LEVEL_DEBUG
79
86
  when Fluent::Log::LEVEL_DEBUG
80
- log_level = Fluent::Log::LEVEL_TRACE
87
+ opts[:log_level] = Fluent::Log::LEVEL_TRACE
81
88
  end
82
89
  end
83
90
  }
@@ -101,7 +108,7 @@ rescue
101
108
  end
102
109
 
103
110
 
104
- if setup_path
111
+ if setup_path = opts[:setup_path]
105
112
  require 'fileutils'
106
113
  FileUtils.mkdir_p File.join(setup_path, "plugin")
107
114
  confpath = File.join(setup_path, "fluent.conf")
@@ -117,142 +124,6 @@ if setup_path
117
124
  exit 0
118
125
  end
119
126
 
120
-
121
- if log_file && log_file != "-"
122
- log_out = File.open(log_file, "a")
123
- else
124
- log_out = STDOUT
125
- end
126
-
127
- $log = Fluent::Log.new(log_out, log_level)
128
-
129
- $log.enable_color(false) if log_file
130
- $log.enable_debug if log_level <= Fluent::Log::LEVEL_DEBUG
131
-
132
-
133
- require 'fluent/load'
134
-
135
- begin
136
- #
137
- # read config file
138
- #
139
- $log.info "reading config file", :path=>config_path
140
- config_fname = File.basename(config_path)
141
- config_basedir = File.dirname(config_path)
142
- config_data = File.read(config_path)
143
-
144
-
145
- #
146
- # change user
147
- #
148
- if chgroup
149
- chgid = chgroup.to_i
150
- if chgid.to_s != chgroup
151
- chgid = `id -g #{chgroup}`.to_i
152
- if $?.to_i != 0
153
- exit 1
154
- end
155
- end
156
- Process::GID.change_privilege(chgid)
157
- end
158
-
159
- if chuser
160
- chuid = chuser.to_i
161
- if chuid.to_s != chuser
162
- chuid = `id -u #{chuser}`.to_i
163
- if $?.to_i != 0
164
- exit 1
165
- end
166
- end
167
- Process::UID.change_privilege(chuid)
168
- end
169
-
170
-
171
- #
172
- # run configure
173
- #
174
- Fluent::Engine.init
175
-
176
- libs.each {|lib|
177
- require lib
178
- }
179
-
180
- plugin_dirs.each {|dir|
181
- if Dir.exist?(dir)
182
- dir = File.expand_path(dir)
183
- Fluent::Engine.load_plugin_dir(dir)
184
- end
185
- }
186
-
187
- Fluent::Engine.parse_config(config_data, config_fname, config_basedir)
188
-
189
-
190
- #
191
- # daemonize
192
- #
193
- trap :INT do
194
- Fluent::Engine.stop
195
- end
196
-
197
- trap :TERM do
198
- Fluent::Engine.stop
199
- end
200
-
201
- trap :HUP do
202
- if log_file
203
- log_out.reopen(log_file, "a")
204
- end
205
- end
206
-
207
- trap :USR1 do
208
- $log.info "force flushing buffered events"
209
- Fluent::Engine.flush!
210
- end
211
-
212
- if daemonize
213
- exit!(0) if fork
214
- Process.setsid
215
- exit!(0) if fork
216
- File.umask(0)
217
- STDIN.reopen("/dev/null")
218
- STDOUT.reopen("/dev/null", "w")
219
- STDERR.reopen("/dev/null", "w")
220
- File.open(daemonize, "w") {|f|
221
- f.write Process.pid.to_s
222
- }
223
- end
224
-
225
-
226
- #
227
- # run
228
- #
229
- $log.info "running fluent-#{Fluent::VERSION}"
230
- Fluent::Engine.run
231
-
232
- rescue Fluent::ConfigError
233
- $log.error "config error", :file=>config_path, :error=>$!.to_s
234
- $log.debug_backtrace
235
-
236
- # also STDOUT
237
- if log_out != STDOUT
238
- console = Fluent::Log.new(STDOUT, log_level).enable_debug
239
- console.error "config error", :file=>config_path, :error=>$!.to_s
240
- console.debug_backtrace
241
- end
242
-
243
- exit 1
244
-
245
- rescue
246
- $log.error "unexpected error", :error=>$!.to_s
247
- $log.error_backtrace
248
-
249
- # also STDOUT
250
- if log_out != STDOUT
251
- console = Fluent::Log.new(STDOUT, log_level).enable_debug
252
- console.error "unexpected error", :error=>$!.to_s
253
- console.error_backtrace
254
- end
255
-
256
- exit 1
257
- end
127
+ require 'fluent/supervisor'
128
+ Fluent::Supervisor.new(opts).start
258
129
 
@@ -193,4 +193,154 @@ module SetTagKeyMixin
193
193
  end
194
194
 
195
195
 
196
+ #module PlainTextFormatterMixin
197
+ # attr_accessor :output_include_time, :output_include_tag, :output_data_type
198
+ # attr_accessor :output_add_newline, :output_field_separator
199
+ #
200
+ # def initialize
201
+ # super
202
+ # # default values may be overwriten by subclasses
203
+ # @output_include_time = true
204
+ # @output_include_tag = true
205
+ # @output_data_type = 'json'
206
+ # @output_field_separator = "\t"
207
+ # @output_add_newline = true
208
+ # end
209
+ #
210
+ # # config_param :output_data_type, :string, :default => 'json' # or 'attr:field' or 'attr:field1,field2,field3(...)'
211
+ # def configure(conf)
212
+ # super
213
+ #
214
+ # if output_include_time = conf['output_include_time']
215
+ # @output_include_time = Config.bool_value(output_include_time)
216
+ # end
217
+ #
218
+ # if output_include_tag = conf['output_include_tag']
219
+ # @output_include_tag = Config.bool_value(output_include_tag)
220
+ # end
221
+ #
222
+ # if output_data_type = conf['output_data_type']
223
+ # @output_data_type = output_data_type
224
+ # end
225
+ #
226
+ # if output_field_separator = conf['output_field_separator']
227
+ # case output_field_separator
228
+ # when 'SPACE'
229
+ # @output_field_separator = ' '
230
+ # when 'COMMA'
231
+ # @output_field_separator = ','
232
+ # else
233
+ # raise ConfigError, "Unknown output_field_separator option #{output_field_separator.dump}"
234
+ # end
235
+ # end
236
+ #
237
+ # if output_add_newline = conf['output_add_newline']
238
+ # @output_add_newline = Config.bool_value(output_add_newline)
239
+ # end
240
+ #
241
+ # # default timezone: utc (localtime=nil)
242
+ # if conf['localtime']
243
+ # @localtime = true
244
+ # elsif conf['utc']
245
+ # @localtime = false
246
+ # end
247
+ #
248
+ # # mix-in default time formatter (or you can overwrite @time_format/@localtime (or @timef itself) on your own configure)
249
+ # if @output_include_time
250
+ # timef = @timef || TimeFormatter.new(@time_format, @localtime)
251
+ # end
252
+ #
253
+ # output_field_separator = @output_field_separator
254
+ #
255
+ # ##
256
+ # # optimize stringify_record(record) method
257
+ # #
258
+ # case @output_data_type
259
+ # when 'json'
260
+ # define_singleton_method(:stringify_record) {|record|
261
+ # record.to_json
262
+ # }
263
+ #
264
+ # when /^attr:(.*)$/
265
+ # out_keys = $1.split(',')
266
+ # if out_keys.size > 1
267
+ # define_singleton_method(:stringify_record) {|record|
268
+ # out_keys.map {|attr|
269
+ # r = record[attr]
270
+ # r.respond_to?(:to_str) ? r.to_str : r.to_json
271
+ # }.join(output_field_separator)
272
+ # }
273
+ # elsif out_keys.size == 1
274
+ # out_key = out_keys[0]
275
+ # define_singleton_method(:stringify_record) {|record|
276
+ # r = record[out_key]
277
+ # r.respond_to?(:to_str) ? r.to_str : r.to_json
278
+ # }
279
+ # else
280
+ # raise ConfigError, "Invalid attributes specification: '#{@output_data_type}', needs one or more attributes."
281
+ # end
282
+ #
283
+ # else
284
+ # raise ConfigError, "Invalid output_data_type: '#{@output_data_type}'. specify 'json' or 'attr:ATTRIBUTE_NAME' or 'attr:ATTR1,ATTR2,...'"
285
+ # end
286
+ #
287
+ # ##
288
+ # # optimize format(tag, time, record) method
289
+ # #
290
+ # if @output_include_time and @output_include_tag
291
+ # if @output_add_newline
292
+ # define_singleton_method(:format) {|tag,time,record|
293
+ # "#{timef.format(time)}#{output_field_separator}#{tag}#{output_field_separator}#{stringify_record(record)}\n"
294
+ # }
295
+ # else
296
+ # define_singleton_method(:format) {|tag,time,record|
297
+ # "#{timef.format(time)}#{output_field_separator}#{tag}#{output_field_separator}#{stringify_record(record)}"
298
+ # }
299
+ # end
300
+ #
301
+ # elsif @output_include_time
302
+ # if @output_add_newline
303
+ # define_singleton_method(:format) {|tag,time,record|
304
+ # "#{timef.format(time)}#{output_field_separator}#{stringify_record(record)}\n"
305
+ # }
306
+ # else
307
+ # define_singleton_method(:format) {|tag,time,record|
308
+ # "#{timef.format(time)}#{output_field_separator}#{stringify_record(record)}"
309
+ # }
310
+ # end
311
+ #
312
+ # elsif @output_include_tag
313
+ # if @output_add_newline
314
+ # define_singleton_method(:format) {|tag,time,record|
315
+ # "#{tag}#{output_field_separator}#{stringify_record(record)}\n"
316
+ # }
317
+ # else
318
+ # define_singleton_method(:format) {|tag,time,record|
319
+ # "#{tag}#{output_field_separator}#{stringify_record(record)}"
320
+ # }
321
+ # end
322
+ #
323
+ # else # without time, tag
324
+ # if @output_add_newline
325
+ # define_singleton_method(:format) {|tag,time,record|
326
+ # "#{stringify_record(record)}\n"
327
+ # }
328
+ # else
329
+ # define_singleton_method(:format) {|tag,time,record|
330
+ # stringify_record(record)
331
+ # }
332
+ # end
333
+ # end
334
+ # end
335
+ #
336
+ # def stringify_record(record)
337
+ # # will be overridden in configure
338
+ # end
339
+ #
340
+ # def format(tag, time, record)
341
+ # # will be overridden in configure
342
+ # end
343
+ #end
344
+
345
+
196
346
  end