fluentd 1.13.3-x86-mingw32 → 1.14.0-x86-mingw32
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 +4 -4
- data/.github/workflows/windows-test.yaml +3 -3
- data/CHANGELOG.md +44 -0
- data/lib/fluent/command/fluentd.rb +8 -0
- data/lib/fluent/compat/output.rb +9 -6
- data/lib/fluent/event_router.rb +28 -1
- data/lib/fluent/plugin/bare_output.rb +49 -8
- data/lib/fluent/plugin/buffer.rb +84 -22
- data/lib/fluent/plugin/filter.rb +35 -1
- data/lib/fluent/plugin/in_http.rb +21 -2
- data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
- data/lib/fluent/plugin/in_syslog.rb +13 -1
- data/lib/fluent/plugin/in_tail/position_file.rb +1 -1
- data/lib/fluent/plugin/in_tail.rb +4 -1
- data/lib/fluent/plugin/input.rb +39 -1
- data/lib/fluent/plugin/metrics.rb +119 -0
- data/lib/fluent/plugin/metrics_local.rb +96 -0
- data/lib/fluent/plugin/multi_output.rb +43 -6
- data/lib/fluent/plugin/output.rb +74 -33
- data/lib/fluent/plugin.rb +10 -1
- data/lib/fluent/plugin_helper/event_emitter.rb +8 -1
- data/lib/fluent/plugin_helper/metrics.rb +129 -0
- data/lib/fluent/plugin_helper/server.rb +4 -2
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/root_agent.rb +6 -0
- data/lib/fluent/supervisor.rb +2 -0
- data/lib/fluent/system_config.rb +9 -1
- data/lib/fluent/version.rb +1 -1
- data/test/config/test_system_config.rb +6 -0
- data/test/plugin/in_tail/test_position_file.rb +26 -4
- data/test/plugin/test_bare_output.rb +13 -0
- data/test/plugin/test_buffer.rb +8 -2
- data/test/plugin/test_filter.rb +11 -0
- data/test/plugin/test_in_http.rb +40 -0
- data/test/plugin/test_in_monitor_agent.rb +214 -8
- data/test/plugin/test_in_syslog.rb +35 -0
- data/test/plugin/test_in_tail.rb +9 -26
- data/test/plugin/test_input.rb +11 -0
- data/test/plugin/test_metrics.rb +294 -0
- data/test/plugin/test_metrics_local.rb +96 -0
- data/test/plugin/test_multi_output.rb +25 -1
- data/test/plugin/test_output.rb +16 -0
- data/test/plugin_helper/test_event_emitter.rb +29 -0
- data/test/plugin_helper/test_metrics.rb +137 -0
- data/test/test_plugin_classes.rb +102 -0
- data/test/test_root_agent.rb +30 -1
- metadata +11 -2
@@ -709,13 +709,15 @@ module Fluent
|
|
709
709
|
return true
|
710
710
|
end
|
711
711
|
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e
|
712
|
+
peeraddr = (@_handler_socket.peeraddr rescue PEERADDR_FAILED)
|
712
713
|
@log.trace "unexpected error before accepting TLS connection",
|
713
|
-
|
714
|
+
addr: peeraddr[3], host: peeraddr[2], port: peeraddr[1], error: e
|
714
715
|
close rescue nil
|
715
716
|
rescue OpenSSL::SSL::SSLError => e
|
717
|
+
peeraddr = (@_handler_socket.peeraddr rescue PEERADDR_FAILED)
|
716
718
|
# Use same log level as on_readable
|
717
719
|
@log.warn "unexpected error before accepting TLS connection by OpenSSL",
|
718
|
-
|
720
|
+
addr: peeraddr[3], host: peeraddr[2], port: peeraddr[1], error: e
|
719
721
|
close rescue nil
|
720
722
|
end
|
721
723
|
|
data/lib/fluent/plugin_helper.rb
CHANGED
@@ -32,6 +32,7 @@ require 'fluent/plugin_helper/retry_state'
|
|
32
32
|
require 'fluent/plugin_helper/record_accessor'
|
33
33
|
require 'fluent/plugin_helper/compat_parameters'
|
34
34
|
require 'fluent/plugin_helper/service_discovery'
|
35
|
+
require 'fluent/plugin_helper/metrics'
|
35
36
|
|
36
37
|
module Fluent
|
37
38
|
module PluginHelper
|
data/lib/fluent/root_agent.rb
CHANGED
@@ -55,9 +55,11 @@ module Fluent
|
|
55
55
|
@suppress_emit_error_log_interval = 0
|
56
56
|
@next_emit_error_log_time = nil
|
57
57
|
@without_source = false
|
58
|
+
@enable_input_metrics = false
|
58
59
|
|
59
60
|
suppress_interval(system_config.emit_error_log_interval) unless system_config.emit_error_log_interval.nil?
|
60
61
|
@without_source = system_config.without_source unless system_config.without_source.nil?
|
62
|
+
@enable_input_metrics = !!system_config.enable_input_metrics
|
61
63
|
end
|
62
64
|
|
63
65
|
attr_reader :inputs
|
@@ -131,6 +133,7 @@ module Fluent
|
|
131
133
|
end
|
132
134
|
name = e.arg
|
133
135
|
raise ConfigError, "Missing symbol argument on <label> directive" if name.empty?
|
136
|
+
raise ConfigError, "@ROOT for <label> is not permitted, reserved for getting root router" if name == '@ROOT'
|
134
137
|
|
135
138
|
if name == ERROR_LABEL
|
136
139
|
error_label_config = e
|
@@ -315,6 +318,9 @@ module Fluent
|
|
315
318
|
# See also 'fluentd/plugin/input.rb'
|
316
319
|
input.context_router = @event_router
|
317
320
|
input.configure(conf)
|
321
|
+
if @enable_input_metrics
|
322
|
+
@event_router.add_metric_callbacks(input.plugin_id, Proc.new {|es| input.metric_callback(es) })
|
323
|
+
end
|
318
324
|
@inputs << input
|
319
325
|
|
320
326
|
input
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -570,6 +570,8 @@ module Fluent
|
|
570
570
|
suppress_repeated_stacktrace: true,
|
571
571
|
ignore_repeated_log_interval: nil,
|
572
572
|
without_source: nil,
|
573
|
+
enable_input_metrics: nil,
|
574
|
+
enable_size_metrics: nil,
|
573
575
|
use_v1_config: true,
|
574
576
|
strict_config_value: nil,
|
575
577
|
supervise: true,
|
data/lib/fluent/system_config.rb
CHANGED
@@ -27,7 +27,8 @@ module Fluent
|
|
27
27
|
:log_event_verbose, :ignore_repeated_log_interval, :ignore_same_log_interval,
|
28
28
|
:without_source, :rpc_endpoint, :enable_get_dump, :process_name,
|
29
29
|
:file_permission, :dir_permission, :counter_server, :counter_client,
|
30
|
-
:strict_config_value, :enable_msgpack_time_support, :disable_shared_socket
|
30
|
+
:strict_config_value, :enable_msgpack_time_support, :disable_shared_socket,
|
31
|
+
:metrics, :enable_input_metrics, :enable_size_metrics
|
31
32
|
]
|
32
33
|
|
33
34
|
config_param :workers, :integer, default: 1
|
@@ -46,6 +47,8 @@ module Fluent
|
|
46
47
|
config_param :strict_config_value, :bool, default: nil
|
47
48
|
config_param :enable_msgpack_time_support, :bool, default: nil
|
48
49
|
config_param :disable_shared_socket, :bool, default: nil
|
50
|
+
config_param :enable_input_metrics, :bool, default: nil
|
51
|
+
config_param :enable_size_metrics, :bool, default: nil
|
49
52
|
config_param :file_permission, default: nil do |v|
|
50
53
|
v.to_i(8)
|
51
54
|
end
|
@@ -93,6 +96,11 @@ module Fluent
|
|
93
96
|
config_param :timeout, :time, default: nil
|
94
97
|
end
|
95
98
|
|
99
|
+
config_section :metrics, multi: false do
|
100
|
+
config_param :@type, :string, default: "local"
|
101
|
+
config_param :labels, :hash, default: {}
|
102
|
+
end
|
103
|
+
|
96
104
|
def self.create(conf, strict_config_value=false)
|
97
105
|
systems = conf.elements(name: 'system')
|
98
106
|
return SystemConfig.new if systems.empty?
|
data/lib/fluent/version.rb
CHANGED
@@ -28,6 +28,8 @@ module Fluent::Config
|
|
28
28
|
log_event_label: nil,
|
29
29
|
log_event_verbose: nil,
|
30
30
|
without_source: nil,
|
31
|
+
enable_input_metrics: nil,
|
32
|
+
enable_size_metrics: nil,
|
31
33
|
emit_error_log_interval: nil,
|
32
34
|
file_permission: nil,
|
33
35
|
dir_permission: nil,
|
@@ -77,6 +79,8 @@ module Fluent::Config
|
|
77
79
|
assert_nil(sc.emit_error_log_interval)
|
78
80
|
assert_nil(sc.suppress_config_dump)
|
79
81
|
assert_nil(sc.without_source)
|
82
|
+
assert_nil(sc.enable_input_metrics)
|
83
|
+
assert_nil(sc.enable_size_metrics)
|
80
84
|
assert_nil(sc.enable_msgpack_time_support)
|
81
85
|
assert_equal(:text, sc.log.format)
|
82
86
|
assert_equal('%Y-%m-%d %H:%M:%S %z', sc.log.time_format)
|
@@ -93,6 +97,8 @@ module Fluent::Config
|
|
93
97
|
'without_source' => ['without_source', true],
|
94
98
|
'strict_config_value' => ['strict_config_value', true],
|
95
99
|
'enable_msgpack_time_support' => ['enable_msgpack_time_support', true],
|
100
|
+
'enable_input_metrics' => ['enable_input_metrics', true],
|
101
|
+
'enable_size_metrics' => ['enable_size_metrics', true],
|
96
102
|
)
|
97
103
|
test "accepts parameters" do |(k, v)|
|
98
104
|
conf = parse_text(<<-EOS)
|
@@ -22,6 +22,10 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
22
22
|
invalidpath100000000000000000000000000000000
|
23
23
|
unwatched\t#{UNWATCHED_STR}\t0000000000000000
|
24
24
|
EOF
|
25
|
+
TEST_CONTENT_PATHS = {
|
26
|
+
"valid_path" => Fluent::Plugin::TailInput::TargetInfo.new("valid_path", 1),
|
27
|
+
"inode23bit" => Fluent::Plugin::TailInput::TargetInfo.new("inode23bit", 0),
|
28
|
+
}
|
25
29
|
|
26
30
|
def write_data(f, content)
|
27
31
|
f.write(content)
|
@@ -36,7 +40,11 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
36
40
|
|
37
41
|
test '.load' do
|
38
42
|
write_data(@file, TEST_CONTENT)
|
39
|
-
|
43
|
+
paths = {
|
44
|
+
"valid_path" => Fluent::Plugin::TailInput::TargetInfo.new("valid_path", 1),
|
45
|
+
"inode23bit" => Fluent::Plugin::TailInput::TargetInfo.new("inode23bit", 2),
|
46
|
+
}
|
47
|
+
Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log})
|
40
48
|
|
41
49
|
@file.seek(0)
|
42
50
|
lines = @file.readlines
|
@@ -118,7 +126,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
118
126
|
|
119
127
|
test 'should ignore initial existing files on follow_inode' do
|
120
128
|
write_data(@file, TEST_CONTENT)
|
121
|
-
pos_file = Fluent::Plugin::TailInput::PositionFile.load(@file, true,
|
129
|
+
pos_file = Fluent::Plugin::TailInput::PositionFile.load(@file, true, TEST_CONTENT_PATHS, **{logger: $log})
|
122
130
|
@file.seek(0)
|
123
131
|
assert_equal([], @file.readlines)
|
124
132
|
|
@@ -138,7 +146,12 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
138
146
|
sub_test_case '#load' do
|
139
147
|
test 'compact invalid and convert 32 bit inode value' do
|
140
148
|
write_data(@file, TEST_CONTENT)
|
141
|
-
|
149
|
+
invalid_path = "invalidpath100000000000000000000000000000000"
|
150
|
+
paths = TEST_CONTENT_PATHS.merge({
|
151
|
+
invalid_path => Fluent::Plugin::TailInput::TargetInfo.new(invalid_path, 0),
|
152
|
+
"unwatched" => Fluent::Plugin::TailInput::TargetInfo.new("unwatched", 0),
|
153
|
+
})
|
154
|
+
Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log})
|
142
155
|
|
143
156
|
@file.seek(0)
|
144
157
|
lines = @file.readlines
|
@@ -147,6 +160,15 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
147
160
|
assert_equal "inode23bit\t0000000000000000\t0000000000000000\n", lines[1]
|
148
161
|
end
|
149
162
|
|
163
|
+
test 'compact deleted paths' do
|
164
|
+
write_data(@file, TEST_CONTENT)
|
165
|
+
Fluent::Plugin::TailInput::PositionFile.load(@file, false, {}, **{logger: $log})
|
166
|
+
|
167
|
+
@file.seek(0)
|
168
|
+
lines = @file.readlines
|
169
|
+
assert_equal [], lines
|
170
|
+
end
|
171
|
+
|
150
172
|
test 'compact data if duplicated line' do
|
151
173
|
write_data(@file, <<~EOF)
|
152
174
|
valid_path\t0000000000000002\t0000000000000001
|
@@ -163,7 +185,7 @@ class IntailPositionFileTest < Test::Unit::TestCase
|
|
163
185
|
sub_test_case '#[]' do
|
164
186
|
test 'return entry' do
|
165
187
|
write_data(@file, TEST_CONTENT)
|
166
|
-
pf = Fluent::Plugin::TailInput::PositionFile.load(@file, false,
|
188
|
+
pf = Fluent::Plugin::TailInput::PositionFile.load(@file, false, TEST_CONTENT_PATHS, **{logger: $log})
|
167
189
|
|
168
190
|
valid_target_info = Fluent::Plugin::TailInput::TargetInfo.new('valid_path', File.stat(@file).ino)
|
169
191
|
f = pf[valid_target_info]
|
@@ -95,6 +95,19 @@ class BareOutputTest < Test::Unit::TestCase
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
test 'can use metrics plugins and fallback methods' do
|
99
|
+
@p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
|
100
|
+
|
101
|
+
%w[num_errors_metrics emit_count_metrics emit_size_metrics emit_records_metrics].each do |metric_name|
|
102
|
+
assert_true @p.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
|
103
|
+
end
|
104
|
+
|
105
|
+
assert_equal 0, @p.num_errors
|
106
|
+
assert_equal 0, @p.emit_count
|
107
|
+
assert_equal 0, @p.emit_size
|
108
|
+
assert_equal 0, @p.emit_records
|
109
|
+
end
|
110
|
+
|
98
111
|
test 'can get input event stream to write' do
|
99
112
|
@p.configure(config_element('ROOT'))
|
100
113
|
@p.start
|
data/test/plugin/test_buffer.rb
CHANGED
@@ -238,8 +238,14 @@ class BufferTest < Test::Unit::TestCase
|
|
238
238
|
assert_nil @p.queue
|
239
239
|
assert_nil @p.dequeued
|
240
240
|
assert_nil @p.queued_num
|
241
|
-
|
242
|
-
|
241
|
+
assert_nil @p.stage_length_metrics
|
242
|
+
assert_nil @p.stage_size_metrics
|
243
|
+
assert_nil @p.queue_length_metrics
|
244
|
+
assert_nil @p.queue_size_metrics
|
245
|
+
assert_nil @p.available_buffer_space_ratios_metrics
|
246
|
+
assert_nil @p.total_queued_size_metrics
|
247
|
+
assert_nil @p.newest_timekey_metrics
|
248
|
+
assert_nil @p.oldest_timekey_metrics
|
243
249
|
assert_equal [], @p.timekeys
|
244
250
|
end
|
245
251
|
|
data/test/plugin/test_filter.rb
CHANGED
@@ -165,6 +165,17 @@ class FilterPluginTest < Test::Unit::TestCase
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
+
test 'can use metrics plugins and fallback methods' do
|
169
|
+
@p.configure(config_element('ROOT', '', {'@log_level' => 'debug'}))
|
170
|
+
|
171
|
+
%w[emit_size_metrics emit_records_metrics].each do |metric_name|
|
172
|
+
assert_true @p.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
|
173
|
+
end
|
174
|
+
|
175
|
+
assert_equal 0, @p.emit_size
|
176
|
+
assert_equal 0, @p.emit_records
|
177
|
+
end
|
178
|
+
|
168
179
|
test 'are available with multi worker configuration in default' do
|
169
180
|
assert @p.multi_workers_ready?
|
170
181
|
end
|
data/test/plugin/test_in_http.rb
CHANGED
@@ -856,6 +856,46 @@ class HttpInputTest < Test::Unit::TestCase
|
|
856
856
|
end
|
857
857
|
end
|
858
858
|
|
859
|
+
def test_cors_allow_credentials
|
860
|
+
d = create_driver(config + %[
|
861
|
+
cors_allow_origins ["http://foo.com"]
|
862
|
+
cors_allow_credentials
|
863
|
+
])
|
864
|
+
assert_equal true, d.instance.cors_allow_credentials
|
865
|
+
|
866
|
+
time = event_time("2011-01-02 13:14:15 UTC")
|
867
|
+
event = ["tag1", time, {"a"=>1}]
|
868
|
+
res_code = nil
|
869
|
+
res_header = nil
|
870
|
+
|
871
|
+
d.run do
|
872
|
+
res = post("/#{event[0]}", {"json"=>event[2].to_json, "time"=>time.to_i.to_s}, {"Origin"=>"http://foo.com"})
|
873
|
+
res_code = res.code
|
874
|
+
res_header = res["Access-Control-Allow-Credentials"]
|
875
|
+
end
|
876
|
+
assert_equal(
|
877
|
+
{
|
878
|
+
response_code: "200",
|
879
|
+
allow_credentials_header: "true",
|
880
|
+
events: [event]
|
881
|
+
},
|
882
|
+
{
|
883
|
+
response_code: res_code,
|
884
|
+
allow_credentials_header: res_header,
|
885
|
+
events: d.events
|
886
|
+
}
|
887
|
+
)
|
888
|
+
end
|
889
|
+
|
890
|
+
def test_cors_allow_credentials_for_wildcard_origins
|
891
|
+
assert_raise(Fluent::ConfigError) do
|
892
|
+
create_driver(config + %[
|
893
|
+
cors_allow_origins ["*"]
|
894
|
+
cors_allow_credentials
|
895
|
+
])
|
896
|
+
end
|
897
|
+
end
|
898
|
+
|
859
899
|
def test_content_encoding_gzip
|
860
900
|
d = create_driver
|
861
901
|
|
@@ -37,6 +37,194 @@ class MonitorAgentInputTest < Test::Unit::TestCase
|
|
37
37
|
assert_true d.instance.include_config
|
38
38
|
end
|
39
39
|
|
40
|
+
sub_test_case "collect in_monitor_agent plugin statistics" do
|
41
|
+
# Input Test Driver does not register metric callbacks.
|
42
|
+
# We should stub them here.
|
43
|
+
class TestEventMetricRouter < Fluent::Test::Driver::TestEventRouter
|
44
|
+
def initialize(driver)
|
45
|
+
super
|
46
|
+
|
47
|
+
raise ArgumentError, "plugin does not respond metric_callback method" unless @driver.instance.respond_to?(:metric_callback)
|
48
|
+
end
|
49
|
+
|
50
|
+
def emit(tag, time, record)
|
51
|
+
super
|
52
|
+
@driver.instance.metric_callback(OneEventStream.new(time, record))
|
53
|
+
end
|
54
|
+
|
55
|
+
def emit_array(tag, array)
|
56
|
+
super
|
57
|
+
@driver.instance.metric_callback(ArrayEventStream.new(array))
|
58
|
+
end
|
59
|
+
|
60
|
+
def emit_stream(tag, es)
|
61
|
+
super
|
62
|
+
@driver.instance.metric_callback(es)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class MetricInputDriver < Fluent::Test::Driver::Input
|
67
|
+
def configure(conf, syntax: :v1)
|
68
|
+
if conf.is_a?(Fluent::Config::Element)
|
69
|
+
@config = conf
|
70
|
+
else
|
71
|
+
@config = Fluent::Config.parse(conf, "(test)", "(test_dir)", syntax: syntax)
|
72
|
+
end
|
73
|
+
|
74
|
+
if @instance.respond_to?(:router=)
|
75
|
+
@event_streams = []
|
76
|
+
@error_events = []
|
77
|
+
|
78
|
+
driver = self
|
79
|
+
mojule = Module.new do
|
80
|
+
define_method(:event_emitter_router) do |label_name|
|
81
|
+
TestEventMetricRouter.new(driver)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
@instance.singleton_class.prepend mojule
|
85
|
+
end
|
86
|
+
|
87
|
+
@instance.configure(@config)
|
88
|
+
self
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
setup do
|
93
|
+
# check @type and type in one configuration
|
94
|
+
conf = <<-EOC
|
95
|
+
<source>
|
96
|
+
@type test_in_gen
|
97
|
+
@id test_in_gen
|
98
|
+
num 10
|
99
|
+
</source>
|
100
|
+
<filter>
|
101
|
+
@type test_filter
|
102
|
+
@id test_filter
|
103
|
+
</filter>
|
104
|
+
<match **>
|
105
|
+
@type relabel
|
106
|
+
@id test_relabel
|
107
|
+
@label @test
|
108
|
+
</match>
|
109
|
+
<label @test>
|
110
|
+
<match **>
|
111
|
+
@type test_out
|
112
|
+
@id test_out
|
113
|
+
</match>
|
114
|
+
</label>
|
115
|
+
<label @copy>
|
116
|
+
<match **>
|
117
|
+
@type copy
|
118
|
+
<store>
|
119
|
+
@type test_out
|
120
|
+
@id copy_out_1
|
121
|
+
</store>
|
122
|
+
<store>
|
123
|
+
@type test_out
|
124
|
+
@id copy_out_2
|
125
|
+
</store>
|
126
|
+
</match>
|
127
|
+
</label>
|
128
|
+
<label @ERROR>
|
129
|
+
<match>
|
130
|
+
@type null
|
131
|
+
@id null
|
132
|
+
</match>
|
133
|
+
</label>
|
134
|
+
EOC
|
135
|
+
@ra = Fluent::RootAgent.new(log: $log)
|
136
|
+
stub(Fluent::Engine).root_agent { @ra }
|
137
|
+
@ra = configure_ra(@ra, conf)
|
138
|
+
end
|
139
|
+
|
140
|
+
data(:with_config_yes => true,
|
141
|
+
:with_config_no => false)
|
142
|
+
def test_enable_input_metrics(with_config)
|
143
|
+
monitor_agent_conf = <<-CONF
|
144
|
+
tag test.monitor
|
145
|
+
emit_interval 1
|
146
|
+
CONF
|
147
|
+
@ra.inputs.first.context_router.emit("test.event", Fluent::Engine.now, {"message":"ok"})
|
148
|
+
d = MetricInputDriver.new(Fluent::Plugin::MonitorAgentInput).configure(monitor_agent_conf)
|
149
|
+
d.run(expect_emits: 1, timeout: 3)
|
150
|
+
|
151
|
+
test_label = @ra.labels['@test']
|
152
|
+
error_label = @ra.labels['@ERROR']
|
153
|
+
input_info = {
|
154
|
+
"output_plugin" => false,
|
155
|
+
"plugin_category"=> "input",
|
156
|
+
"plugin_id" => "test_in_gen",
|
157
|
+
"retry_count" => nil,
|
158
|
+
"type" => "test_in_gen",
|
159
|
+
"emit_records" => 0, # This field is not updated due to not to be assigned metric callback.
|
160
|
+
"emit_size" => 0, # Ditto.
|
161
|
+
}
|
162
|
+
input_info.merge!("config" => {"@id" => "test_in_gen", "@type" => "test_in_gen", "num" => "10"}) if with_config
|
163
|
+
filter_info = {
|
164
|
+
"output_plugin" => false,
|
165
|
+
"plugin_category" => "filter",
|
166
|
+
"plugin_id" => "test_filter",
|
167
|
+
"retry_count" => nil,
|
168
|
+
"type" => "test_filter",
|
169
|
+
"emit_records" => Integer,
|
170
|
+
"emit_size" => Integer,
|
171
|
+
}
|
172
|
+
filter_info.merge!("config" => {"@id" => "test_filter", "@type" => "test_filter"}) if with_config
|
173
|
+
output_info = {
|
174
|
+
"output_plugin" => true,
|
175
|
+
"plugin_category" => "output",
|
176
|
+
"plugin_id" => "test_out",
|
177
|
+
"retry_count" => 0,
|
178
|
+
"type" => "test_out",
|
179
|
+
"emit_count" => Integer,
|
180
|
+
"emit_records" => Integer,
|
181
|
+
"emit_size" => Integer,
|
182
|
+
"write_count" => Integer,
|
183
|
+
"rollback_count" => Integer,
|
184
|
+
"slow_flush_count" => Integer,
|
185
|
+
"flush_time_count" => Integer,
|
186
|
+
}
|
187
|
+
output_info.merge!("config" => {"@id" => "test_out", "@type" => "test_out"}) if with_config
|
188
|
+
error_label_info = {
|
189
|
+
"buffer_queue_length" => 0,
|
190
|
+
"buffer_timekeys" => [],
|
191
|
+
"buffer_total_queued_size" => 0,
|
192
|
+
"output_plugin" => true,
|
193
|
+
"plugin_category" => "output",
|
194
|
+
"plugin_id" => "null",
|
195
|
+
"retry_count" => 0,
|
196
|
+
"type" => "null",
|
197
|
+
"buffer_available_buffer_space_ratios" => Float,
|
198
|
+
"buffer_queue_byte_size" => Integer,
|
199
|
+
"buffer_stage_byte_size" => Integer,
|
200
|
+
"buffer_stage_length" => Integer,
|
201
|
+
"emit_count" => Integer,
|
202
|
+
"emit_records" => Integer,
|
203
|
+
"emit_size" => Integer,
|
204
|
+
"write_count" => Integer,
|
205
|
+
"rollback_count" => Integer,
|
206
|
+
"slow_flush_count" => Integer,
|
207
|
+
"flush_time_count" => Integer,
|
208
|
+
}
|
209
|
+
error_label_info.merge!("config" => {"@id"=>"null", "@type" => "null"}) if with_config
|
210
|
+
opts = {with_config: with_config}
|
211
|
+
assert_equal(input_info, d.instance.get_monitor_info(@ra.inputs.first, opts))
|
212
|
+
assert_fuzzy_equal(filter_info, d.instance.get_monitor_info(@ra.filters.first, opts))
|
213
|
+
assert_fuzzy_equal(output_info, d.instance.get_monitor_info(test_label.outputs.first, opts))
|
214
|
+
assert_fuzzy_equal(error_label_info, d.instance.get_monitor_info(error_label.outputs.first, opts))
|
215
|
+
monitor_agent_emit_info = {
|
216
|
+
"emit_records" => Integer,
|
217
|
+
"emit_size" => Integer,
|
218
|
+
}
|
219
|
+
filter_statistics_info = {
|
220
|
+
"emit_records" => Integer,
|
221
|
+
"emit_size" => Integer,
|
222
|
+
}
|
223
|
+
assert_fuzzy_equal(monitor_agent_emit_info, d.instance.statistics["input"])
|
224
|
+
assert_fuzzy_equal(filter_statistics_info, @ra.filters.first.statistics["filter"])
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
40
228
|
sub_test_case "collect plugin information" do
|
41
229
|
setup do
|
42
230
|
# check @type and type in one configuration
|
@@ -106,7 +294,9 @@ EOC
|
|
106
294
|
"plugin_category"=> "input",
|
107
295
|
"plugin_id" => "test_in",
|
108
296
|
"retry_count" => nil,
|
109
|
-
"type" => "test_in"
|
297
|
+
"type" => "test_in",
|
298
|
+
"emit_records" => 0,
|
299
|
+
"emit_size" => 0,
|
110
300
|
}
|
111
301
|
input_info.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
|
112
302
|
filter_info = {
|
@@ -114,7 +304,9 @@ EOC
|
|
114
304
|
"plugin_category" => "filter",
|
115
305
|
"plugin_id" => "test_filter",
|
116
306
|
"retry_count" => nil,
|
117
|
-
"type" => "test_filter"
|
307
|
+
"type" => "test_filter",
|
308
|
+
"emit_records" => 0,
|
309
|
+
"emit_size" => 0,
|
118
310
|
}
|
119
311
|
filter_info.merge!("config" => {"@id" => "test_filter", "@type" => "test_filter"}) if with_config
|
120
312
|
output_info = {
|
@@ -125,6 +317,7 @@ EOC
|
|
125
317
|
"type" => "test_out",
|
126
318
|
"emit_count" => Integer,
|
127
319
|
"emit_records" => Integer,
|
320
|
+
"emit_size" => Integer,
|
128
321
|
"write_count" => Integer,
|
129
322
|
"rollback_count" => Integer,
|
130
323
|
"slow_flush_count" => Integer,
|
@@ -146,6 +339,7 @@ EOC
|
|
146
339
|
"buffer_stage_length" => Integer,
|
147
340
|
"emit_count" => Integer,
|
148
341
|
"emit_records" => Integer,
|
342
|
+
"emit_size" => Integer,
|
149
343
|
"write_count" => Integer,
|
150
344
|
"rollback_count" => Integer,
|
151
345
|
"slow_flush_count" => Integer,
|
@@ -220,6 +414,7 @@ EOC
|
|
220
414
|
"retry_count" => 0,
|
221
415
|
"emit_count" => Integer,
|
222
416
|
"emit_records" => Integer,
|
417
|
+
"emit_size" => Integer,
|
223
418
|
"write_count" => Integer,
|
224
419
|
"rollback_count" => Integer,
|
225
420
|
"slow_flush_count" => Integer,
|
@@ -233,6 +428,7 @@ EOC
|
|
233
428
|
"retry_count" => 0,
|
234
429
|
"emit_count" => Integer,
|
235
430
|
"emit_records" => Integer,
|
431
|
+
"emit_size" => Integer,
|
236
432
|
"write_count" => Integer,
|
237
433
|
"rollback_count" => Integer,
|
238
434
|
"slow_flush_count" => Integer,
|
@@ -322,9 +518,9 @@ EOC
|
|
322
518
|
")
|
323
519
|
d.instance.start
|
324
520
|
expected_test_in_response = "\
|
325
|
-
plugin_id:test_in\tplugin_category:input\ttype:test_in\toutput_plugin:false\tretry_count:"
|
521
|
+
plugin_id:test_in\tplugin_category:input\ttype:test_in\toutput_plugin:false\tretry_count:\temit_records:0\temit_size:0"
|
326
522
|
expected_test_filter_response = "\
|
327
|
-
plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:false\tretry_count:"
|
523
|
+
plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:false\tretry_count:\temit_records:0\temit_size:0"
|
328
524
|
|
329
525
|
response = get("http://127.0.0.1:#{@port}/api/plugins").body
|
330
526
|
test_in = response.split("\n")[0]
|
@@ -350,7 +546,9 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
350
546
|
"plugin_category" => "input",
|
351
547
|
"plugin_id" => "test_in",
|
352
548
|
"retry_count" => nil,
|
353
|
-
"type" => "test_in"
|
549
|
+
"type" => "test_in",
|
550
|
+
"emit_records" => 0,
|
551
|
+
"emit_size" => 0,
|
354
552
|
}
|
355
553
|
expected_test_in_response.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
|
356
554
|
expected_null_response = {
|
@@ -368,6 +566,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
368
566
|
"buffer_stage_length" => Integer,
|
369
567
|
"emit_count" => Integer,
|
370
568
|
"emit_records" => Integer,
|
569
|
+
"emit_size" => Integer,
|
371
570
|
"write_count" => Integer,
|
372
571
|
"rollback_count" => Integer,
|
373
572
|
"slow_flush_count" => Integer,
|
@@ -412,7 +611,9 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
412
611
|
"plugin_category" => "input",
|
413
612
|
"plugin_id" => "test_in",
|
414
613
|
"retry_count" => nil,
|
415
|
-
"type" => "test_in"
|
614
|
+
"type" => "test_in",
|
615
|
+
"emit_records" => 0,
|
616
|
+
"emit_size" => 0,
|
416
617
|
}
|
417
618
|
expected_test_in_response.merge!("config" => {"@id" => "test_in", "@type" => "test_in"}) if with_config
|
418
619
|
expected_null_response = {
|
@@ -430,6 +631,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
430
631
|
"buffer_stage_length" => Integer,
|
431
632
|
"emit_count" => Integer,
|
432
633
|
"emit_records" => Integer,
|
634
|
+
"emit_size" => Integer,
|
433
635
|
"write_count" => Integer,
|
434
636
|
"rollback_count" => Integer,
|
435
637
|
"slow_flush_count" => Integer,
|
@@ -458,7 +660,9 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
458
660
|
"plugin_id" => "test_in",
|
459
661
|
"retry_count" => nil,
|
460
662
|
"type" => "test_in",
|
461
|
-
"instance_variables" => {"id" => "test_in"}
|
663
|
+
"instance_variables" => {"id" => "test_in"},
|
664
|
+
"emit_records" => 0,
|
665
|
+
"emit_size" => 0,
|
462
666
|
}
|
463
667
|
expected_null_response = {
|
464
668
|
"buffer_queue_length" => 0,
|
@@ -469,13 +673,14 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
469
673
|
"plugin_id" => "null",
|
470
674
|
"retry_count" => 0,
|
471
675
|
"type" => "null",
|
472
|
-
"instance_variables" => {"id" => "null"
|
676
|
+
"instance_variables" => {"id" => "null"},
|
473
677
|
"buffer_available_buffer_space_ratios" => Float,
|
474
678
|
"buffer_queue_byte_size" => Integer,
|
475
679
|
"buffer_stage_byte_size" => Integer,
|
476
680
|
"buffer_stage_length" => Integer,
|
477
681
|
"emit_count" => Integer,
|
478
682
|
"emit_records" => Integer,
|
683
|
+
"emit_size" => Integer,
|
479
684
|
"write_count" => Integer,
|
480
685
|
"rollback_count" => Integer,
|
481
686
|
"slow_flush_count" => Integer,
|
@@ -606,6 +811,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
606
811
|
"buffer_stage_length" => Integer,
|
607
812
|
"emit_count" => Integer,
|
608
813
|
"emit_records" => Integer,
|
814
|
+
"emit_size" => Integer,
|
609
815
|
"write_count" => Integer,
|
610
816
|
"rollback_count" => Integer,
|
611
817
|
'slow_flush_count' => Integer,
|