{"record":{"id":"6c657c6d711d3680","repo":"thanos-io/thanos","slug":"error-while-parsing-config-for-request-logging-6c657c","errorCode":null,"errorMessage":"error while parsing config for request logging","messagePattern":"error while parsing config for request logging","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":250,"sourceCode":"\t\t}\n\n\t\t// Parse and check alerting configuration.\n\t\tconf.alertmgrsConfigYAML, err = conf.alertmgr.configPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(conf.alertmgrsConfigYAML) != 0 && len(conf.alertmgr.alertmgrURLs) != 0 {\n\t\t\treturn errors.New(\"--alertmanagers.url and --alertmanagers.config* parameters cannot be defined at the same time\")\n\t\t}\n\n\t\tconf.alertRelabelConfigYAML, err = conf.alertmgr.alertRelabelConfigPath.Content()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\thttpLogOpts, err := logging.ParseHTTPOptions(reqLogConfig)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error while parsing config for request logging\")\n\t\t}\n\n\t\tgrpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(reqLogConfig)\n\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"error while parsing config for request logging\")\n\t\t}\n\n\t\treturn runRule(\n\t\t\tg,\n\t\t\tlogger,\n\t\t\treg,\n\t\t\ttracer,\n\t\t\tcomp,\n\t\t\t*conf,\n\t\t\treload,\n\t\t\tgetFlagsMap(cmd.Flags()),\n\t\t\thttpLogOpts,","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L232-L268","documentation":"The rule command parses --request.logging-config via logging.ParseHTTPOptions to build HTTP request logging middleware. This wraps the parse error when the config YAML is invalid or contains unsupported fields, aborting startup because logging options are required for the HTTP servers.","triggerScenarios":"logging.ParseHTTPOptions(reqLogConfig) errors when the YAML under --request.logging-config fails to unmarshal into the RequestConfig struct (bad indentation, unknown keys like level instead of the expected fields).","commonSituations":"Typo in request logging config keys; YAML indentation mistakes in Helm values; copying a --log.request.level-style string where structured YAML is expected; version mismatch where a field was renamed.","solutions":["Validate the --request.logging-config YAML: it should look like http: {log_config: {level: error}} style structure matching logging.RequestConfig.","Fix indentation and remove unknown keys; compare against the example in Thanos docs (get_config_docs).","Pipe the value through yamllint to catch syntax errors.","Check the Thanos version's supported request logging schema if fields seem to be rejected."],"exampleFix":"// before\n--request.logging-config='{\"level\":\"debug\"}'            # unknown top-level key\n// after\n--request.logging-config='{\"http\":{\"log_config\":{\"level\":\"debug\"}}}'","handlingStrategy":"validation","validationCode":"import json\ndef check_request_logging_config(raw):\n    try:\n        cfg = json.loads(raw)\n    except json.JSONDecodeError as e:\n        raise SystemExit(f\"invalid --request.logging-config JSON: {e}\")\n    allowed_top = {\"http\", \"grpc\"}\n    unknown = set(cfg) - allowed_top\n    if unknown:\n        raise SystemExit(f\"unknown request logging keys: {unknown}\")\n    for section in (\"http\", \"grpc\"):\n        lc = cfg.get(section, {}).get(\"log_config\", {})\n        if lc and not isinstance(lc.get(\"level\"), str):\n            raise SystemExit(f\"{section}.log_config.level must be a string\")","typeGuard":"def is_valid_req_log_config(raw):\n    import json\n    try:\n        cfg = json.loads(raw)\n        return isinstance(cfg, dict) and set(cfg) <= {\"http\", \"grpc\"}\n    except (json.JSONDecodeError, AttributeError):\n        return False","tryCatchPattern":null,"preventionTips":["Copy the request logging config example from the Thanos docs for your exact version.","Run yamllint/jsonlint on inline configs before embedding them in flags.","Watch for field renames across Thanos versions; pin and re-check on upgrade.","Keep the config in a file and validate it in CI instead of inlining in flags."],"tags":["config","logging","yaml","startup"],"backgroundTag":"yaml-parse-error","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}