thanos-io/thanos · error

error while parsing config for request logging

Error message

error while parsing config for request logging

What it means

This error wraps failures from logging.ParseHTTOptions when parsing the request-logging configuration flags that were registered via extkingpin.RegisterRequestLoggingFlags. Thanos wraps the underlying parse error so the operator knows the request-logging flags (or their YAML file content) could not be interpreted. The command exits during cmd.Setup before the query-frontend starts.

Solutions

  1. Check the --http.request.*-log-format / request-logging flag values for typos against accepted values (logfmt, json).
  2. If a config file is used, validate its YAML with yamllint and ensure it matches logging options schema.
  3. Run with the underlying error message (it is wrapped) to see the exact field that failed parsing.
  4. Remove or fix the request-logging flags to boot with defaults.

Example fix

// before
query-frontend --http.request.log-format=jsn
// after
query-frontend --http.request.log-format=json
Defensive patterns

Strategy: validation

Validate before calling

const v := os.Getenv("HTTP_REQ_LOG_FORMAT")
if v != "" && v != "logfmt" && v != "json" {
  return fmt.Errorf("unsupported request log format %q (want logfmt|json)", v)
}

Try / catch

if _, err := logging.ParseHTTOptions(reqLogConfig); err != nil {
  return fmt.Errorf("request logging config invalid: %w", err)
}

Prevention

When it happens

Trigger: Passing --http.request.log-format with an unsupported format string, or pointing a request-logging flag at a file whose content is not valid YAML for the logging options schema.

Common situations: Typo in the log format value (e.g. 'jsonl' instead of 'logfmt'/'json'), a YAML file with wrong indentation, or an empty/garbage file passed to the request-logging config flags.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at cmd/thanos/query_frontend.go:181

		"If multiple headers match the request, the first matching arg specified will take precedence. "+
		"If no headers match 'anonymous' will be used.").PlaceHolder("<http-header-name>").StringsVar(&cfg.orgIdHeaders)

	cmd.Flag("query-frontend.forward-header", "List of headers forwarded by the query-frontend to downstream queriers, default is empty").PlaceHolder("<http-header-name>").StringsVar(&cfg.ForwardHeaders)

	cmd.Flag("query-frontend.tenant-header", "HTTP header to determine tenant").Default(tenancy.DefaultTenantHeader).Hidden().StringVar(&cfg.TenantHeader)
	cmd.Flag("query-frontend.default-tenant-id", "Default tenant ID to use if tenant header is not present").Default(tenancy.DefaultTenant).Hidden().StringVar(&cfg.DefaultTenant)
	cmd.Flag("query-frontend.tenant-certificate-field", "Use TLS client's certificate field to determine tenant for requests. Must be one of "+tenancy.CertificateFieldOrganization+", "+tenancy.CertificateFieldOrganizationalUnit+" or "+tenancy.CertificateFieldCommonName+". This setting will cause the query-frontend.tenant-header flag value to be ignored.").Hidden().Default("").EnumVar(&cfg.TenantCertField, "", tenancy.CertificateFieldOrganization, tenancy.CertificateFieldOrganizationalUnit, tenancy.CertificateFieldCommonName)

	cmd.Flag("query-frontend.vertical-shards", "Number of shards to use when distributing shardable PromQL queries. For more details, you can refer to the Vertical query sharding proposal: https://thanos.io/tip/proposals-accepted/202205-vertical-query-sharding.md").IntVar(&cfg.NumShards)

	cmd.Flag("query-frontend.slow-query-logs-user-header", "Set the value of the field remote_user in the slow query logs to the value of the given HTTP header. Falls back to reading the user from the basic auth header.").PlaceHolder("<http-header-name>").Default("").StringVar(&cfg.CortexHandlerConfig.SlowQueryLogsUserHeader)

	reqLogConfig := extkingpin.RegisterRequestLoggingFlags(cmd)

	cmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ <-chan struct{}, _ bool) error {
		httpLogOpts, err := logging.ParseHTTPOptions(reqLogConfig)
		if err != nil {
			return errors.Wrap(err, "error while parsing config for request logging")
		}

		return runQueryFrontend(g, logger, reg, tracer, httpLogOpts, cfg, comp)
	})
}

func parseTransportConfiguration(downstreamTripperConfContentYaml []byte) (*http.Transport, error) {
	downstreamTripper := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
			DualStack: true,
		}).DialContext,
		ForceAttemptHTTP2:     true,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,

View on GitHub (pinned to 35b8b99117)