fluent/fluentd · critical · Fluent::ConfigError

time_slice_format only with %Y or %m is too long

Error message

time_slice_format only with %Y or %m is too long

What it means

Raised as Fluent::ConfigError in Fluent::Compat::TimeSlicedOutput#configure while translating a v0.12 time-sliced plugin's config. The shim maps time_slice_format to a v1 buffer timekey by scanning for %S (1s), %M (60s), %H (3600) or %d (86400); nil defaults to 86400. A format containing none of those - i.e. only %Y and/or %m such as '%Y%m' for monthly files - has no representable timekey and configure aborts.

Source

Thrown at lib/fluent/compat/output.rb:667

            conf['localtime'] = "false"
            conf.delete('utc')
          elsif conf['localtime']
            conf['timezone'] = Time.now.strftime('%z')
            conf['localtime'] = "true"
          else
            # v0.12 assumes UTC without any configuration
            # 'localtime=false && no timezone key' means UTC
            conf['localtime'] = "false"
          end

          @_timekey = case conf['time_slice_format']
                      when /\%S/ then 1
                      when /\%M/ then 60
                      when /\%H/ then 3600
                      when /\%d/ then 86400
                      when nil   then 86400 # default value of TimeSlicedOutput.time_slice_format is '%Y%m%d'
                      else
                        raise Fluent::ConfigError, "time_slice_format only with %Y or %m is too long"
                      end
          buf_params["timekey"] = @_timekey

          conf.elements << Fluent::Config::Element.new('buffer', 'time', buf_params, [])
        end

        ParserUtils.convert_parser_conf(conf)
        FormatterUtils.convert_formatter_conf(conf)

        super

        if config_style == :v1
          if @buffer_config.chunk_keys == ['tag']
            raise Fluent::ConfigError, "this plugin '#{self.class}' allows <buffer tag> only"
          end
        end

        self.extend TimeSliceChunkMixin

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Use day-or-finer granularity: time_slice_format %Y%m%d (the default) or %Y%m%d%H
  2. If month-level paths are required, switch to a v1 plugin and build paths with timekey/path placeholders, or post-process daily files
  3. Validate the format contains %S/%M/%H/%d before deploy

Example fix

# before
time_slice_format %Y%m

# after
time_slice_format %Y%m%d
Defensive patterns

Strategy: validation

Validate before calling

fmt = conf['time_slice_format']
valid = fmt.nil? || fmt =~ /%[SMHd]/
abort 'time_slice_format must include %S/%M/%H/%d (day-or-finer granularity)' unless valid

Prevention

When it happens

Trigger: time_slice_format %Y%m (monthly) or %Y (yearly) on a v0.12 TimeSlicedOutput plugin such as legacy out_file/out_s3-style outputs; a migrated config that kept a coarse slice format.

Common situations: Trying to get monthly rolled files from old time-sliced plugins; copying v0.12 examples with %Y%m; generated configs that build the format string from a template.

Related errors


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