{"record":{"id":"bc6225d4080b8dae","repo":"fluent/fluentd","slug":"sd-file-path-path-not-found","errorCode":null,"errorMessage":"sd_file: path=#{@path} not found","messagePattern":"sd_file: path=#(.+?) not found","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/sd_file.rb","lineNumber":49,"sourceCode":"      DEFAULT_WEIGHT = 60\n      DEFAULT_SD_FILE_PATH = ENV['DEFAULT_SD_FILE_PATH'] || '/etc/fluent/sd.yaml'\n\n      helpers :event_loop\n\n      config_param :path, :string, default: DEFAULT_SD_FILE_PATH\n      config_param :conf_encoding, :string, default: 'utf-8'\n\n      def initialize\n        super\n\n        @file_type = nil\n      end\n\n      def configure(conf)\n        super\n\n        unless File.exist?(@path)\n          raise Fluent::ConfigError, \"sd_file: path=#{@path} not found\"\n        end\n\n        @file_type = File.basename(@path).split('.', 2).last.to_sym\n        unless %i[yaml yml json].include?(@file_type)\n          @file_type = DEFAULT_FILE_TYPE\n        end\n\n        @services = fetch_server_info\n      end\n\n      def start(queue)\n        watcher = StatWatcher.new(@path, @log) do |_prev, _cur|\n          refresh_file(queue)\n        end\n        event_loop_attach(watcher)\n\n        super()\n      end","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/sd_file.rb#L31-L67","documentation":"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).","triggerScenarios":"<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.","commonSituations":"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.","solutions":["Create the file before starting fluentd (even an empty yaml '---\\\\n[]' works).","Use an absolute path and verify it inside the container/host where fluentd runs.","If servers are discovered later, consider @type srv or static <server> entries as the bootstrap set.","Add a pre-start check: test -f /etc/fluent/services.yaml in the systemd/docker entrypoint."],"exampleFix":"# before\n<service_discovery>\n  @type file\n  path services.yaml   # missing / wrong cwd\n</service_discovery>\n# after\n<service_discovery>\n  @type file\n  path /etc/fluent/services.yaml\n</service_discovery>","handlingStrategy":"validation","validationCode":"path = '/etc/fluent/services.yaml'\nFile.write(path, \"---\\\\n[]\\\\n\") unless File.exist?(path)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create service files in provisioning (Ansible/Chef/Helm) before fluentd starts.","Use absolute paths in <service_discovery> blocks.","Add test -f checks to systemd ExecStartPre or container entrypoints."],"tags":["fluentd","service-discovery","config-error","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}