fluent/fluentd · error · Fluent::ConfigError

sd_file: path=#{@path} not found

Error message

sd_file: path=#{@path} not found

What it means

SdFileServiceDiscovery#configure (lib/fluent/plugin/sd_file.rb:49) raises Fluent::ConfigError when the configured path for a <service_discovery> @type file block does not exist on disk. The plugin reads the file at configure time to build the initial server list for outputs like forward, so a missing file cannot be deferred. Note that only existence is checked here — readability is checked later (error 237).

Source

Thrown at lib/fluent/plugin/sd_file.rb:49

      DEFAULT_WEIGHT = 60
      DEFAULT_SD_FILE_PATH = ENV['DEFAULT_SD_FILE_PATH'] || '/etc/fluent/sd.yaml'

      helpers :event_loop

      config_param :path, :string, default: DEFAULT_SD_FILE_PATH
      config_param :conf_encoding, :string, default: 'utf-8'

      def initialize
        super

        @file_type = nil
      end

      def configure(conf)
        super

        unless File.exist?(@path)
          raise Fluent::ConfigError, "sd_file: path=#{@path} not found"
        end

        @file_type = File.basename(@path).split('.', 2).last.to_sym
        unless %i[yaml yml json].include?(@file_type)
          @file_type = DEFAULT_FILE_TYPE
        end

        @services = fetch_server_info
      end

      def start(queue)
        watcher = StatWatcher.new(@path, @log) do |_prev, _cur|
          refresh_file(queue)
        end
        event_loop_attach(watcher)

        super()
      end

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Create the file before starting fluentd (even an empty yaml '---\\n[]' works).
  2. Use an absolute path and verify it inside the container/host where fluentd runs.
  3. If servers are discovered later, consider @type srv or static <server> entries as the bootstrap set.
  4. Add a pre-start check: test -f /etc/fluent/services.yaml in the systemd/docker entrypoint.

Example fix

# before
<service_discovery>
  @type file
  path services.yaml   # missing / wrong cwd
</service_discovery>
# after
<service_discovery>
  @type file
  path /etc/fluent/services.yaml
</service_discovery>
Defensive patterns

Strategy: validation

Validate before calling

path = '/etc/fluent/services.yaml'
File.write(path, "---\\n[]\\n") unless File.exist?(path)

Prevention

When it happens

Trigger: <service_discovery> @type file path /etc/fluent/services.yaml </service_discovery> where the file was not yet created; relative paths resolved against fluentd's working directory instead of the intended one; paths with typos or from a different container mount.

Common situations: Container/Kubernetes deployments where the config file is mounted later or at another path; config management (Ansible/Chef) ordering issues; absolute vs relative path mismatch when running fluentd from a non-root working directory.

Related errors


AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21). Data as JSON: /api/errors/bc6225d4080b8dae. Report an issue: GitHub.