fluentd 0.14.14 → 0.14.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog +28 -0
- data/example/worker_section.conf +36 -0
- data/lib/fluent/agent.rb +5 -2
- data/lib/fluent/command/fluentd.rb +28 -12
- data/lib/fluent/command/plugin_generator.rb +1 -1
- data/lib/fluent/compat/detach_process_mixin.rb +8 -0
- data/lib/fluent/compat/input.rb +0 -10
- data/lib/fluent/compat/output.rb +0 -10
- data/lib/fluent/config/element.rb +22 -0
- data/lib/fluent/engine.rb +22 -9
- data/lib/fluent/plugin/base.rb +3 -0
- data/lib/fluent/plugin/filter.rb +2 -2
- data/lib/fluent/plugin/in_http.rb +2 -0
- data/lib/fluent/plugin/in_tail.rb +5 -2
- data/lib/fluent/plugin/out_file.rb +5 -0
- data/lib/fluent/plugin/output.rb +6 -1
- data/lib/fluent/plugin_helper/compat_parameters.rb +1 -1
- data/lib/fluent/root_agent.rb +26 -1
- data/lib/fluent/supervisor.rb +0 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +25 -11
- data/test/command/test_fluentd.rb +208 -2
- data/test/config/test_element.rb +63 -0
- data/test/plugin/test_in_http.rb +36 -4
- data/test/plugin/test_out_file.rb +9 -0
- data/test/plugin/test_output_as_buffered.rb +30 -2
- data/test/test_plugin_classes.rb +15 -0
- data/test/test_root_agent.rb +204 -0
- metadata +4 -3
data/test/plugin/test_in_http.rb
CHANGED
@@ -215,14 +215,14 @@ class HttpInputTest < Test::Unit::TestCase
|
|
215
215
|
def test_multi_json_with_add_remote_addr_given_x_forwarded_for
|
216
216
|
d = create_driver(CONFIG + "add_remote_addr true")
|
217
217
|
|
218
|
+
tag = "tag1"
|
218
219
|
time = event_time("2011-01-02 13:14:15 UTC")
|
219
220
|
time_i = time.to_i
|
220
221
|
records = [{"a"=>1},{"a"=>2}]
|
221
222
|
events = [
|
222
|
-
[
|
223
|
-
[
|
223
|
+
[tag, time, {"REMOTE_ADDR"=>"129.78.138.66", "a"=>1}],
|
224
|
+
[tag, time, {"REMOTE_ADDR"=>"129.78.138.66", "a"=>2}],
|
224
225
|
]
|
225
|
-
tag = "tag1"
|
226
226
|
res_codes = []
|
227
227
|
|
228
228
|
d.run(expect_records: 2, timeout: 5) do
|
@@ -235,6 +235,37 @@ class HttpInputTest < Test::Unit::TestCase
|
|
235
235
|
assert_equal_event_time time, d.events[1][1]
|
236
236
|
end
|
237
237
|
|
238
|
+
def test_add_remote_addr_given_multi_x_forwarded_for
|
239
|
+
d = create_driver(CONFIG + "add_remote_addr true")
|
240
|
+
|
241
|
+
tag = "tag1"
|
242
|
+
time = event_time("2011-01-02 13:14:15 UTC")
|
243
|
+
time_i = time.to_i
|
244
|
+
record = {"a" => 1}
|
245
|
+
event = ["tag1", time, {"REMOTE_ADDR" => "129.78.138.66", "a" => 1}]
|
246
|
+
res_code = nil
|
247
|
+
|
248
|
+
d.run(expect_records: 1, timeout: 5) do
|
249
|
+
res = post("/#{tag}", {"json" => record.to_json, "time" => time_i.to_s}) { |http, req|
|
250
|
+
# net/http can't send multiple headers so overwrite it.
|
251
|
+
def req.each_capitalized
|
252
|
+
block_given? or return enum_for(__method__) { @header.size }
|
253
|
+
@header.each do |k, vs|
|
254
|
+
vs.each { |v|
|
255
|
+
yield capitalize(k), v
|
256
|
+
}
|
257
|
+
end
|
258
|
+
end
|
259
|
+
req.add_field("X-Forwarded-For", "129.78.138.66, 127.0.0.1")
|
260
|
+
req.add_field("X-Forwarded-For", "8.8.8.8")
|
261
|
+
}
|
262
|
+
res_code = res.code
|
263
|
+
end
|
264
|
+
assert_equal "200", res_code
|
265
|
+
assert_equal event, d.events.first
|
266
|
+
assert_equal_event_time time, d.events.first[1]
|
267
|
+
end
|
268
|
+
|
238
269
|
def test_multi_json_with_add_http_headers
|
239
270
|
d = create_driver(CONFIG + "add_http_headers true")
|
240
271
|
time = event_time("2011-01-02 13:14:15 UTC")
|
@@ -565,9 +596,10 @@ class HttpInputTest < Test::Unit::TestCase
|
|
565
596
|
assert_equal $test_in_http_connection_object_ids[0], $test_in_http_connection_object_ids[1]
|
566
597
|
end
|
567
598
|
|
568
|
-
def post(path, params, header = {})
|
599
|
+
def post(path, params, header = {}, &block)
|
569
600
|
http = Net::HTTP.new("127.0.0.1", PORT)
|
570
601
|
req = Net::HTTP::Post.new(path, header)
|
602
|
+
block.call(http, req) if block
|
571
603
|
if params.is_a?(String)
|
572
604
|
unless header.has_key?('Content-Type')
|
573
605
|
header['Content-Type'] = 'application/octet-stream'
|
@@ -20,6 +20,9 @@ class FileOutputTest < Test::Unit::TestCase
|
|
20
20
|
path #{TMP_DIR}/out_file_test
|
21
21
|
compress gz
|
22
22
|
utc
|
23
|
+
<buffer>
|
24
|
+
timekey_use_utc true
|
25
|
+
</buffer>
|
23
26
|
]
|
24
27
|
|
25
28
|
def create_driver(conf = CONFIG, opts = {})
|
@@ -405,6 +408,9 @@ class FileOutputTest < Test::Unit::TestCase
|
|
405
408
|
path #{TMP_DIR_WITH_SYSTEM}/out_file_test
|
406
409
|
compress gz
|
407
410
|
utc
|
411
|
+
<buffer>
|
412
|
+
timekey_use_utc true
|
413
|
+
</buffer>
|
408
414
|
<system>
|
409
415
|
file_permission #{OVERRIDE_FILE_PERMISSION}
|
410
416
|
dir_permission #{OVERRIDE_DIR_PERMISSION}
|
@@ -527,6 +533,9 @@ class FileOutputTest < Test::Unit::TestCase
|
|
527
533
|
compress gz
|
528
534
|
utc
|
529
535
|
append true
|
536
|
+
<buffer>
|
537
|
+
timekey_use_utc true
|
538
|
+
</buffer>
|
530
539
|
]
|
531
540
|
d.run(default_tag: 'test'){
|
532
541
|
d.feed(time, {"a"=>1})
|
@@ -75,6 +75,31 @@ module FluentPluginOutputAsBufferedTest
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
class DummyCustomFormatBufferedOutput < DummyBareOutput
|
78
|
+
def initialize
|
79
|
+
super
|
80
|
+
@format_type_is_msgpack = nil
|
81
|
+
@prefer_delayed_commit = nil
|
82
|
+
@write = nil
|
83
|
+
@try_write = nil
|
84
|
+
end
|
85
|
+
def format(tag, time, record)
|
86
|
+
@format ? @format.call(tag, time, record) : [tag, time, record].to_json
|
87
|
+
end
|
88
|
+
def formatted_to_msgpack_binary?
|
89
|
+
@format_type_is_msgpack ? @format_type_is_msgpack.call : false
|
90
|
+
end
|
91
|
+
def prefer_delayed_commit
|
92
|
+
@prefer_delayed_commit ? @prefer_delayed_commit.call : false
|
93
|
+
end
|
94
|
+
def write(chunk)
|
95
|
+
@write ? @write.call(chunk) : nil
|
96
|
+
end
|
97
|
+
def try_write(chunk)
|
98
|
+
@try_write ? @try_write.call(chunk) : nil
|
99
|
+
end
|
100
|
+
end
|
101
|
+
# check for formatted_to_msgpack_binary compatibility
|
102
|
+
class DummyOldCustomFormatBufferedOutput < DummyBareOutput
|
78
103
|
def initialize
|
79
104
|
super
|
80
105
|
@format_type_is_msgpack = nil
|
@@ -163,6 +188,7 @@ class BufferedOutputTest < Test::Unit::TestCase
|
|
163
188
|
when :full then FluentPluginOutputAsBufferedTest::DummyFullFeatureOutput.new
|
164
189
|
when :old_buf then FluentPluginOutputAsBufferedTest::DummyOldBufferedOutput.new
|
165
190
|
when :old_obj then FluentPluginOutputAsBufferedTest::DummyOldObjectBufferedOutput.new
|
191
|
+
when :old_custom then FluentPluginOutputAsBufferedTest::DummyOldCustomFormatBufferedOutput.new
|
166
192
|
else
|
167
193
|
raise ArgumentError, "unknown type: #{type}"
|
168
194
|
end
|
@@ -306,9 +332,11 @@ class BufferedOutputTest < Test::Unit::TestCase
|
|
306
332
|
assert_equal 0, events_from_chunk.size
|
307
333
|
end
|
308
334
|
|
309
|
-
|
335
|
+
data('formatted_to_msgpack_binary?' => :custom,
|
336
|
+
'formatted_to_msgpack_binary' => :old_custom)
|
337
|
+
test 'plugin using custom format can iterate chunk in #write if #format returns msgpack' do |out_type|
|
310
338
|
events_from_chunk = []
|
311
|
-
@i = create_output(
|
339
|
+
@i = create_output(out_type)
|
312
340
|
@i.configure(config_element('ROOT','',{},[config_element('buffer','',@hash)]))
|
313
341
|
@i.register(:prefer_delayed_commit){ false }
|
314
342
|
@i.register(:format){ |tag, time, record| [tag,time,record].to_msgpack }
|
data/test/test_plugin_classes.rb
CHANGED
@@ -235,6 +235,21 @@ module FluentTest
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
+
class FluentTestBuffer < Fluent::Plugin::Buffer
|
239
|
+
::Fluent::Plugin.register_buffer('test_buffer', self)
|
240
|
+
|
241
|
+
def resume
|
242
|
+
return {}, []
|
243
|
+
end
|
244
|
+
|
245
|
+
def generate_chunk(metadata)
|
246
|
+
end
|
247
|
+
|
248
|
+
def multi_workers_ready?
|
249
|
+
false
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
238
253
|
class TestEmitErrorHandler
|
239
254
|
def initialize
|
240
255
|
@events = Hash.new { |h, k| h[k] = [] }
|
data/test/test_root_agent.rb
CHANGED
@@ -608,4 +608,208 @@ EOC
|
|
608
608
|
assert_equal [true, true], dyn_out.child.outputs.map{|i| i.terminated? }
|
609
609
|
end
|
610
610
|
end
|
611
|
+
|
612
|
+
sub_test_case 'configured at worker2 with 4 workers environment' do
|
613
|
+
setup do
|
614
|
+
ENV['SERVERENGINE_WORKER_ID'] = '2'
|
615
|
+
@ra = RootAgent.new(log: $log)
|
616
|
+
system_config = SystemConfig.new
|
617
|
+
system_config.workers = 4
|
618
|
+
stub(Engine).worker_id { 2 }
|
619
|
+
stub(Engine).root_agent { @ra }
|
620
|
+
stub(Engine).system_config { system_config }
|
621
|
+
@ra
|
622
|
+
end
|
623
|
+
|
624
|
+
teardown '' do
|
625
|
+
ENV.delete('SERVERENGINE_WORKER_ID')
|
626
|
+
end
|
627
|
+
|
628
|
+
def configure_ra(conf_str)
|
629
|
+
conf = Config.parse(conf_str, "(test)", "(test_dir)", true)
|
630
|
+
@ra.configure(conf)
|
631
|
+
@ra
|
632
|
+
end
|
633
|
+
|
634
|
+
test 'raises configuration error for missing worker id' do
|
635
|
+
errmsg = 'Missing worker id on <worker> directive'
|
636
|
+
assert_raise Fluent::ConfigError.new(errmsg) do
|
637
|
+
conf = <<-EOC
|
638
|
+
<worker>
|
639
|
+
</worker>
|
640
|
+
EOC
|
641
|
+
configure_ra(conf)
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
645
|
+
test 'raises configuration error for too big worker id' do
|
646
|
+
errmsg = "worker id 4 specified by <worker> directive is not allowed. Available worker id is between 0 and 3"
|
647
|
+
assert_raise Fluent::ConfigError.new(errmsg) do
|
648
|
+
conf = <<-EOC
|
649
|
+
<worker 4>
|
650
|
+
</worker>
|
651
|
+
EOC
|
652
|
+
configure_ra(conf)
|
653
|
+
end
|
654
|
+
end
|
655
|
+
|
656
|
+
test 'raises configuration error for invalid elements as a child of worker section' do
|
657
|
+
errmsg = '<worker> section cannot have <system> directive'
|
658
|
+
assert_raise Fluent::ConfigError.new(errmsg) do
|
659
|
+
conf = <<-EOC
|
660
|
+
<worker 2>
|
661
|
+
<system>
|
662
|
+
</system>
|
663
|
+
</worker>
|
664
|
+
EOC
|
665
|
+
configure_ra(conf)
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
test 'raises configuration error when configured plugins do not have support multi worker configuration' do
|
670
|
+
errmsg = "Plugin 'test_out' does not support multi workers configuration (FluentTest::FluentTestOutput)"
|
671
|
+
assert_raise Fluent::ConfigError.new(errmsg) do
|
672
|
+
conf = <<-EOC
|
673
|
+
<match **>
|
674
|
+
@type test_out
|
675
|
+
</match>
|
676
|
+
EOC
|
677
|
+
configure_ra(conf)
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
681
|
+
test 'does not raise configuration error when configured plugins in worker section do not have support multi worker configuration' do
|
682
|
+
assert_nothing_raised do
|
683
|
+
conf = <<-EOC
|
684
|
+
<worker 2>
|
685
|
+
<match **>
|
686
|
+
@type test_out
|
687
|
+
</match>
|
688
|
+
</worker>
|
689
|
+
EOC
|
690
|
+
configure_ra(conf)
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
694
|
+
test 'does not raise configuration error when configured plugins as a children of MultiOutput in worker section do not have support multi worker configuration' do
|
695
|
+
assert_nothing_raised do
|
696
|
+
conf = <<-EOC
|
697
|
+
<worker 2>
|
698
|
+
<match **>
|
699
|
+
@type copy
|
700
|
+
<store>
|
701
|
+
@type test_out
|
702
|
+
</store>
|
703
|
+
<store>
|
704
|
+
@type test_out
|
705
|
+
</store>
|
706
|
+
</match>
|
707
|
+
</worker>
|
708
|
+
EOC
|
709
|
+
configure_ra(conf)
|
710
|
+
end
|
711
|
+
end
|
712
|
+
|
713
|
+
test 'does not raise configuration error when configured plugins owned by plugin do not have support multi worker configuration' do
|
714
|
+
assert_nothing_raised do
|
715
|
+
conf = <<-EOC
|
716
|
+
<worker 2>
|
717
|
+
<match **>
|
718
|
+
@type test_out_buffered
|
719
|
+
<buffer>
|
720
|
+
@type test_buffer
|
721
|
+
</buffer>
|
722
|
+
</match>
|
723
|
+
</worker>
|
724
|
+
EOC
|
725
|
+
configure_ra(conf)
|
726
|
+
end
|
727
|
+
end
|
728
|
+
|
729
|
+
test 'with plugins' do
|
730
|
+
conf = <<-EOC
|
731
|
+
<worker 2>
|
732
|
+
<source>
|
733
|
+
@type test_in
|
734
|
+
@id test_in
|
735
|
+
</source>
|
736
|
+
<filter>
|
737
|
+
type test_filter
|
738
|
+
id test_filter
|
739
|
+
</filter>
|
740
|
+
<match **>
|
741
|
+
@type relabel
|
742
|
+
@id test_relabel
|
743
|
+
@label @test
|
744
|
+
</match>
|
745
|
+
<label @test>
|
746
|
+
<match **>
|
747
|
+
type test_out
|
748
|
+
id test_out
|
749
|
+
</match>
|
750
|
+
</label>
|
751
|
+
<label @ERROR>
|
752
|
+
<match>
|
753
|
+
@type null
|
754
|
+
</match>
|
755
|
+
</label>
|
756
|
+
</worker>
|
757
|
+
EOC
|
758
|
+
ra = configure_ra(conf)
|
759
|
+
assert_kind_of FluentTestInput, ra.inputs.first
|
760
|
+
assert_kind_of Plugin::RelabelOutput, ra.outputs.first
|
761
|
+
assert_kind_of FluentTestFilter, ra.filters.first
|
762
|
+
assert ra.error_collector
|
763
|
+
|
764
|
+
%W(@test @ERROR).each { |label_symbol|
|
765
|
+
assert_include ra.labels, label_symbol
|
766
|
+
assert_kind_of Label, ra.labels[label_symbol]
|
767
|
+
}
|
768
|
+
|
769
|
+
test_label = ra.labels['@test']
|
770
|
+
assert_kind_of FluentTestOutput, test_label.outputs.first
|
771
|
+
assert_equal ra, test_label.root_agent
|
772
|
+
|
773
|
+
error_label = ra.labels['@ERROR']
|
774
|
+
assert_kind_of Fluent::Plugin::NullOutput, error_label.outputs.first
|
775
|
+
assert_kind_of RootAgent::RootAgentProxyWithoutErrorCollector, error_label.root_agent
|
776
|
+
end
|
777
|
+
|
778
|
+
test 'with plugins but for another worker' do
|
779
|
+
conf = <<-EOC
|
780
|
+
<worker 0>
|
781
|
+
<source>
|
782
|
+
@type test_in
|
783
|
+
@id test_in
|
784
|
+
</source>
|
785
|
+
<filter>
|
786
|
+
type test_filter
|
787
|
+
id test_filter
|
788
|
+
</filter>
|
789
|
+
<match **>
|
790
|
+
@type relabel
|
791
|
+
@id test_relabel
|
792
|
+
@label @test
|
793
|
+
</match>
|
794
|
+
<label @test>
|
795
|
+
<match **>
|
796
|
+
type test_out
|
797
|
+
id test_out
|
798
|
+
</match>
|
799
|
+
</label>
|
800
|
+
<label @ERROR>
|
801
|
+
<match>
|
802
|
+
@type null
|
803
|
+
</match>
|
804
|
+
</label>
|
805
|
+
</worker>
|
806
|
+
EOC
|
807
|
+
ra = configure_ra(conf)
|
808
|
+
assert_equal 0, ra.inputs.size
|
809
|
+
assert_equal 0, ra.outputs.size
|
810
|
+
assert_equal 0, ra.filters.size
|
811
|
+
assert_equal 0, ra.labels.size
|
812
|
+
refute ra.error_collector
|
813
|
+
end
|
814
|
+
end
|
611
815
|
end
|
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.14.
|
4
|
+
version: 0.14.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -348,6 +348,7 @@ files:
|
|
348
348
|
- example/suppress_config_dump.conf
|
349
349
|
- example/v0_12_filter.conf
|
350
350
|
- example/v1_literal_example.conf
|
351
|
+
- example/worker_section.conf
|
351
352
|
- fluent.conf
|
352
353
|
- fluentd.gemspec
|
353
354
|
- lib/fluent/agent.rb
|
@@ -713,7 +714,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
713
714
|
version: '0'
|
714
715
|
requirements: []
|
715
716
|
rubyforge_project:
|
716
|
-
rubygems_version: 2.
|
717
|
+
rubygems_version: 2.6.11
|
717
718
|
signing_key:
|
718
719
|
specification_version: 4
|
719
720
|
summary: Fluentd event collector
|