fluentd 0.14.1 → 0.14.2

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.

Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +110 -1
  3. data/Rakefile +5 -1
  4. data/appveyor.yml +7 -1
  5. data/example/in_forward.conf +4 -0
  6. data/lib/fluent/compat/exec_util.rb +129 -0
  7. data/lib/fluent/compat/file_util.rb +54 -0
  8. data/lib/fluent/compat/filter.rb +21 -3
  9. data/lib/fluent/compat/formatter.rb +4 -2
  10. data/lib/fluent/compat/formatter_utils.rb +85 -0
  11. data/lib/fluent/compat/handle_tag_and_time_mixin.rb +60 -0
  12. data/lib/fluent/compat/input.rb +1 -3
  13. data/lib/fluent/compat/output.rb +95 -39
  14. data/lib/fluent/compat/parser.rb +17 -0
  15. data/lib/fluent/compat/parser_utils.rb +40 -0
  16. data/lib/fluent/compat/socket_util.rb +165 -0
  17. data/lib/fluent/compat/string_util.rb +34 -0
  18. data/lib/fluent/{test/driver/owner.rb → compat/structured_format_mixin.rb} +5 -11
  19. data/lib/fluent/config/element.rb +2 -2
  20. data/lib/fluent/configurable.rb +2 -1
  21. data/lib/fluent/event.rb +61 -7
  22. data/lib/fluent/event_router.rb +1 -1
  23. data/lib/fluent/plugin.rb +7 -7
  24. data/lib/fluent/plugin/buf_file.rb +5 -2
  25. data/lib/fluent/plugin/buffer.rb +194 -64
  26. data/lib/fluent/plugin/buffer/chunk.rb +28 -3
  27. data/lib/fluent/plugin/buffer/file_chunk.rb +5 -21
  28. data/lib/fluent/plugin/buffer/memory_chunk.rb +1 -11
  29. data/lib/fluent/plugin/exec_util.rb +2 -112
  30. data/lib/fluent/plugin/file_util.rb +3 -38
  31. data/lib/fluent/plugin/file_wrapper.rb +1 -1
  32. data/lib/fluent/plugin/filter_grep.rb +3 -7
  33. data/lib/fluent/plugin/filter_record_transformer.rb +5 -5
  34. data/lib/fluent/plugin/filter_stdout.rb +18 -11
  35. data/lib/fluent/plugin/formatter.rb +0 -48
  36. data/lib/fluent/plugin/formatter_csv.rb +7 -8
  37. data/lib/fluent/plugin/formatter_hash.rb +1 -4
  38. data/lib/fluent/plugin/formatter_json.rb +1 -4
  39. data/lib/fluent/plugin/formatter_ltsv.rb +5 -6
  40. data/lib/fluent/plugin/formatter_msgpack.rb +1 -4
  41. data/lib/fluent/plugin/formatter_out_file.rb +36 -3
  42. data/lib/fluent/plugin/formatter_stdout.rb +36 -1
  43. data/lib/fluent/plugin/in_dummy.rb +9 -2
  44. data/lib/fluent/plugin/in_exec.rb +20 -57
  45. data/lib/fluent/plugin/in_forward.rb +4 -3
  46. data/lib/fluent/plugin/in_object_space.rb +8 -44
  47. data/lib/fluent/plugin/in_syslog.rb +13 -24
  48. data/lib/fluent/plugin/in_tail.rb +3 -0
  49. data/lib/fluent/plugin/out_buffered_stdout.rb +14 -4
  50. data/lib/fluent/plugin/out_exec.rb +7 -5
  51. data/lib/fluent/plugin/out_exec_filter.rb +10 -10
  52. data/lib/fluent/plugin/out_file.rb +1 -3
  53. data/lib/fluent/plugin/out_forward.rb +38 -57
  54. data/lib/fluent/plugin/out_stdout.rb +14 -5
  55. data/lib/fluent/plugin/out_stream.rb +3 -0
  56. data/lib/fluent/plugin/output.rb +31 -14
  57. data/lib/fluent/plugin/parser.rb +0 -69
  58. data/lib/fluent/plugin/parser_apache.rb +10 -6
  59. data/lib/fluent/plugin/parser_apache_error.rb +8 -3
  60. data/lib/fluent/plugin/parser_csv.rb +3 -1
  61. data/lib/fluent/plugin/parser_json.rb +1 -1
  62. data/lib/fluent/plugin/parser_multiline.rb +5 -3
  63. data/lib/fluent/plugin/parser_nginx.rb +10 -6
  64. data/lib/fluent/plugin/parser_regexp.rb +73 -0
  65. data/lib/fluent/plugin/socket_util.rb +2 -148
  66. data/lib/fluent/plugin/storage_local.rb +1 -1
  67. data/lib/fluent/plugin/string_util.rb +3 -18
  68. data/lib/fluent/plugin_helper.rb +1 -0
  69. data/lib/fluent/plugin_helper/compat_parameters.rb +166 -41
  70. data/lib/fluent/plugin_helper/formatter.rb +30 -19
  71. data/lib/fluent/plugin_helper/inject.rb +25 -12
  72. data/lib/fluent/plugin_helper/parser.rb +22 -13
  73. data/lib/fluent/plugin_helper/storage.rb +22 -13
  74. data/lib/fluent/registry.rb +19 -6
  75. data/lib/fluent/supervisor.rb +27 -1
  76. data/lib/fluent/test/driver/base.rb +16 -92
  77. data/lib/fluent/test/driver/base_owned.rb +17 -53
  78. data/lib/fluent/test/driver/base_owner.rb +125 -0
  79. data/lib/fluent/test/driver/filter.rb +24 -2
  80. data/lib/fluent/test/driver/input.rb +2 -2
  81. data/lib/fluent/test/driver/multi_output.rb +2 -2
  82. data/lib/fluent/test/driver/output.rb +3 -5
  83. data/lib/fluent/test/helpers.rb +25 -0
  84. data/lib/fluent/test/input_test.rb +4 -4
  85. data/lib/fluent/test/output_test.rb +3 -3
  86. data/lib/fluent/version.rb +1 -1
  87. data/test/config/test_element.rb +135 -6
  88. data/test/plugin/test_buf_file.rb +71 -3
  89. data/test/plugin/test_buffer.rb +305 -86
  90. data/test/plugin/test_buffer_chunk.rb +60 -2
  91. data/test/plugin/test_buffer_file_chunk.rb +4 -3
  92. data/test/plugin/test_filter_grep.rb +25 -21
  93. data/test/plugin/test_filter_record_transformer.rb +75 -67
  94. data/test/plugin/test_filter_stdout.rb +171 -74
  95. data/test/plugin/test_formatter_csv.rb +94 -0
  96. data/test/plugin/test_formatter_json.rb +30 -0
  97. data/test/plugin/test_formatter_ltsv.rb +52 -0
  98. data/test/plugin/test_formatter_msgpack.rb +28 -0
  99. data/test/plugin/test_formatter_out_file.rb +95 -0
  100. data/test/plugin/test_formatter_single_value.rb +38 -0
  101. data/test/plugin/test_in_dummy.rb +95 -0
  102. data/test/plugin/test_in_exec.rb +27 -31
  103. data/test/plugin/test_in_forward.rb +24 -0
  104. data/test/plugin/test_in_gc_stat.rb +5 -5
  105. data/test/plugin/test_in_object_space.rb +4 -4
  106. data/test/plugin/test_in_syslog.rb +60 -35
  107. data/test/plugin/test_out_buffered_stdout.rb +17 -3
  108. data/test/plugin/test_out_forward.rb +93 -5
  109. data/test/plugin/test_out_stdout.rb +14 -3
  110. data/test/plugin/test_output_as_buffered_retries.rb +20 -0
  111. data/test/plugin/test_output_as_buffered_secondary.rb +16 -0
  112. data/test/plugin/test_output_as_standard.rb +22 -22
  113. data/test/plugin/test_parser_apache.rb +13 -9
  114. data/test/plugin/test_parser_apache_error.rb +11 -6
  115. data/test/plugin/test_parser_csv.rb +35 -25
  116. data/test/plugin/test_parser_nginx.rb +11 -5
  117. data/test/plugin/test_parser_regexp.rb +235 -68
  118. data/test/plugin/test_parser_tsv.rb +54 -58
  119. data/test/plugin_helper/test_compat_parameters.rb +111 -46
  120. data/test/plugin_helper/test_formatter.rb +40 -0
  121. data/test/plugin_helper/test_inject.rb +101 -2
  122. data/test/plugin_helper/test_parser.rb +40 -0
  123. data/test/plugin_helper/test_storage.rb +43 -0
  124. data/test/test_event.rb +93 -0
  125. data/test/test_event_router.rb +13 -4
  126. data/test/test_event_time.rb +0 -3
  127. data/test/test_formatter.rb +7 -164
  128. data/test/test_plugin_classes.rb +28 -1
  129. metadata +24 -3
@@ -0,0 +1,60 @@
1
+ #
2
+ # Fluentd
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Fluent
18
+ module Compat
19
+ module HandleTagAndTimeMixin
20
+ def self.included(klass)
21
+ klass.instance_eval {
22
+ config_param :include_time_key, :bool, default: false
23
+ config_param :time_key, :string, default: 'time'
24
+ config_param :time_format, :string, default: nil
25
+ config_param :time_as_epoch, :bool, default: false
26
+ config_param :include_tag_key, :bool, default: false
27
+ config_param :tag_key, :string, default: 'tag'
28
+ config_param :localtime, :bool, default: true
29
+ config_param :timezone, :string, default: nil
30
+ }
31
+ end
32
+
33
+ def configure(conf)
34
+ super
35
+
36
+ if conf['utc']
37
+ @localtime = false
38
+ end
39
+ @timef = Fluent::TimeFormatter.new(@time_format, @localtime, @timezone)
40
+ if @time_as_epoch && !@include_time_key
41
+ log.warn "time_as_epoch will be ignored because include_time_key is false"
42
+ end
43
+ end
44
+
45
+ def filter_record(tag, time, record)
46
+ if @include_tag_key
47
+ record[@tag_key] = tag
48
+ end
49
+ if @include_time_key
50
+ if @time_as_epoch
51
+ record[@time_key] = time.to_i
52
+ else
53
+ record[@time_key] = @timef.format(time)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
@@ -27,9 +27,7 @@ module Fluent
27
27
  def initialize
28
28
  super
29
29
  unless self.class.ancestors.include?(Fluent::Compat::CallSuperMixin)
30
- self.class.module_eval do
31
- prepend Fluent::Compat::CallSuperMixin
32
- end
30
+ self.class.prepend Fluent::Compat::CallSuperMixin
33
31
  end
34
32
  end
35
33
 
@@ -18,6 +18,8 @@ require 'fluent/plugin'
18
18
  require 'fluent/plugin/output'
19
19
  require 'fluent/plugin/bare_output'
20
20
  require 'fluent/compat/call_super_mixin'
21
+ require 'fluent/compat/formatter_utils'
22
+ require 'fluent/compat/parser_utils'
21
23
  require 'fluent/compat/propagate_default'
22
24
  require 'fluent/compat/output_chain'
23
25
  require 'fluent/timezone'
@@ -109,6 +111,10 @@ module Fluent
109
111
  def size
110
112
  self.bytesize
111
113
  end
114
+
115
+ def size_of_events
116
+ @size + @adding_size
117
+ end
112
118
  end
113
119
 
114
120
  module BufferedChunkMixin
@@ -136,7 +142,7 @@ module Fluent
136
142
  class Output < Fluent::Plugin::Output
137
143
  # TODO: warn when deprecated
138
144
 
139
- helpers :event_emitter
145
+ helpers :event_emitter, :inject
140
146
 
141
147
  def support_in_v12_style?(feature)
142
148
  case feature
@@ -154,8 +160,26 @@ module Fluent
154
160
  def initialize
155
161
  super
156
162
  unless self.class.ancestors.include?(Fluent::Compat::CallSuperMixin)
157
- self.class.module_eval do
158
- prepend Fluent::Compat::CallSuperMixin
163
+ self.class.prepend Fluent::Compat::CallSuperMixin
164
+ end
165
+ end
166
+
167
+ def configure(conf)
168
+ ParserUtils.convert_parser_conf(conf)
169
+ FormatterUtils.convert_formatter_conf(conf)
170
+
171
+ super
172
+ end
173
+
174
+ def start
175
+ super
176
+
177
+ if instance_variable_defined?(:@formatter) && @inject_config
178
+ unless @formatter.class.ancestors.include?(Fluent::Compat::HandleTagAndTimeMixin)
179
+ if @formatter.respond_to?(:owner) && !@formatter.owner
180
+ @formatter.owner = self
181
+ @formatter.singleton_class.prepend FormatterUtils::InjectMixin
182
+ end
159
183
  end
160
184
  end
161
185
  end
@@ -174,7 +198,7 @@ module Fluent
174
198
  class BufferedOutput < Fluent::Plugin::Output
175
199
  # TODO: warn when deprecated
176
200
 
177
- helpers :event_emitter
201
+ helpers :event_emitter, :inject
178
202
 
179
203
  def support_in_v12_style?(feature)
180
204
  case feature
@@ -212,10 +236,10 @@ module Fluent
212
236
 
213
237
  config_param :flush_at_shutdown, :bool, default: true
214
238
 
215
- PARAMS_MAP = Fluent::PluginHelper::CompatParameters::PARAMS_MAP
239
+ BUFFER_PARAMS = Fluent::PluginHelper::CompatParameters::BUFFER_PARAMS
216
240
 
217
241
  def self.propagate_default_params
218
- PARAMS_MAP
242
+ BUFFER_PARAMS
219
243
  end
220
244
  include PropagateDefault
221
245
 
@@ -227,7 +251,7 @@ module Fluent
227
251
  "flush_mode" => "interval",
228
252
  "retry_type" => "exponential_backoff",
229
253
  }
230
- PARAMS_MAP.each do |older, newer|
254
+ BUFFER_PARAMS.each do |older, newer|
231
255
  next unless newer
232
256
  if conf.has_key?(older)
233
257
  if older == 'buffer_queue_full_action' && conf[older] == 'exception'
@@ -248,6 +272,9 @@ module Fluent
248
272
  # RecordFilter mixin uses its own #format_stream method implementation
249
273
  @overrides_format_stream = methods_of_plugin.include?(:format_stream) || @includes_record_filter
250
274
 
275
+ ParserUtils.convert_parser_conf(conf)
276
+ FormatterUtils.convert_formatter_conf(conf)
277
+
251
278
  super
252
279
 
253
280
  if config_style == :v1
@@ -256,9 +283,7 @@ module Fluent
256
283
  end
257
284
  end
258
285
 
259
- (class << self; self; end).module_eval do
260
- prepend BufferedChunkMixin
261
- end
286
+ self.extend BufferedChunkMixin
262
287
 
263
288
  if @overrides_emit
264
289
  self.singleton_class.module_eval do
@@ -271,9 +296,7 @@ module Fluent
271
296
  output_plugin.last_emit_via_buffer = [key, data]
272
297
  end
273
298
  end
274
- @buffer.singleton_class.module_eval do
275
- prepend m
276
- end
299
+ @buffer.extend m
277
300
  end
278
301
  end
279
302
 
@@ -320,7 +343,7 @@ module Fluent
320
343
  # on-the-fly key assignment can be done, and it's not configurable if Plugin#emit does it dynamically
321
344
  meta = @buffer.metadata(variables: (key && !key.empty? ? {key: key} : nil))
322
345
  write_guard do
323
- @buffer.write({meta => [data, size]}, bulk: true, enqueue: enqueue)
346
+ @buffer.write({meta => data}, format: ->(_data){ _data }, size: ->(){ size }, enqueue: enqueue)
324
347
  end
325
348
  @counters_monitor.synchronize{ @emit_records += size }
326
349
  return [meta]
@@ -331,17 +354,16 @@ module Fluent
331
354
  size = es.size
332
355
  bulk = format_stream(tag, es)
333
356
  write_guard do
334
- @buffer.write({meta => [bulk, size]}, bulk: true, enqueue: enqueue)
357
+ @buffer.write({meta => bulk}, format: ->(_data){ _data }, size: ->(){ size }, enqueue: enqueue)
335
358
  end
336
359
  @counters_monitor.synchronize{ @emit_records += size }
337
360
  return [meta]
338
361
  end
339
362
 
340
363
  meta = metadata(nil, nil, nil)
341
- es_size = 0
342
- es_bulk = es.map{|time,record| es_size += 1; format(tag, time, record) }.join
364
+ data = es.map{|time,record| format(tag, time, record) }
343
365
  write_guard do
344
- @buffer.write({meta => [es_bulk, es_size]}, bulk: true, enqueue: enqueue)
366
+ @buffer.write({meta => data}, enqueue: enqueue)
345
367
  end
346
368
  @counters_monitor.synchronize{ @emit_records += es_size }
347
369
  [meta]
@@ -354,8 +376,19 @@ module Fluent
354
376
  def initialize
355
377
  super
356
378
  unless self.class.ancestors.include?(Fluent::Compat::CallSuperMixin)
357
- self.class.module_eval do
358
- prepend Fluent::Compat::CallSuperMixin
379
+ self.class.prepend Fluent::Compat::CallSuperMixin
380
+ end
381
+ end
382
+
383
+ def start
384
+ super
385
+
386
+ if instance_variable_defined?(:@formatter) && @inject_config
387
+ unless @formatter.class.ancestors.include?(Fluent::Compat::HandleTagAndTimeMixin)
388
+ if @formatter.respond_to?(:owner) && !@formatter.owner
389
+ @formatter.owner = self
390
+ @formatter.singleton_class.prepend FormatterUtils::InjectMixin
391
+ end
359
392
  end
360
393
  end
361
394
  end
@@ -364,7 +397,7 @@ module Fluent
364
397
  class ObjectBufferedOutput < Fluent::Plugin::Output
365
398
  # TODO: warn when deprecated
366
399
 
367
- helpers :event_emitter
400
+ helpers :event_emitter, :inject
368
401
 
369
402
  # This plugin cannot inherit BufferedOutput because #configure sets chunk_key 'tag'
370
403
  # to flush chunks per tags, but BufferedOutput#configure doesn't allow setting chunk_key
@@ -408,10 +441,10 @@ module Fluent
408
441
 
409
442
  config_set_default :time_as_integer, true
410
443
 
411
- PARAMS_MAP = Fluent::PluginHelper::CompatParameters::PARAMS_MAP
444
+ BUFFER_PARAMS = Fluent::PluginHelper::CompatParameters::BUFFER_PARAMS
412
445
 
413
446
  def self.propagate_default_params
414
- PARAMS_MAP
447
+ BUFFER_PARAMS
415
448
  end
416
449
  include PropagateDefault
417
450
 
@@ -423,7 +456,7 @@ module Fluent
423
456
  "flush_mode" => "interval",
424
457
  "retry_type" => "exponential_backoff",
425
458
  }
426
- PARAMS_MAP.each do |older, newer|
459
+ BUFFER_PARAMS.each do |older, newer|
427
460
  next unless newer
428
461
  if conf.has_key?(older)
429
462
  if older == 'buffer_queue_full_action' && conf[older] == 'exception'
@@ -437,6 +470,9 @@ module Fluent
437
470
  conf.elements << Fluent::Config::Element.new('buffer', 'tag', buf_params, [])
438
471
  end
439
472
 
473
+ ParserUtils.convert_parser_conf(conf)
474
+ FormatterUtils.convert_formatter_conf(conf)
475
+
440
476
  super
441
477
 
442
478
  if config_style == :v1
@@ -445,9 +481,7 @@ module Fluent
445
481
  end
446
482
  end
447
483
 
448
- (class << self; self; end).module_eval do
449
- prepend BufferedChunkMixin
450
- end
484
+ self.extend BufferedChunkMixin
451
485
  end
452
486
 
453
487
  def format_stream(tag, es) # for BufferedOutputTestDriver
@@ -465,8 +499,19 @@ module Fluent
465
499
  def initialize
466
500
  super
467
501
  unless self.class.ancestors.include?(Fluent::Compat::CallSuperMixin)
468
- self.class.module_eval do
469
- prepend Fluent::Compat::CallSuperMixin
502
+ self.class.prepend Fluent::Compat::CallSuperMixin
503
+ end
504
+ end
505
+
506
+ def start
507
+ super
508
+
509
+ if instance_variable_defined?(:@formatter) && @inject_config
510
+ unless @formatter.class.ancestors.include?(Fluent::Compat::HandleTagAndTimeMixin)
511
+ if @formatter.respond_to?(:owner) && !@formatter.owner
512
+ @formatter.owner = self
513
+ @formatter.singleton_class.prepend FormatterUtils::InjectMixin
514
+ end
470
515
  end
471
516
  end
472
517
  end
@@ -475,7 +520,7 @@ module Fluent
475
520
  class TimeSlicedOutput < Fluent::Plugin::Output
476
521
  # TODO: warn when deprecated
477
522
 
478
- helpers :event_emitter
523
+ helpers :event_emitter, :inject
479
524
 
480
525
  def support_in_v12_style?(feature)
481
526
  case feature
@@ -526,21 +571,19 @@ module Fluent
526
571
  config_set_default :@type, 'file'
527
572
  end
528
573
 
529
- PARAMS_MAP = Fluent::PluginHelper::CompatParameters::PARAMS_MAP.merge(Fluent::PluginHelper::CompatParameters::TIME_SLICED_PARAMS)
574
+ BUFFER_PARAMS = Fluent::PluginHelper::CompatParameters::BUFFER_PARAMS.merge(Fluent::PluginHelper::CompatParameters::BUFFER_TIME_SLICED_PARAMS)
530
575
 
531
576
  def initialize
532
577
  super
533
578
  @localtime = true
534
579
 
535
580
  unless self.class.ancestors.include?(Fluent::Compat::CallSuperMixin)
536
- self.class.module_eval do
537
- prepend Fluent::Compat::CallSuperMixin
538
- end
581
+ self.class.prepend Fluent::Compat::CallSuperMixin
539
582
  end
540
583
  end
541
584
 
542
585
  def self.propagate_default_params
543
- PARAMS_MAP
586
+ BUFFER_PARAMS
544
587
  end
545
588
  include PropagateDefault
546
589
 
@@ -552,7 +595,7 @@ module Fluent
552
595
  "flush_mode" => (conf['flush_interval'] ? "interval" : "lazy"),
553
596
  "retry_type" => "exponential_backoff",
554
597
  }
555
- PARAMS_MAP.each do |older, newer|
598
+ BUFFER_PARAMS.each do |older, newer|
556
599
  next unless newer
557
600
  if conf.has_key?(older)
558
601
  if older == 'buffer_queue_full_action' && conf[older] == 'exception'
@@ -591,6 +634,9 @@ module Fluent
591
634
  conf.elements << Fluent::Config::Element.new('buffer', 'time', buf_params, [])
592
635
  end
593
636
 
637
+ ParserUtils.convert_parser_conf(conf)
638
+ FormatterUtils.convert_formatter_conf(conf)
639
+
594
640
  super
595
641
 
596
642
  if config_style == :v1
@@ -599,8 +645,19 @@ module Fluent
599
645
  end
600
646
  end
601
647
 
602
- (class << self; self; end).module_eval do
603
- prepend TimeSliceChunkMixin
648
+ self.extend TimeSliceChunkMixin
649
+ end
650
+
651
+ def start
652
+ super
653
+
654
+ if instance_variable_defined?(:@formatter) && @inject_config
655
+ unless @formatter.class.ancestors.include?(Fluent::Compat::HandleTagAndTimeMixin)
656
+ if @formatter.respond_to?(:owner) && !@formatter.owner
657
+ @formatter.owner = self
658
+ @formatter.singleton_class.prepend FormatterUtils::InjectMixin
659
+ end
660
+ end
604
661
  end
605
662
  end
606
663
 
@@ -615,4 +672,3 @@ module Fluent
615
672
  end
616
673
  end
617
674
  end
618
-
@@ -18,6 +18,7 @@ require 'fluent/plugin'
18
18
  require 'fluent/plugin/parser'
19
19
  require 'fluent/mixin'
20
20
 
21
+ require 'fluent/plugin/parser_regexp'
21
22
  require 'fluent/plugin/parser_json'
22
23
  require 'fluent/plugin/parser_tsv'
23
24
  require 'fluent/plugin/parser_ltsv'
@@ -121,6 +122,22 @@ module Fluent
121
122
 
122
123
  class RegexpParser < Fluent::Plugin::RegexpParser
123
124
  # TODO: warn when deprecated
125
+ def initialize(regexp, conf = {})
126
+ super()
127
+
128
+ unless conf.empty?
129
+ unless conf.is_a?(Config::Element)
130
+ conf = Config::Element.new('default_regexp_conf', '', conf, [])
131
+ end
132
+ configure(conf)
133
+ end
134
+
135
+ @regexp = regexp
136
+ end
137
+
138
+ def patterns
139
+ {'format' => @regexp, 'time_format' => @time_format}
140
+ end
124
141
  end
125
142
 
126
143
  class ValuesParser < Fluent::Plugin::ValuesParser
@@ -0,0 +1,40 @@
1
+ #
2
+ # Fluentd
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'fluent/plugin_helper/compat_parameters'
18
+
19
+ module Fluent
20
+ module Compat
21
+ module ParserUtils
22
+ PARSER_PARAMS = Fluent::PluginHelper::CompatParameters::PARSER_PARAMS
23
+
24
+ def self.convert_parser_conf(conf)
25
+ return if conf.elements(name: 'parse').first
26
+
27
+ parser_params = {}
28
+ PARSER_PARAMS.each do |older, newer|
29
+ next unless newer
30
+ if conf.has_key?(older)
31
+ parser_params[newer] = conf[older]
32
+ end
33
+ end
34
+ unless parser_params.empty?
35
+ conf.elements << Fluent::Config::Element.new('parse', '', parser_params, [])
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end