Skip to content

Commit eeb384e

Browse files
Watson1978daipom
andauthored
metrics: enable input metrics by default (#4966)
**Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: I ran fluend with `--enable-input-metrics` option and read 10GB file with the `in_tail` plugin There was no significant performance degradation. So, I think it is safe to always enable `--enable-input-metrics`. ### environment * ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-linux] ### results * fluentd master branch (efbb51d) * `ruby bin/fluentd -c in_tail.conf` * 65.939232375 seconds * `ruby bin/fluentd --enable-input-metrics -c in_tail.conf` * 67.776236261 seconds * fluentd 1.16.9 (daccbc6) * `ruby bin/fluentd -c in_tail.conf` * 106.312500419 seconds ### config ``` <source> @type tail tag test path "#{File.expand_path '~/tmp/fluentd/access-*.log'}" read_from_head true <parse> @type json </parse> </source> <match **> @type file path "#{File.expand_path '~/tmp/fluentd/log'}" </match> ``` ### script to generate 10GB ```ruby # frozen_string_literal: true require "json" require "fileutils" def data_generater(str) { "message": str * 1000, }.to_json end FILE_MAX_SIZE = 10 * 1024 * 1024 * 1024 FILE_PATH = "/home/watson/tmp/fluentd/access-1.log" dir = File.dirname(FILE_PATH) FileUtils.mkdir_p(dir) File.open(FILE_PATH, "w") do |f| data = data_generater('a') loop do f.puts data break if File.size(FILE_PATH) > FILE_MAX_SIZE end end ``` **Docs Changes**: fluent/fluentd-docs-gitbook#578 **Release Note**: The same as the title. --------- Signed-off-by: Shizuo Fujita <[email protected]> Co-authored-by: Daijiro Fukuda <[email protected]>
1 parent a3f4c82 commit eeb384e

File tree

8 files changed

+21
-6
lines changed

8 files changed

+21
-6
lines changed

lib/fluent/command/fluentd.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@
155155
cmd_opts[:strict_config_value] = b
156156
}
157157

158-
op.on('--enable-input-metrics', "Enable input plugin metrics on fluentd", TrueClass) {|b|
158+
op.on('--enable-input-metrics', "[DEPRECATED] Enable input plugin metrics on fluentd", TrueClass) {|b|
159+
cmd_opts[:enable_input_metrics] = b
160+
}
161+
162+
op.on('--disable-input-metrics', "Disable input plugin metrics on fluentd", FalseClass) {|b|
159163
cmd_opts[:enable_input_metrics] = b
160164
}
161165

lib/fluent/root_agent.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def initialize(log:, system_config: SystemConfig.new, start_in_parallel: false)
8686
@without_source = system_config.without_source || false
8787
@source_only_mode = SourceOnlyMode.new(system_config.with_source_only, start_in_parallel)
8888
@source_only_buffer_agent = nil
89-
@enable_input_metrics = system_config.enable_input_metrics || false
89+
@enable_input_metrics = system_config.enable_input_metrics
9090

9191
suppress_interval(system_config.emit_error_log_interval) unless system_config.emit_error_log_interval.nil?
9292
end

lib/fluent/supervisor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ def self.default_options
631631
ignore_repeated_log_interval: nil,
632632
without_source: nil,
633633
with_source_only: nil,
634-
enable_input_metrics: nil,
634+
enable_input_metrics: true,
635635
enable_size_metrics: nil,
636636
use_v1_config: true,
637637
strict_config_value: nil,

lib/fluent/system_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class SystemConfig
5151
config_param :strict_config_value, :bool, default: nil
5252
config_param :enable_msgpack_time_support, :bool, default: nil
5353
config_param :disable_shared_socket, :bool, default: nil
54-
config_param :enable_input_metrics, :bool, default: nil
54+
config_param :enable_input_metrics, :bool, default: true
5555
config_param :enable_size_metrics, :bool, default: nil
5656
config_param :enable_jit, :bool, default: false
5757
config_param :file_permission, default: nil do |v|

test/command/test_fluentd.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,4 +1608,12 @@ def create_config_include_dir_configuration(config_path, config_dir, yaml_format
16081608
"[info]: loading additional configuration file path=\"#{conf_dir}/child.yml\"")
16091609
end
16101610
end
1611+
1612+
test "allow --disable-input-metrics option" do
1613+
conf_path = create_conf_file('empty.conf', '')
1614+
assert_log_matches(
1615+
create_cmdline(conf_path, '--disable-input-metrics'),
1616+
"#0 fluentd worker is now running worker=0"
1617+
)
1618+
end
16111619
end

test/config/test_system_config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def parse_text(text)
7575
assert_nil(sc.suppress_config_dump)
7676
assert_nil(sc.without_source)
7777
assert_nil(sc.with_source_only)
78-
assert_nil(sc.enable_input_metrics)
78+
assert_true(sc.enable_input_metrics)
7979
assert_nil(sc.enable_size_metrics)
8080
assert_nil(sc.enable_msgpack_time_support)
8181
assert(!sc.enable_jit)
@@ -97,7 +97,7 @@ def parse_text(text)
9797
'with_source_only' => ['with_source_only', true],
9898
'strict_config_value' => ['strict_config_value', true],
9999
'enable_msgpack_time_support' => ['enable_msgpack_time_support', true],
100-
'enable_input_metrics' => ['enable_input_metrics', true],
100+
'enable_input_metrics' => ['enable_input_metrics', false],
101101
'enable_size_metrics' => ['enable_size_metrics', true],
102102
'enable_jit' => ['enable_jit', true],
103103
)

test/test_root_agent.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def test_initialize
1818
'suppress interval' => [{'emit_error_log_interval' => 30}, {:@suppress_emit_error_log_interval => 30}],
1919
'without source' => [{'without_source' => true}, {:@without_source => true}],
2020
'enable input metrics' => [{'enable_input_metrics' => true}, {:@enable_input_metrics => true}],
21+
'disable input metrics' => [{'enable_input_metrics' => false}, {:@enable_input_metrics => false}],
2122
)
2223
def test_initialize_with_opt(data)
2324
opt, expected = data

test/test_supervisor.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def test_system_config
6464
without_source true
6565
with_source_only true
6666
enable_get_dump true
67+
enable_input_metrics false
6768
process_name "process_name"
6869
log_level info
6970
root_dir #{@tmp_root_dir}
@@ -103,6 +104,7 @@ def test_system_config
103104
assert_equal true, sys_conf.without_source
104105
assert_equal true, sys_conf.with_source_only
105106
assert_equal true, sys_conf.enable_get_dump
107+
assert_equal false, sys_conf.enable_input_metrics
106108
assert_equal "process_name", sys_conf.process_name
107109
assert_equal 2, sys_conf.log_level
108110
assert_equal @tmp_root_dir, sys_conf.root_dir

0 commit comments

Comments
 (0)