fluentd 0.12.30 → 0.12.31

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63a646de1e8fe70118ebe431f68ab2492486c094
4
- data.tar.gz: 2f5d57af5036d8197aa5bcb92061498d273031e2
3
+ metadata.gz: 0aa9f8f4d0ebedebdba427af533a3b6b67eb7bcd
4
+ data.tar.gz: f69ae9d212c29b4c68303460aa10a9c21aa2080a
5
5
  SHA512:
6
- metadata.gz: b5a6242bf2ee47e9aa32ad27bb9af3c67643a9d6b41decc801afaee842758a2dfd18b2bd32fabe2e21eadb293d370bd2a06c0b05e3d609f0ba97bed6325c42b4
7
- data.tar.gz: 0bfabdc2a87e25ca1106b6df6d1193ebe2bd6dd7c47ac8b32050877d3ab5fe9ba7b9d94222f6cd8b0002c1a2dcf37fbaf3d541f385386b9d60237f582b735fd9
6
+ metadata.gz: 4a89d78f39a8f3d5ced5460274db3e0c8ac7923fe68e9dc0d119225f912aa30a37a067f5d7c403f156f12491d9bd3440eeb82913cf7e3092ce49199b9c7ddb4b
7
+ data.tar.gz: a3009318c51d0f8dcd774521c67b0935c6d619d5cd8b506e126cd3bf2e55c24c39c8150fca88cfb0eb25eaa0fae4fbf778f482d6fd26e52ea03d990c49c6fddb
data/ChangeLog CHANGED
@@ -1,5 +1,16 @@
1
1
  # v0.12
2
2
 
3
+ ## Release 0.12.31 - 2016/12/14
4
+
5
+ ### New features / Enhancement
6
+
7
+ * output: Add slow_flush_log_threshold parameter
8
+ https://github.com/fluent/fluentd/pull/1366
9
+ * formatter_csv: Change fields parameter to required. Now accepts both a,b and ["a", "b"]
10
+ https://github.com/fluent/fluentd/pull/1361
11
+ * in_syslog: Add "priority_key" and "facility_key" parameters
12
+ https://github.com/fluent/fluentd/pull/1351
13
+
3
14
  ## Release 0.12.30 - 2016/12/01
4
15
 
5
16
  ### New features / Enhancement
@@ -30,12 +30,12 @@ Gem::Specification.new do |gem|
30
30
  gem.add_runtime_dependency("string-scrub", [">= 0.0.3", "<= 0.0.5"])
31
31
 
32
32
  gem.add_development_dependency("rake", [">= 0.9.2"])
33
- gem.add_development_dependency("flexmock", ["~> 1.3.3"])
34
- gem.add_development_dependency("parallel_tests", [">= 0.15.3"])
35
- gem.add_development_dependency("simplecov", ["~> 0.6.4"])
36
- gem.add_development_dependency("rr", [">= 1.0.0"])
37
- gem.add_development_dependency("timecop", [">= 0.3.0"])
38
- gem.add_development_dependency("test-unit", ["~> 3.1.4"])
39
- gem.add_development_dependency("test-unit-rr", ["~> 1.0.3"])
33
+ gem.add_development_dependency("flexmock", ["~> 2.0"])
34
+ gem.add_development_dependency("parallel_tests", ["~> 0.15.3"])
35
+ gem.add_development_dependency("simplecov", ["~> 0.7"])
36
+ gem.add_development_dependency("rr", ["~> 1.0"])
37
+ gem.add_development_dependency("timecop", ["~> 0.3"])
38
+ gem.add_development_dependency("test-unit", ["~> 3.2"])
39
+ gem.add_development_dependency("test-unit-rr", ["~> 1.0"])
40
40
  gem.add_development_dependency("oj", ["~> 2.14"])
41
41
  end
@@ -196,26 +196,28 @@ module Fluent
196
196
  ['\t', 'TAB'].include?(val) ? "\t" : val
197
197
  end
198
198
  config_param :force_quotes, :bool, default: true
199
- config_param :fields, default: [] do |val|
200
- val.split(',').map do |f|
201
- f.strip!
202
- f.size > 0 ? f : nil
203
- end.compact
204
- end
199
+ config_param :fields, :array, value_type: :string
205
200
 
206
201
  def initialize
207
202
  super
208
203
  require 'csv'
209
204
  end
210
205
 
206
+ def configure(conf)
207
+ super
208
+ @fields = fields.select { |f| !f.empty? }
209
+ raise ConfigError, "empty value is specified in fields parameter" if @fields.empty?
210
+
211
+ @generate_opts = {col_sep: @delimiter, force_quotes: @force_quotes}
212
+ end
213
+
211
214
  def format(tag, time, record)
212
215
  filter_record(tag, time, record)
213
216
  row = @fields.inject([]) do |memo, key|
214
217
  memo << record[key]
215
218
  memo
216
219
  end
217
- CSV.generate_line(row, col_sep: @delimiter,
218
- force_quotes: @force_quotes)
220
+ CSV.generate_line(row, @generate_opts)
219
221
  end
220
222
  end
221
223
 
@@ -203,6 +203,8 @@ module Fluent
203
203
  config_param :max_retry_wait, :time, default: nil
204
204
  desc 'The number of threads to flush the buffer.'
205
205
  config_param :num_threads, :integer, default: 1
206
+ desc 'The threshold to show slow flush logs'
207
+ config_param :slow_flush_log_threshold, :float, default: 20.0
206
208
  desc 'The interval between data flushes for queued chunk.'
207
209
  config_param :queued_chunk_flush_interval, :time, default: 1
208
210
 
@@ -332,12 +334,20 @@ module Fluent
332
334
  end
333
335
  end
334
336
 
337
+ chunk_write_start = Time.now
338
+
335
339
  if @secondary && !@disable_retry_limit && @num_errors > @retry_limit
336
340
  has_next = flush_secondary(@secondary)
337
341
  else
338
342
  has_next = @buffer.pop(self)
339
343
  end
340
344
 
345
+ elapsed_time = Time.now - chunk_write_start
346
+ if elapsed_time > @slow_flush_log_threshold
347
+ $log.warn "buffer flush took longer time than slow_flush_log_threshold:",
348
+ plugin_id: plugin_id, elapsed_time: elapsed_time, slow_flush_log_threshold: @slow_flush_log_threshold
349
+ end
350
+
341
351
  # success
342
352
  if retrying
343
353
  @num_errors = 0
@@ -500,6 +510,7 @@ module Fluent
500
510
  config_set_default :buffer_type, 'file' # overwrite default buffer_type
501
511
  config_set_default :buffer_chunk_limit, 256*1024*1024 # overwrite default buffer_chunk_limit
502
512
  config_set_default :flush_interval, nil
513
+ config_set_default :slow_flush_log_threshold, 40.0
503
514
 
504
515
  attr_accessor :localtime
505
516
  attr_reader :time_slicer # for test
@@ -91,6 +91,10 @@ module Fluent
91
91
  config_param :include_source_host, :bool, default: false
92
92
  desc 'Specify key of source host when include_source_host is true.'
93
93
  config_param :source_host_key, :string, default: 'source_host'.freeze
94
+ desc 'The field name of the priority.'
95
+ config_param :priority_key, :string, default: nil
96
+ desc 'The field name of the facility.'
97
+ config_param :facility_key, :string, default: nil
94
98
  config_param :blocking_timeout, :time, default: 0.5
95
99
  config_param :message_length_limit, :size, default: 2048
96
100
 
@@ -153,8 +157,15 @@ module Fluent
153
157
  return
154
158
  end
155
159
 
160
+ facility = FACILITY_MAP[pri >> 3]
161
+ priority = PRIORITY_MAP[pri & 0b111]
162
+
163
+ record[@priority_key] = priority if @priority_key
164
+ record[@facility_key] = facility if @facility_key
156
165
  record[@source_host_key] = addr[2] if @include_source_host
157
- emit(pri, time, record)
166
+
167
+ tag = "#{@tag}.#{facility}.#{priority}"
168
+ emit(tag, time, record)
158
169
  }
159
170
  rescue => e
160
171
  log.error data.dump, error: e.to_s
@@ -168,9 +179,16 @@ module Fluent
168
179
  return
169
180
  end
170
181
 
171
- pri = record.delete('pri')
182
+ pri = record.delete('pri'.freeze)
183
+ facility = FACILITY_MAP[pri >> 3]
184
+ priority = PRIORITY_MAP[pri & 0b111]
185
+
186
+ record[@priority_key] = priority if @priority_key
187
+ record[@facility_key] = facility if @facility_key
172
188
  record[@source_host_key] = addr[2] if @include_source_host
173
- emit(pri, time, record)
189
+
190
+ tag = "#{@tag}.#{facility}.#{priority}"
191
+ emit(tag, time, record)
174
192
  }
175
193
  rescue => e
176
194
  log.error data.dump, error: e.to_s
@@ -191,12 +209,7 @@ module Fluent
191
209
  end
192
210
  end
193
211
 
194
- def emit(pri, time, record)
195
- facility = FACILITY_MAP[pri >> 3]
196
- priority = PRIORITY_MAP[pri & 0b111]
197
-
198
- tag = "#{@tag}.#{facility}.#{priority}"
199
-
212
+ def emit(tag, time, record)
200
213
  router.emit(tag, time, record)
201
214
  rescue => e
202
215
  log.error "syslog failed to emit", error: e.to_s, error_class: e.class.to_s, tag: tag, record: Yajl.dump(record)
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '0.12.30'
19
+ VERSION = '0.12.31'
20
20
 
21
21
  end
@@ -57,6 +57,7 @@ class SyslogInputTest < Test::Unit::TestCase
57
57
  end
58
58
 
59
59
  emits = d.emits
60
+ assert_equal 2, emits.size
60
61
  emits.each_index {|i|
61
62
  assert_equal(tests[i]['expected'], emits[i][1])
62
63
  }
@@ -76,6 +77,7 @@ class SyslogInputTest < Test::Unit::TestCase
76
77
  sleep 1
77
78
  end
78
79
 
80
+ assert_equal 2, d.emits.size
79
81
  compare_test_result(d.emits, tests)
80
82
  end
81
83
 
@@ -94,6 +96,7 @@ class SyslogInputTest < Test::Unit::TestCase
94
96
  sleep 1
95
97
  end
96
98
 
99
+ assert_equal 3, d.emits.size
97
100
  compare_test_result(d.emits, tests)
98
101
  end
99
102
 
@@ -110,6 +113,7 @@ class SyslogInputTest < Test::Unit::TestCase
110
113
  sleep 1
111
114
  end
112
115
 
116
+ assert_equal 2, d.emits.size
113
117
  compare_test_result(d.emits, tests)
114
118
  end
115
119
 
@@ -126,6 +130,7 @@ class SyslogInputTest < Test::Unit::TestCase
126
130
  sleep 1
127
131
  end
128
132
 
133
+ assert_equal 2, d.emits.size
129
134
  compare_test_result(d.emits, tests)
130
135
  end
131
136
 
@@ -146,6 +151,7 @@ class SyslogInputTest < Test::Unit::TestCase
146
151
  sleep 1
147
152
  end
148
153
 
154
+ assert_equal 2, d.emits.size
149
155
  compare_test_result(d.emits, tests)
150
156
  end
151
157
 
@@ -164,7 +170,44 @@ class SyslogInputTest < Test::Unit::TestCase
164
170
  sleep 1
165
171
  end
166
172
 
167
- compare_test_result(d.emits, tests, host)
173
+ assert_equal 2, d.emits.size
174
+ compare_test_result(d.emits, tests, {host: host})
175
+ end
176
+
177
+ def test_msg_size_with_include_priority
178
+ d = create_driver([CONFIG, 'priority_key priority'].join("\n"))
179
+ tests = create_test_case
180
+
181
+ priority = 'info'
182
+ d.run do
183
+ u = UDPSocket.new
184
+ u.connect('127.0.0.1', PORT)
185
+ tests.each {|test|
186
+ u.send(test['msg'], 0)
187
+ }
188
+ sleep 1
189
+ end
190
+
191
+ assert_equal 2, d.emits.size
192
+ compare_test_result(d.emits, tests, {priority: priority})
193
+ end
194
+
195
+ def test_msg_size_with_include_facility
196
+ d = create_driver([CONFIG, 'facility_key facility'].join("\n"))
197
+ tests = create_test_case
198
+
199
+ facility = 'kern'
200
+ d.run do
201
+ u = UDPSocket.new
202
+ u.connect('127.0.0.1', PORT)
203
+ tests.each {|test|
204
+ u.send(test['msg'], 0)
205
+ }
206
+ sleep 1
207
+ end
208
+
209
+ assert_equal 2, d.emits.size
210
+ compare_test_result(d.emits, tests, {facility: facility})
168
211
  end
169
212
 
170
213
  def create_test_case(large_message = false)
@@ -183,11 +226,13 @@ class SyslogInputTest < Test::Unit::TestCase
183
226
  end
184
227
  end
185
228
 
186
- def compare_test_result(emits, tests, host = nil)
187
- emits.each_index { |i|
188
- assert_equal('syslog.kern.info', emits[0][0]) # <6> means kern.info
189
- assert_equal(tests[i]['expected'], emits[i][2]['message'])
190
- assert_equal(host, emits[i][2]['source_host']) if host
229
+ def compare_test_result(events, tests, options = {})
230
+ events.each_index { |i|
231
+ assert_equal('syslog.kern.info', events[i][0]) # <6> means kern.info
232
+ assert_equal(tests[i]['expected'], events[i][2]['message'])
233
+ assert_equal(options[:host], events[i][2]['source_host']) if options[:host]
234
+ assert_equal(options[:priority], events[i][2]['priority']) if options[:priority]
235
+ assert_equal(options[:facility], events[i][2]['facility']) if options[:facility]
191
236
  }
192
237
  end
193
238
  end
@@ -289,7 +289,15 @@ module FormatterTest
289
289
  def test_config_params
290
290
  assert_equal ',', @formatter.delimiter
291
291
  assert_equal true, @formatter.force_quotes
292
- assert_equal [], @formatter.fields
292
+ assert_nil @formatter.fields
293
+ end
294
+
295
+ data('empty array' => [],
296
+ 'array including empty string' => ['', ''])
297
+ def test_empty_fields(param)
298
+ assert_raise ConfigError do
299
+ @formatter.configure('fields' => param)
300
+ end
293
301
  end
294
302
 
295
303
  data(
@@ -298,7 +306,7 @@ module FormatterTest
298
306
  'pipe' => ['|', '|'])
299
307
  def test_config_params_with_customized_delimiters(data)
300
308
  expected, target = data
301
- @formatter.configure('delimiter' => target)
309
+ @formatter.configure('fields' => 'f1', 'delimiter' => target)
302
310
  assert_equal expected, @formatter.delimiter
303
311
  end
304
312
 
@@ -47,6 +47,7 @@ module FluentOutputTest
47
47
  assert_equal nil, d.instance.max_retry_wait
48
48
  assert_equal 1.0, d.instance.retry_wait
49
49
  assert_equal 1, d.instance.num_threads
50
+ assert_equal 20.0, d.instance.slow_flush_log_threshold
50
51
  assert_equal 1, d.instance.queued_chunk_flush_interval
51
52
 
52
53
  # max_retry_wait
@@ -201,6 +202,68 @@ module FluentOutputTest
201
202
  10.times { sleep 0.05 }
202
203
  end
203
204
  end
205
+
206
+ sub_test_case "test slow_flush_log_threshold" do
207
+ def create_slow_driver(conf, sleep_time)
208
+ d = Fluent::Test::BufferedOutputTestDriver.new(Fluent::BufferedOutput) do
209
+ attr_accessor :sleep_time
210
+
211
+ def initialize
212
+ super
213
+ @_written_check_mutex = Mutex.new
214
+ @_written_check = false
215
+ end
216
+
217
+ def written_check
218
+ @_written_check_mutex.synchronize { @_written_check }
219
+ end
220
+
221
+ def write(chunk)
222
+ sleep @sleep_time
223
+ end
224
+
225
+ def try_flush
226
+ super
227
+ @_written_check_mutex.synchronize { @_written_check = true }
228
+ end
229
+ end.configure(conf)
230
+ d.instance.sleep_time = sleep_time
231
+ d
232
+ end
233
+
234
+ def setup
235
+ # output#try_flush uses $log, so it should be replaced
236
+ @orig_log = $log
237
+ $log = Fluent::Test::TestLogger.new
238
+ end
239
+
240
+ def teardown
241
+ $log = @orig_log
242
+ end
243
+
244
+ test "flush took longer time than slow_flush_log_threshold" do
245
+ d = create_slow_driver(%[
246
+ slow_flush_log_threshold 0.5
247
+ ], 1.5)
248
+ run_driver(d)
249
+ assert_equal 1, $log.logs.count { |line| line =~ /buffer flush took longer time than slow_flush_log_threshold:/ }
250
+ end
251
+
252
+ test "flush took lower time than slow_flush_log_threshold. No logs" do
253
+ d = create_slow_driver(%[
254
+ slow_flush_log_threshold 5.0
255
+ ], 0)
256
+ run_driver(d)
257
+ assert_equal 0, $log.logs.count { |line| line =~ /buffer flush took longer time than slow_flush_log_threshold:/ }
258
+ end
259
+
260
+ def run_driver(d)
261
+ d.instance.start
262
+ d.instance.emit('test', OneEventStream.new(@time.to_i, {"message" => "foo"}), NullOutputChain.instance)
263
+ d.instance.force_flush
264
+ until d.instance.written_check; end
265
+ end
266
+ end
204
267
  end
205
268
 
206
269
  class TimeSlicedOutputTest < ::Test::Unit::TestCase
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.30
4
+ version: 0.12.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-01 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -180,26 +180,26 @@ dependencies:
180
180
  requirements:
181
181
  - - "~>"
182
182
  - !ruby/object:Gem::Version
183
- version: 1.3.3
183
+ version: '2.0'
184
184
  type: :development
185
185
  prerelease: false
186
186
  version_requirements: !ruby/object:Gem::Requirement
187
187
  requirements:
188
188
  - - "~>"
189
189
  - !ruby/object:Gem::Version
190
- version: 1.3.3
190
+ version: '2.0'
191
191
  - !ruby/object:Gem::Dependency
192
192
  name: parallel_tests
193
193
  requirement: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - ">="
195
+ - - "~>"
196
196
  - !ruby/object:Gem::Version
197
197
  version: 0.15.3
198
198
  type: :development
199
199
  prerelease: false
200
200
  version_requirements: !ruby/object:Gem::Requirement
201
201
  requirements:
202
- - - ">="
202
+ - - "~>"
203
203
  - !ruby/object:Gem::Version
204
204
  version: 0.15.3
205
205
  - !ruby/object:Gem::Dependency
@@ -208,70 +208,70 @@ dependencies:
208
208
  requirements:
209
209
  - - "~>"
210
210
  - !ruby/object:Gem::Version
211
- version: 0.6.4
211
+ version: '0.7'
212
212
  type: :development
213
213
  prerelease: false
214
214
  version_requirements: !ruby/object:Gem::Requirement
215
215
  requirements:
216
216
  - - "~>"
217
217
  - !ruby/object:Gem::Version
218
- version: 0.6.4
218
+ version: '0.7'
219
219
  - !ruby/object:Gem::Dependency
220
220
  name: rr
221
221
  requirement: !ruby/object:Gem::Requirement
222
222
  requirements:
223
- - - ">="
223
+ - - "~>"
224
224
  - !ruby/object:Gem::Version
225
- version: 1.0.0
225
+ version: '1.0'
226
226
  type: :development
227
227
  prerelease: false
228
228
  version_requirements: !ruby/object:Gem::Requirement
229
229
  requirements:
230
- - - ">="
230
+ - - "~>"
231
231
  - !ruby/object:Gem::Version
232
- version: 1.0.0
232
+ version: '1.0'
233
233
  - !ruby/object:Gem::Dependency
234
234
  name: timecop
235
235
  requirement: !ruby/object:Gem::Requirement
236
236
  requirements:
237
- - - ">="
237
+ - - "~>"
238
238
  - !ruby/object:Gem::Version
239
- version: 0.3.0
239
+ version: '0.3'
240
240
  type: :development
241
241
  prerelease: false
242
242
  version_requirements: !ruby/object:Gem::Requirement
243
243
  requirements:
244
- - - ">="
244
+ - - "~>"
245
245
  - !ruby/object:Gem::Version
246
- version: 0.3.0
246
+ version: '0.3'
247
247
  - !ruby/object:Gem::Dependency
248
248
  name: test-unit
249
249
  requirement: !ruby/object:Gem::Requirement
250
250
  requirements:
251
251
  - - "~>"
252
252
  - !ruby/object:Gem::Version
253
- version: 3.1.4
253
+ version: '3.2'
254
254
  type: :development
255
255
  prerelease: false
256
256
  version_requirements: !ruby/object:Gem::Requirement
257
257
  requirements:
258
258
  - - "~>"
259
259
  - !ruby/object:Gem::Version
260
- version: 3.1.4
260
+ version: '3.2'
261
261
  - !ruby/object:Gem::Dependency
262
262
  name: test-unit-rr
263
263
  requirement: !ruby/object:Gem::Requirement
264
264
  requirements:
265
265
  - - "~>"
266
266
  - !ruby/object:Gem::Version
267
- version: 1.0.3
267
+ version: '1.0'
268
268
  type: :development
269
269
  prerelease: false
270
270
  version_requirements: !ruby/object:Gem::Requirement
271
271
  requirements:
272
272
  - - "~>"
273
273
  - !ruby/object:Gem::Version
274
- version: 1.0.3
274
+ version: '1.0'
275
275
  - !ruby/object:Gem::Dependency
276
276
  name: oj
277
277
  requirement: !ruby/object:Gem::Requirement