fluentd 0.10.29 → 0.10.30

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.30 - 2012/12/06
3
+
4
+ * Shows configuration file at start time
5
+ * Changed ruby version dependency from ~> 1.9.2 to => 1.9.2 so that it works
6
+ with ruby-2.0.
7
+ * TimeSlicedOutput: overwrites default value of buffer_chunk_limit to 256m.
8
+ fluent-plugin-s3 will be affected.
9
+ * TextParser/in_tail: supports 'nginx' preset formats
10
+ * in/out_forward and in_syslog: support IPv6
11
+ * out_forward: fixed a out of bounds bug
12
+
13
+
2
14
  Release 0.10.29 - 2012/11/26
3
15
 
4
16
  * buf_file: added flush_at_shutdown option to force flush before shuttingdown
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ begin
25
25
  gemspec.files = Dir["bin/**/*", "lib/**/*", "test/**/*.rb"] +
26
26
  %w[fluent.conf VERSION AUTHORS Rakefile COPYING fluentd.gemspec Gemfile]
27
27
  gemspec.executables = ['fluentd', 'fluent-cat', 'fluent-gem', 'fluent-debug']
28
- gemspec.required_ruby_version = '~> 1.9.2'
28
+ gemspec.required_ruby_version = '>= 1.9.2'
29
29
  end
30
30
  Jeweler::GemcutterTasks.new
31
31
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.29
1
+ 0.10.30
@@ -55,6 +55,8 @@ class EngineClass
55
55
  end
56
56
 
57
57
  def configure(conf)
58
+ $log.info "using configuration file: #{conf.to_s.rstrip}"
59
+
58
60
  conf.elements.select {|e|
59
61
  e.name == 'source'
60
62
  }.each {|e|
@@ -217,155 +217,4 @@ module SetTagKeyMixin
217
217
  end
218
218
  end
219
219
 
220
-
221
- #module PlainTextFormatterMixin
222
- # attr_accessor :output_include_time, :output_include_tag, :output_data_type
223
- # attr_accessor :output_add_newline, :output_field_separator
224
- #
225
- # def initialize
226
- # super
227
- # # default values may be overwriten by subclasses
228
- # @output_include_time = true
229
- # @output_include_tag = true
230
- # @output_data_type = 'json'
231
- # @output_field_separator = "\t"
232
- # @output_add_newline = true
233
- # end
234
- #
235
- # # config_param :output_data_type, :string, :default => 'json' # or 'attr:field' or 'attr:field1,field2,field3(...)'
236
- # def configure(conf)
237
- # super
238
- #
239
- # if output_include_time = conf['output_include_time']
240
- # @output_include_time = Config.bool_value(output_include_time)
241
- # end
242
- #
243
- # if output_include_tag = conf['output_include_tag']
244
- # @output_include_tag = Config.bool_value(output_include_tag)
245
- # end
246
- #
247
- # if output_data_type = conf['output_data_type']
248
- # @output_data_type = output_data_type
249
- # end
250
- #
251
- # if output_field_separator = conf['output_field_separator']
252
- # case output_field_separator
253
- # when 'SPACE'
254
- # @output_field_separator = ' '
255
- # when 'COMMA'
256
- # @output_field_separator = ','
257
- # else
258
- # raise ConfigError, "Unknown output_field_separator option #{output_field_separator.dump}"
259
- # end
260
- # end
261
- #
262
- # if output_add_newline = conf['output_add_newline']
263
- # @output_add_newline = Config.bool_value(output_add_newline)
264
- # end
265
- #
266
- # # default timezone: utc (localtime=nil)
267
- # if conf['localtime']
268
- # @localtime = true
269
- # elsif conf['utc']
270
- # @localtime = false
271
- # end
272
- #
273
- # # mix-in default time formatter (or you can overwrite @time_format/@localtime (or @timef itself) on your own configure)
274
- # if @output_include_time
275
- # timef = @timef || TimeFormatter.new(@time_format, @localtime)
276
- # end
277
- #
278
- # output_field_separator = @output_field_separator
279
- #
280
- # ##
281
- # # optimize stringify_record(record) method
282
- # #
283
- # case @output_data_type
284
- # when 'json'
285
- # define_singleton_method(:stringify_record) {|record|
286
- # record.to_json
287
- # }
288
- #
289
- # when /^attr:(.*)$/
290
- # out_keys = $1.split(',')
291
- # if out_keys.size > 1
292
- # define_singleton_method(:stringify_record) {|record|
293
- # out_keys.map {|attr|
294
- # r = record[attr]
295
- # r.respond_to?(:to_str) ? r.to_str : r.to_json
296
- # }.join(output_field_separator)
297
- # }
298
- # elsif out_keys.size == 1
299
- # out_key = out_keys[0]
300
- # define_singleton_method(:stringify_record) {|record|
301
- # r = record[out_key]
302
- # r.respond_to?(:to_str) ? r.to_str : r.to_json
303
- # }
304
- # else
305
- # raise ConfigError, "Invalid attributes specification: '#{@output_data_type}', needs one or more attributes."
306
- # end
307
- #
308
- # else
309
- # raise ConfigError, "Invalid output_data_type: '#{@output_data_type}'. specify 'json' or 'attr:ATTRIBUTE_NAME' or 'attr:ATTR1,ATTR2,...'"
310
- # end
311
- #
312
- # ##
313
- # # optimize format(tag, time, record) method
314
- # #
315
- # if @output_include_time and @output_include_tag
316
- # if @output_add_newline
317
- # define_singleton_method(:format) {|tag,time,record|
318
- # "#{timef.format(time)}#{output_field_separator}#{tag}#{output_field_separator}#{stringify_record(record)}\n"
319
- # }
320
- # else
321
- # define_singleton_method(:format) {|tag,time,record|
322
- # "#{timef.format(time)}#{output_field_separator}#{tag}#{output_field_separator}#{stringify_record(record)}"
323
- # }
324
- # end
325
- #
326
- # elsif @output_include_time
327
- # if @output_add_newline
328
- # define_singleton_method(:format) {|tag,time,record|
329
- # "#{timef.format(time)}#{output_field_separator}#{stringify_record(record)}\n"
330
- # }
331
- # else
332
- # define_singleton_method(:format) {|tag,time,record|
333
- # "#{timef.format(time)}#{output_field_separator}#{stringify_record(record)}"
334
- # }
335
- # end
336
- #
337
- # elsif @output_include_tag
338
- # if @output_add_newline
339
- # define_singleton_method(:format) {|tag,time,record|
340
- # "#{tag}#{output_field_separator}#{stringify_record(record)}\n"
341
- # }
342
- # else
343
- # define_singleton_method(:format) {|tag,time,record|
344
- # "#{tag}#{output_field_separator}#{stringify_record(record)}"
345
- # }
346
- # end
347
- #
348
- # else # without time, tag
349
- # if @output_add_newline
350
- # define_singleton_method(:format) {|tag,time,record|
351
- # "#{stringify_record(record)}\n"
352
- # }
353
- # else
354
- # define_singleton_method(:format) {|tag,time,record|
355
- # stringify_record(record)
356
- # }
357
- # end
358
- # end
359
- # end
360
- #
361
- # def stringify_record(record)
362
- # # will be overridden in configure
363
- # end
364
- #
365
- # def format(tag, time, record)
366
- # # will be overridden in configure
367
- # end
368
- #end
369
-
370
-
371
220
  end
@@ -451,6 +451,7 @@ class TimeSlicedOutput < BufferedOutput
451
451
  config_param :time_slice_format, :string, :default => '%Y%m%d'
452
452
  config_param :time_slice_wait, :time, :default => 10*60
453
453
  config_set_default :buffer_type, 'file' # overwrite default buffer_type
454
+ config_set_default :buffer_chunk_limit, 256*1024*1024 # overwrite default buffer_chunk_limit
454
455
  config_set_default :flush_interval, nil
455
456
 
456
457
  attr_accessor :localtime
@@ -205,6 +205,7 @@ class TextParser
205
205
  'json' => Proc.new { JSONParser.new },
206
206
  'tsv' => Proc.new { TSVParser.new },
207
207
  'csv' => Proc.new { CSVParser.new },
208
+ 'nginx' => Proc.new { RegexpParser.new(/^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$/, {'time_format'=>"%d/%b/%Y:%H:%M:%S %z"}) },
208
209
  }
209
210
 
210
211
  def self.register_template(name, regexp_or_proc, time_format=nil)
@@ -23,6 +23,7 @@ class ForwardInput < Input
23
23
 
24
24
  def initialize
25
25
  super
26
+ require 'fluent/plugin/socket_util'
26
27
  end
27
28
 
28
29
  config_param :port, :integer, :default => DEFAULT_LISTEN_PORT
@@ -38,7 +39,7 @@ class ForwardInput < Input
38
39
  @lsock = listen
39
40
  @loop.attach(@lsock)
40
41
 
41
- @usock = UDPSocket.new
42
+ @usock = SocketUtil.create_udp_socket(@bind)
42
43
  @usock.bind(@bind, @port)
43
44
  @hbr = HeartbeatRequestHandler.new(@usock, method(:on_heartbeat_request))
44
45
  @loop.attach(@hbr)
@@ -65,6 +65,7 @@ class SyslogInput < Input
65
65
 
66
66
  def initialize
67
67
  super
68
+ require 'fluent/plugin/socket_util'
68
69
  end
69
70
 
70
71
  config_param :port, :integer, :default => 5140
@@ -93,7 +94,7 @@ class SyslogInput < Input
93
94
  @loop = Coolio::Loop.new
94
95
 
95
96
  $log.debug "listening syslog socket on #{@bind}:#{@port}"
96
- @usock = UDPSocket.new
97
+ @usock = SocketUtil.create_udp_socket(@bind)
97
98
  @usock.bind(@bind, @port)
98
99
 
99
100
  @handler = UdpHandler.new(@usock, callback)
@@ -62,9 +62,6 @@ class FileOutput < TimeSlicedOutput
62
62
  conf['buffer_path'] ||= "#{@path}.*"
63
63
  end
64
64
 
65
- # override default buffer_chunk_limit
66
- conf['buffer_chunk_limit'] ||= '256m'
67
-
68
65
  super
69
66
 
70
67
  @timef = TimeFormatter.new(@time_format, @localtime)
@@ -25,6 +25,7 @@ class ForwardOutput < ObjectBufferedOutput
25
25
  super
26
26
  require 'socket'
27
27
  require 'fileutils'
28
+ require 'fluent/plugin/socket_util'
28
29
  @nodes = [] #=> [Node]
29
30
  end
30
31
 
@@ -88,7 +89,8 @@ class ForwardOutput < ObjectBufferedOutput
88
89
 
89
90
  @loop = Coolio::Loop.new
90
91
 
91
- @usock = UDPSocket.new
92
+ # Assume all hosts are same protocol.
93
+ @usock = SocketUtil.create_udp_socket(@nodes.first.host)
92
94
  @hb = HeartbeatHandler.new(@usock, method(:on_heartbeat))
93
95
  @loop.attach(@hb)
94
96
 
@@ -126,8 +128,8 @@ class ForwardOutput < ObjectBufferedOutput
126
128
 
127
129
  wlen = @weight_array.length
128
130
  wlen.times do
129
- node = @weight_array[@rr]
130
131
  @rr = (@rr + 1) % wlen
132
+ node = @weight_array[@rr]
131
133
 
132
134
  if node.available?
133
135
  begin
@@ -148,6 +150,7 @@ class ForwardOutput < ObjectBufferedOutput
148
150
  end
149
151
 
150
152
  private
153
+
151
154
  def rebuild_weight_array
152
155
  standby_nodes, regular_nodes = @nodes.partition {|n|
153
156
  n.standby?
@@ -0,0 +1,14 @@
1
+ module Fluent
2
+ module SocketUtil
3
+ def create_udp_socket(host)
4
+ require 'ipaddr'
5
+
6
+ if IPAddr.new(IPSocket.getaddress(host)).ipv4?
7
+ UDPSocket.new
8
+ else
9
+ UDPSocket.new(Socket::AF_INET6)
10
+ end
11
+ end
12
+ module_function :create_udp_socket
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
 
3
- VERSION = '0.10.29'
3
+ VERSION = '0.10.30'
4
4
 
5
5
  end
@@ -3,6 +3,7 @@ require 'fluent/test'
3
3
  class SyslogInputTest < Test::Unit::TestCase
4
4
  def setup
5
5
  Fluent::Test.setup
6
+ require 'fluent/plugin/socket_util'
6
7
  end
7
8
 
8
9
  CONFIG = %[
@@ -11,36 +12,46 @@ class SyslogInputTest < Test::Unit::TestCase
11
12
  tag syslog
12
13
  ]
13
14
 
15
+ IPv6_CONFIG = %[
16
+ port 9911
17
+ bind ::1
18
+ tag syslog
19
+ ]
20
+
14
21
  def create_driver(conf=CONFIG)
15
22
  Fluent::Test::InputTestDriver.new(Fluent::SyslogInput).configure(conf)
16
23
  end
17
24
 
18
25
  def test_configure
19
- d = create_driver
20
- assert_equal 9911, d.instance.port
21
- assert_equal '127.0.0.1', d.instance.bind
26
+ {'127.0.0.1' => CONFIG, '::1' => IPv6_CONFIG}.each_pair { |k, v|
27
+ d = create_driver(v)
28
+ assert_equal 9911, d.instance.port
29
+ assert_equal k, d.instance.bind
30
+ }
22
31
  end
23
32
 
24
33
  def test_time_format
25
- d = create_driver
34
+ {'127.0.0.1' => CONFIG, '::1' => IPv6_CONFIG}.each_pair { |k, v|
35
+ d = create_driver(v)
26
36
 
27
- tests = [
28
- {'msg' => '<6>Sep 11 00:00:00 localhost logger: foo', 'expected' => Time.strptime('Sep 11 00:00:00', '%b %d %H:%M:%S').to_i},
29
- {'msg' => '<6>Sep 1 00:00:00 localhost logger: foo', 'expected' => Time.strptime('Sep 1 00:00:00', '%b %d %H:%M:%S').to_i},
30
- ]
37
+ tests = [
38
+ {'msg' => '<6>Sep 11 00:00:00 localhost logger: foo', 'expected' => Time.strptime('Sep 11 00:00:00', '%b %d %H:%M:%S').to_i},
39
+ {'msg' => '<6>Sep 1 00:00:00 localhost logger: foo', 'expected' => Time.strptime('Sep 1 00:00:00', '%b %d %H:%M:%S').to_i},
40
+ ]
31
41
 
32
- d.run do
33
- u = UDPSocket.new
34
- u.connect('127.0.0.1', 9911)
35
- tests.each {|test|
36
- u.send(test['msg'], 0)
37
- }
38
- sleep 1
39
- end
42
+ d.run do
43
+ u = Fluent::SocketUtil.create_udp_socket(k)
44
+ u.connect(k, 9911)
45
+ tests.each {|test|
46
+ u.send(test['msg'], 0)
47
+ }
48
+ sleep 1
49
+ end
40
50
 
41
- emits = d.emits
42
- emits.each_index {|i|
43
- assert_equal(tests[i]['expected'], emits[i][1])
51
+ emits = d.emits
52
+ emits.each_index {|i|
53
+ assert_equal(tests[i]['expected'], emits[i][1])
54
+ }
44
55
  }
45
56
  end
46
57
 
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.29
4
+ version: 0.10.30
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
@@ -216,6 +216,7 @@ files:
216
216
  - lib/fluent/plugin/out_stdout.rb
217
217
  - lib/fluent/plugin/out_stream.rb
218
218
  - lib/fluent/plugin/out_test.rb
219
+ - lib/fluent/plugin/socket_util.rb
219
220
  - lib/fluent/process.rb
220
221
  - lib/fluent/status.rb
221
222
  - lib/fluent/supervisor.rb
@@ -254,7 +255,7 @@ require_paths:
254
255
  required_ruby_version: !ruby/object:Gem::Requirement
255
256
  none: false
256
257
  requirements:
257
- - - ~>
258
+ - - ! '>='
258
259
  - !ruby/object:Gem::Version
259
260
  version: 1.9.2
260
261
  required_rubygems_version: !ruby/object:Gem::Requirement