thanos-io/thanos · error

error while parsing config for request logging

Error message

error while parsing config for request logging

What it means

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.

Solutions

  1. Validate the --request.logging-config YAML: it should look like http: {log_config: {level: error}} style structure matching logging.RequestConfig.
  2. Fix indentation and remove unknown keys; compare against the example in Thanos docs (get_config_docs).
  3. Pipe the value through yamllint to catch syntax errors.
  4. Check the Thanos version's supported request logging schema if fields seem to be rejected.

Example fix

// before
--request.logging-config='{"level":"debug"}'            # unknown top-level key
// after
--request.logging-config='{"http":{"log_config":{"level":"debug"}}}'
Defensive patterns

Strategy: validation

Validate before calling

import json
def check_request_logging_config(raw):
    try:
        cfg = json.loads(raw)
    except json.JSONDecodeError as e:
        raise SystemExit(f"invalid --request.logging-config JSON: {e}")
    allowed_top = {"http", "grpc"}
    unknown = set(cfg) - allowed_top
    if unknown:
        raise SystemExit(f"unknown request logging keys: {unknown}")
    for section in ("http", "grpc"):
        lc = cfg.get(section, {}).get("log_config", {})
        if lc and not isinstance(lc.get("level"), str):
            raise SystemExit(f"{section}.log_config.level must be a string")

Type guard

def is_valid_req_log_config(raw):
    import json
    try:
        cfg = json.loads(raw)
        return isinstance(cfg, dict) and set(cfg) <= {"http", "grpc"}
    except (json.JSONDecodeError, AttributeError):
        return False

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/6c657c6d711d3680. Report an issue: GitHub.

Appendix: source

Thrown at cmd/thanos/rule.go:250

		}

		// Parse and check alerting configuration.
		conf.alertmgrsConfigYAML, err = conf.alertmgr.configPath.Content()
		if err != nil {
			return err
		}
		if len(conf.alertmgrsConfigYAML) != 0 && len(conf.alertmgr.alertmgrURLs) != 0 {
			return errors.New("--alertmanagers.url and --alertmanagers.config* parameters cannot be defined at the same time")
		}

		conf.alertRelabelConfigYAML, err = conf.alertmgr.alertRelabelConfigPath.Content()
		if err != nil {
			return err
		}

		httpLogOpts, err := logging.ParseHTTPOptions(reqLogConfig)
		if err != nil {
			return errors.Wrap(err, "error while parsing config for request logging")
		}

		grpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(reqLogConfig)

		if err != nil {
			return errors.Wrap(err, "error while parsing config for request logging")
		}

		return runRule(
			g,
			logger,
			reg,
			tracer,
			comp,
			*conf,
			reload,
			getFlagsMap(cmd.Flags()),
			httpLogOpts,

View on GitHub (pinned to 35b8b99117)