fluent/fluentd · error · Fluent::ConfigError

both of utc and localtime are specified, use only one of the

Error message

both of utc and localtime are specified, use only one of them

What it means

While converting legacy v0.12 buffer parameters, compat_parameters_buffer rejects configs that set both localtime and utc at the top level of a time-sliced output (compat_parameters.rb:160-162). The two options answer the same question (which clock generates the time slice?) with contradictory answers, and the v0.14 model has a single timekey_use_utc flag, so the conversion cannot proceed and a Fluent::ConfigError is raised.

Source

Thrown at lib/fluent/plugin_helper/compat_parameters.rb:162

            value
          end
        end

        chunk_key = default_chunk_key

        if conf.has_key?('time_slice_format')
          chunk_key = 'time'
          hash['timekey'] = case conf['time_slice_format']
                            when /\%S/ then 1
                            when /\%M/ then 60
                            when /\%H/ then 3600
                            when /\%d/ then 86400
                            else
                              raise Fluent::ConfigError, "time_slice_format only with %Y or %m is too long"
                            end
          if conf.has_key?('localtime') || conf.has_key?('utc')
            if conf.has_key?('localtime') && conf.has_key?('utc')
              raise Fluent::ConfigError, "both of utc and localtime are specified, use only one of them"
            elsif conf.has_key?('localtime')
              hash['timekey_use_utc'] = !(Fluent::Config.bool_value(conf['localtime']))
            elsif conf.has_key?('utc')
              hash['timekey_use_utc'] = Fluent::Config.bool_value(conf['utc'])
            end
          end
        else
          if chunk_key == 'time'
            hash['timekey'] = 86400 # TimeSliceOutput.time_slice_format default value is '%Y%m%d'
          end
        end

        e = Fluent::Config::Element.new('buffer', chunk_key, hash, [])
        conf.elements << e

        conf
      end

View on GitHub (pinned to dd45c6e18d)

Solutions

  1. Delete one of the two keys — keep utc true for UTC slicing or localtime true/false for local time
  2. Move to native v0.14 syntax: <buffer time> timekey_use_utc true </buffer> instead of legacy localtime/utc
  3. If a timezone other than UTC/local is wanted, use timezone (mapped to timekey_zone) rather than combining utc and localtime
  4. Audit generated/templated fluentd configs for snippets that hardcode both options

Example fix

# before
<match app.**>
  @type old_timesliced_output
  time_slice_format %Y%m%d
  utc true
  localtime true
</match>
# => both of utc and localtime are specified, use only one of them

# after
<match app.**>
  @type old_timesliced_output
  time_slice_format %Y%m%d
  utc true
</match>
Defensive patterns

Strategy: validation

Validate before calling

raise 'config sets both localtime and utc' if conf.has_key?('localtime') && conf.has_key?('utc') # buffer-compat section

Try / catch

begin
  plugin.configure(conf)
rescue Fluent::ConfigError => e
  if e.message.include?('both of utc and localtime')
    abort 'remove utc or localtime from the buffer config (keep exactly one clock option)'
  end
  raise
end

Prevention

When it happens

Trigger: A plugin calling compat_parameters_convert(conf, :buffer) whose config contains both time_slice_format-era 'localtime true' and 'utc true' lines (any values — presence alone triggers it). Raised during configure at startup.

Common situations: Config templates that include utc true by default and an operator adding localtime for local files; merges of config snippets from different sources keeping both keys; v0.12 configs that silently favored one key now failing loudly under the compat converter.

Related errors


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