{"record":{"id":"580cfdb3f243fabb","repo":"fluent/fluentd","slug":"tag-or-tag-key-option-is-required-on-exec-inpu","errorCode":null,"errorMessage":"'tag' or 'tag_key' option is required on exec input","messagePattern":"'tag' or 'tag_key' option is required on exec input","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/in_exec.rb","lineNumber":68,"sourceCode":"    desc 'The encoding to receive the result of the command, especially for non-ascii characters.'\n    config_param :encoding, :string, default: nil\n\n    attr_reader :parser\n\n    def configure(conf)\n      compat_parameters_convert(conf, :extract, :parser)\n      ['parse', 'extract'].each do |subsection_name|\n        if subsection = conf.elements(subsection_name).first\n          if subsection.has_key?('time_format')\n            subsection['time_type'] ||= 'string'\n          end\n        end\n      end\n\n      super\n\n      if !@tag && (!@extract_config || !@extract_config.tag_key)\n        raise Fluent::ConfigError, \"'tag' or 'tag_key' option is required on exec input\"\n      end\n      validate_encoding(@encoding) if @encoding\n      @parser = parser_create\n    end\n\n    def validate_encoding(encoding)\n      Encoding.find(encoding)\n    rescue ArgumentError => e\n      raise Fluent::ConfigError, e.message\n    end\n\n    def multi_workers_ready?\n      true\n    end\n\n    def start\n      super\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/in_exec.rb#L50-L86","documentation":"The exec input spawns a command and turns its stdout into events; every event needs a tag. After configure runs, in_exec checks that either the tag param is set or the <parse>/<extract> configuration yields a tag_key (a field of the parsed output to use as tag). When both are missing it raises Fluent::ConfigError \"'tag' or 'tag_key' option is required on exec input\", failing at config load.","triggerScenarios":"An in_exec <source> with neither a tag param nor an extract tag_key (e.g. only <parse> @type json with no tag_key inside), so emitted events would have no tag.","commonSituations":"First-time exec input setups that copy a minimal example; switching from tag to tag_key extraction and accidentally removing both; refactors of the <parse> subsection dropping tag_key.","solutions":["Add an explicit tag: tag exec.metrics in the <source>.","Or keep tag extraction from the command output by configuring the parse/extract subsection with tag_key <field>.","Validate the config with fluentd --dry-run."],"exampleFix":"# before\n<source>\n  @type exec\n  command /usr/local/bin/gen-metrics.sh\n  run_interval 10s\n  <parse>\n    @type json\n  </parse>\n</source>\n# after\n<source>\n  @type exec\n  command /usr/local/bin/gen-metrics.sh\n  run_interval 10s\n  tag exec.metrics\n  <parse>\n    @type json\n  </parse>\n</source>","handlingStrategy":"validation","validationCode":"# config lint: exec input needs tag or tag_key\nhas_tag = conf =~ /^\\s*tag\\s+\\S/\nhas_tag_key = conf =~ /tag_key/\nabort \"in_exec: set 'tag' or extract 'tag_key'\" unless has_tag || has_tag_key\n# authoritative: fluentd --dry-run -c /etc/fluent/fluent.conf","typeGuard":null,"tryCatchPattern":"begin\n  Fluent::Plugin.new_input('exec').configure(conf)\nrescue Fluent::ConfigError => e\n  abort \"exec input config rejected: #{e.message}\" # 'tag' or 'tag_key' option is required\nend","preventionTips":["Start from a complete in_exec example that includes a tag.","When extracting the tag from output, verify tag_key exists in the parsed records.","Dry-run configs in CI."],"tags":["fluentd","ruby","exec-input","configuration","missing-param"],"backgroundTag":"missing-required-config-param","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}