fluent/fluentd · error · Fluent::ConfigError
sd_file: path=#{@path} couldn't open #{e}
Error message
sd_file: path=#{@path} couldn't open #{e} What it means
SdFileServiceDiscovery#fetch_server_info (lib/fluent/plugin/sd_file.rb:121) opens the services file with File.open(path, 'r:{conf_encoding}:utf-8') and wraps any exception in Fluent::ConfigError. Unlike the not-found case (error 236), this fires when the file exists but cannot be read or decoded: permission denied, encoding name typos, or content that cannot be converted from conf_encoding to UTF-8.
Source
Thrown at lib/fluent/plugin/sd_file.rb:121
drain = @services - s
drain.each do |d|
diff << ServiceDiscovery.service_out_msg(d)
end
@services = s
diff.each do |a|
queue.push(a)
end
end
def fetch_server_info
config_data =
begin
File.open(@path, "r:#{@conf_encoding}:utf-8", &:read)
rescue => e
raise Fluent::ConfigError, "sd_file: path=#{@path} couldn't open #{e}"
end
parser.call(config_data).map do |s|
Service.new(
:file,
s.fetch('host'),
s.fetch('port'),
s['name'],
s.fetch('weight', DEFAULT_WEIGHT),
s['standby'],
s['username'],
s['password'],
s['shared_key'],
)
end
rescue KeyError => e
raise Fluent::ConfigError, "#{e}. Service must have `host` and `port`"
endView on GitHub (pinned to dd45c6e18d)
Solutions
- Fix permissions: chown fluent:fluent /etc/fluent/services.yaml or chmod a+r (as appropriate).
- Set conf_encoding to the file's real Ruby encoding name (<service_discovery> @type file path ... conf_encoding SJIS </service_discovery>).
- Re-save the services file as UTF-8 and drop conf_encoding.
- Verify readability as the fluentd user: sudo -u fluent head -1 /etc/fluent/services.yaml.
Example fix
# before <service_discovery> @type file path /etc/fluent/servers.yaml conf_encoding utf8 # invalid encoding name </service_discovery> # after <service_discovery> @type file path /etc/fluent/servers.yaml conf_encoding UTF-8 </service_discovery>
Defensive patterns
Strategy: validation
Validate before calling
# pre-start readability + encoding probe
enc = 'UTF-8'
data = File.read(path, encoding: "#{enc}:utf-8") # raises here if unreadable/undecodable Prevention
- Grant the fluentd runtime user read access to the services file.
- Declare the real Ruby encoding name in conf_encoding (e.g. SJIS, EUC-JP) or re-save the file as UTF-8.
- Verify as the daemon user: sudo -u fluent cat path >/dev/null.
When it happens
Trigger: File mode 0600 owned by another user while fluentd runs unprivileged; conf_encoding set to 'utf8' (must be a Ruby encoding name like 'UTF-8' or 'EUC-JP'); a Shift_JIS/EUC-KR file declared as UTF-8 causing an UndefinedConversionError during read.
Common situations: Running fluentd as the 'fluent' user on files created by root; Japanese/Korean legacy-encoded service lists; Docker volume mounts that preserve restrictive permissions; copy-pasted conf_encoding values from examples using non-Ruby names.
Related errors
- sd_file: path=#{@path} not found
- #{e}. Service must have `host` and `port`
- e.message
- unknown value conversion for key:'#{field_name}', type:'#{ty
- Invalid regexp '#{formats}': #{e}
AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21).
Data as JSON: /api/errors/78f1ea9e39bd9c8a.
Report an issue: GitHub.