{"record":{"id":"6fefc84d9b0e1984","repo":"thanos-io/thanos","slug":"error-while-parsing-config-for-request-logging-6fefc8","errorCode":null,"errorMessage":"error while parsing config for request logging","messagePattern":"error while parsing config for request logging","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/query_frontend.go","lineNumber":181,"sourceCode":"\t\t\"If multiple headers match the request, the first matching arg specified will take precedence. \"+\n\t\t\"If no headers match 'anonymous' will be used.\").PlaceHolder(\"<http-header-name>\").StringsVar(&cfg.orgIdHeaders)\n\n\tcmd.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)\n\n\tcmd.Flag(\"query-frontend.tenant-header\", \"HTTP header to determine tenant\").Default(tenancy.DefaultTenantHeader).Hidden().StringVar(&cfg.TenantHeader)\n\tcmd.Flag(\"query-frontend.default-tenant-id\", \"Default tenant ID to use if tenant header is not present\").Default(tenancy.DefaultTenant).Hidden().StringVar(&cfg.DefaultTenant)\n\tcmd.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)\n\n\tcmd.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)\n\n\tcmd.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)\n\n\treqLogConfig := extkingpin.RegisterRequestLoggingFlags(cmd)\n\n\tcmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ <-chan struct{}, _ bool) error {\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\treturn runQueryFrontend(g, logger, reg, tracer, httpLogOpts, cfg, comp)\n\t})\n}\n\nfunc parseTransportConfiguration(downstreamTripperConfContentYaml []byte) (*http.Transport, error) {\n\tdownstreamTripper := &http.Transport{\n\t\tProxy: http.ProxyFromEnvironment,\n\t\tDialContext: (&net.Dialer{\n\t\t\tTimeout:   30 * time.Second,\n\t\t\tKeepAlive: 30 * time.Second,\n\t\t\tDualStack: true,\n\t\t}).DialContext,\n\t\tForceAttemptHTTP2:     true,\n\t\tMaxIdleConns:          100,\n\t\tIdleConnTimeout:       90 * time.Second,\n\t\tTLSHandshakeTimeout:   10 * time.Second,","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/query_frontend.go#L163-L199","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the --http.request.*-log-format / request-logging flag values for typos against accepted values (logfmt, json).","If a config file is used, validate its YAML with yamllint and ensure it matches logging options schema.","Run with the underlying error message (it is wrapped) to see the exact field that failed parsing.","Remove or fix the request-logging flags to boot with defaults."],"exampleFix":"// before\nquery-frontend --http.request.log-format=jsn\n// after\nquery-frontend --http.request.log-format=json","handlingStrategy":"validation","validationCode":"const v := os.Getenv(\"HTTP_REQ_LOG_FORMAT\")\nif v != \"\" && v != \"logfmt\" && v != \"json\" {\n  return fmt.Errorf(\"unsupported request log format %q (want logfmt|json)\", v)\n}","typeGuard":null,"tryCatchPattern":"if _, err := logging.ParseHTTOptions(reqLogConfig); err != nil {\n  return fmt.Errorf(\"request logging config invalid: %w\", err)\n}","preventionTips":["Keep request-logging flags to documented values only","Lint any YAML used for logging options","Test flag sets in CI before rollout"],"tags":["config","logging","cli"],"backgroundTag":"invalid-config-value","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"}