{"record":{"id":"dc8b96d2e54a2592","repo":"fluent/fluentd","slug":"2-or-more-chunk-keys-is-not-allowed","errorCode":null,"errorMessage":"2 or more chunk keys is not allowed","messagePattern":"2 or more chunk keys is not allowed","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/buf_file_single.rb","lineNumber":75,"sourceCode":"      end\n\n      def configure(conf)\n        super\n\n        @variable_store = Fluent::VariableStore.fetch_or_build(:buf_file_single)\n\n        if @chunk_format == :auto\n          @chunk_format = owner.formatted_to_msgpack_binary? ? :msgpack : :text\n        end\n\n        @key_in_path = nil\n        if owner.chunk_keys.empty?\n          log.debug \"use event tag for buffer key\"\n        else\n          if owner.chunk_key_tag\n            raise Fluent::ConfigError, \"chunk keys must be tag or one field\"\n          elsif owner.chunk_keys.size > 1\n            raise Fluent::ConfigError, \"2 or more chunk keys is not allowed\"\n          else\n            @key_in_path = owner.chunk_keys.first.to_sym\n          end\n        end\n\n        multi_workers_configured = owner.system_config.workers > 1\n        using_plugin_root_dir = false\n        unless @path\n          if root_dir = owner.plugin_root_dir\n            @path = File.join(root_dir, 'buffer')\n            using_plugin_root_dir = true # plugin_root_dir path contains worker id\n          else\n            raise Fluent::ConfigError, \"buffer path is not configured. specify 'path' in <buffer>\"\n          end\n        end\n\n        specified_directory_exists = File.exist?(@path) && File.directory?(@path)\n        unexisting_path_for_directory = !File.exist?(@path) && !@path.include?('.*')","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/buf_file_single.rb#L57-L93","documentation":"In the file_single buffer's configure, after the tag case is excluded, chunk_keys.size > 1 raises this ConfigError: the single-file-per-chunk layout can encode only one record-field key in the path. Buffering on two or more fields (e.g. <buffer tenant, app>) is unsupported for this buffer type, unlike the standard file buffer which supports multiple chunk keys via path placeholders.","triggerScenarios":"<buffer tenant_id, user_id>@type file_single</buffer>; two <key> entries in a file_single buffer; moving a multi-key file-buffer config to file_single unchanged.","commonSituations":"Partitioning outputs by multiple dimensions and choosing file_single for simplicity; performance tuning that switches buffer types without reviewing chunk keys.","solutions":["Keep exactly one chunk key for file_single (<buffer tenant_id>)","Drop secondary keys if per-dimension files are not strictly required (filter/rewrite instead)","Switch to @type file (or memory) when multiple chunk keys are genuinely needed","Consider a separate label/match per dimension so each output owns a single-key buffer"],"exampleFix":"# before\n<match demo.**>\n  @type stdout\n  <buffer tenant_id, user_id>\n    @type file_single\n  </buffer>\n</match>\n\n# after\n<match demo.**>\n  @type stdout\n  <buffer tenant_id>\n    @type file_single\n  </buffer>\n</match>","handlingStrategy":"validation","validationCode":"keys = buffer_keys - ['tag']\nraise 'file_single: at most one chunk key allowed' if keys.size > 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep exactly one chunk key per file_single buffer","Model multi-dimensional partitioning with multiple <match> outputs instead of multiple keys","Switch to @type file when multiple chunk keys are required"],"tags":["fluentd","buffer","file-single-buffer","chunk-keys","config"],"backgroundTag":"invalid-buffer-config","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}