fluent/fluentd · error · Fluent::ConfigError
regexp#{i} does not contain 2 parameters
Error message
regexp#{i} does not contain 2 parameters What it means
The grep filter's deprecated numbered parameters (regexp1..regexp20) take a value of the form 'key pattern' and are parsed with String#split(/ /, 2). If the value contains no space, the regexp capture is nil and configure raises Fluent::ConfigError because the directive does not carry both required parameters.
Source
Thrown at lib/fluent/plugin/filter_grep.rb:99
desc "The field name to which the regular expression is applied."
config_param :key, :string
desc "The regular expression."
config_param :pattern, :regexp
end
end
def configure(conf)
super
regexp_and_conditions = {}
regexp_or_conditions = {}
exclude_and_conditions = {}
exclude_or_conditions = {}
(1..REGEXP_MAX_NUM).each do |i|
next unless conf["regexp#{i}"]
key, regexp = conf["regexp#{i}"].split(/ /, 2)
raise Fluent::ConfigError, "regexp#{i} does not contain 2 parameters" unless regexp
raise Fluent::ConfigError, "regexp#{i} contains a duplicated key, #{key}" if regexp_and_conditions[key]
regexp_and_conditions[key] = Expression.new(record_accessor_create(key), Regexp.compile(regexp))
end
(1..REGEXP_MAX_NUM).each do |i|
next unless conf["exclude#{i}"]
key, exclude = conf["exclude#{i}"].split(/ /, 2)
raise Fluent::ConfigError, "exclude#{i} does not contain 2 parameters" unless exclude
raise Fluent::ConfigError, "exclude#{i} contains a duplicated key, #{key}" if exclude_or_conditions[key]
exclude_or_conditions[key] = Expression.new(record_accessor_create(key), Regexp.compile(exclude))
end
if @regexps.size > 1
log.info "Top level multiple <regexp> is interpreted as 'and' condition"
end
@regexps.each do |e|
raise Fluent::ConfigError, "Duplicate key: #{e.key}" if regexp_and_conditions.key?(e.key)
regexp_and_conditions[e.key] = Expression.new(record_accessor_create(e.key), e.pattern)View on GitHub (pinned to dd45c6e18d)
Solutions
- Supply both tokens: regexp1 message error
- Better: migrate to the modern section syntax <regexp> key message pattern /error/
- Run fluentd --dry-run to validate before deploy
- If the pattern itself contains spaces, keep it on the same line after the key (split limit 2 keeps the rest intact)
Example fix
# before
<filter app.**>
@type grep
regexp1 message
</filter>
# after
<filter app.**>
@type grep
<regexp>
key message
pattern /error/
</regexp>
</filter> Defensive patterns
Strategy: validation
Validate before calling
# Lint deprecated grep directives before deploy
(1..20).each do |i|
%W[regexp#{i} exclude#{i}].each do |k|
next unless (v = conf[k])
abort "#{k} must be '<key> <pattern>': got '#{v}'" unless v.include?(' ')
end
end
# or simply:
system('fluentd --dry-run -c /etc/fluent/fluent.conf') or abort 'config invalid' Try / catch
begin
Fluent::Plugin::GrepFilter.new.configure(conf)
rescue Fluent::ConfigError => e
abort "grep filter config rejected: #{e.message}" # message includes the regexpN index
end Prevention
- Migrate off deprecated regexpN/excludeN to <regexp>/<exclude> sections
- Template configs should fail loudly when pattern variables are empty
- Keep grep directive values as 'key pattern' with a single separating space
- dry-run every config change in CI
When it happens
Trigger: A config line like regexp1 message (field name only, no pattern) or regexp1 "message" where quoting removed the intended space; any regexpN value that splits into fewer than 2 tokens. Note regexpN itself is deprecated in favor of <regexp> sections.
Common situations: Migrating old v0.12 grep configs where a pattern was accidentally dropped; YAML/erb templating that renders an empty pattern variable; quoting mistakes where the pattern is in a separate quoted string that gets lost.
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- exclude#{i} does not contain 2 parameters
- regexp#{i} contains a duplicated key, #{key}
- exclude#{i} contains a duplicated key, #{key}
- Duplicate key: #{e.key}
- Do not specify both <regexp> and <exclude> in <and>
AI-assisted analysis of fluent/fluentd@dd45c6e18d (2026-08-21).
Data as JSON: /api/errors/375e4b65d8c78e3b.
Report an issue: GitHub.