{"record":{"id":"517d16f1ed14317d","repo":"fluent/fluentd","slug":"exclude-i-does-not-contain-2-parameters","errorCode":null,"errorMessage":"exclude#{i} does not contain 2 parameters","messagePattern":"exclude#(.+?) does not contain 2 parameters","errorType":"validation","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/filter_grep.rb","lineNumber":107,"sourceCode":"      super\n\n      regexp_and_conditions = {}\n      regexp_or_conditions = {}\n      exclude_and_conditions = {}\n      exclude_or_conditions = {}\n\n      (1..REGEXP_MAX_NUM).each do |i|\n        next unless conf[\"regexp#{i}\"]\n        key, regexp = conf[\"regexp#{i}\"].split(/ /, 2)\n        raise Fluent::ConfigError, \"regexp#{i} does not contain 2 parameters\" unless regexp\n        raise Fluent::ConfigError, \"regexp#{i} contains a duplicated key, #{key}\" if regexp_and_conditions[key]\n        regexp_and_conditions[key] = Expression.new(record_accessor_create(key), Regexp.compile(regexp))\n      end\n\n      (1..REGEXP_MAX_NUM).each do |i|\n        next unless conf[\"exclude#{i}\"]\n        key, exclude = conf[\"exclude#{i}\"].split(/ /, 2)\n        raise Fluent::ConfigError, \"exclude#{i} does not contain 2 parameters\" unless exclude\n        raise Fluent::ConfigError, \"exclude#{i} contains a duplicated key, #{key}\" if exclude_or_conditions[key]\n        exclude_or_conditions[key] = Expression.new(record_accessor_create(key), Regexp.compile(exclude))\n      end\n\n      if @regexps.size > 1\n        log.info \"Top level multiple <regexp> is interpreted as 'and' condition\"\n      end\n      @regexps.each do |e|\n        raise Fluent::ConfigError, \"Duplicate key: #{e.key}\" if regexp_and_conditions.key?(e.key)\n        regexp_and_conditions[e.key] = Expression.new(record_accessor_create(e.key), e.pattern)\n      end\n\n      if @excludes.size > 1\n        log.info \"Top level multiple <exclude> is interpreted as 'or' condition\"\n      end\n      @excludes.each do |e|\n        raise Fluent::ConfigError, \"Duplicate key: #{e.key}\" if exclude_or_conditions.key?(e.key)\n        exclude_or_conditions[e.key] = Expression.new(record_accessor_create(e.key), e.pattern)","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/filter_grep.rb#L89-L125","documentation":"The exclude counterpart of the regexpN check: each excludeN directive must be 'key pattern'. After split(/ /, 2), a missing pattern leaves the exclude variable nil and configure raises Fluent::ConfigError.","triggerScenarios":"A line like exclude1 hostname with no pattern after the field name, or templating that emits only the key half of the directive.","commonSituations":"Hand-edited configs where the pattern was accidentally deleted; deprecated v0.12 syntax kept during an upgrade with a truncated line; environment-variable interpolation producing an empty pattern.","solutions":["Provide both tokens: exclude1 hostname ^web-","Prefer the modern section: <exclude> key hostname pattern /^web-/ </exclude>","Run fluentd --dry-run -c fluent.conf before deploying","Double-check erb/YAML templates that generate excludeN lines"],"exampleFix":"# before\n<filter app.**>\n  @type grep\n  exclude1 hostname\n</filter>\n\n# after\n<filter app.**>\n  @type grep\n  <exclude>\n    key hostname\n    pattern /^web-/\n  </exclude>\n</filter>","handlingStrategy":"validation","validationCode":"(1..20).each do |i|\n  next unless (v = conf[\"exclude#{i}\"])\n  abort \"exclude#{i} must be '<key> <pattern>': got '#{v}'\" unless v.include?(' ')\nend\n# or: system('fluentd --dry-run -c /etc/fluent/fluent.conf')","typeGuard":null,"tryCatchPattern":"begin\n  Fluent::Plugin::GrepFilter.new.configure(conf)\nrescue Fluent::ConfigError => e\n  abort \"grep exclude syntax rejected: #{e.message}\" # names the excludeN index at fault\nend","preventionTips":["Use <exclude> sections instead of deprecated excludeN","Validate templated patterns render non-empty strings","Keep 'key pattern' on one line","CI dry-run"],"tags":["fluentd","grep-filter","configuration","deprecated-syntax","configerror"],"backgroundTag":"config-validation-failed","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}