{"record":{"id":"e6fed2b75aed8660","repo":"thanos-io/thanos","slug":"error-while-parsing-config-for-request-logging-e6fed2","errorCode":null,"errorMessage":"error while parsing config for request logging","messagePattern":"error while parsing config for request logging","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/sidecar.go","lineNumber":70,"sourceCode":"\t\"github.com/thanos-io/thanos/pkg/shipper\"\n\t\"github.com/thanos-io/thanos/pkg/status\"\n\t\"github.com/thanos-io/thanos/pkg/store\"\n\t\"github.com/thanos-io/thanos/pkg/store/labelpb\"\n\t\"github.com/thanos-io/thanos/pkg/store/storepb\"\n\t\"github.com/thanos-io/thanos/pkg/targets\"\n\t\"github.com/thanos-io/thanos/pkg/tls\"\n)\n\nfunc registerSidecar(app *extkingpin.App) {\n\tcmd := app.Command(component.Sidecar.String(), \"Sidecar for Prometheus server.\")\n\tconf := &sidecarConfig{}\n\tconf.registerFlag(cmd)\n\tcmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ <-chan struct{}, _ bool) error {\n\n\t\tgrpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(conf.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\thttpConfContentYaml, err := conf.prometheus.httpClient.Content()\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"getting http client config\")\n\t\t}\n\t\thttpClientConfig, err := clientconfig.NewHTTPClientConfigFromYAML(httpConfContentYaml)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"parsing http config YAML\")\n\t\t}\n\n\t\thttpClient, err := clientconfig.NewHTTPClient(*httpClientConfig, \"thanos-sidecar\")\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"Improper http client config\")\n\t\t}\n\n\t\topts := reloader.Options{\n\t\t\tHTTPClient:    *httpClient,","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/sidecar.go#L52-L88","documentation":"At sidecar startup, Thanos parses the request-logging configuration (--request-logging-config / reqLogConfig) with logging.ParsegRPCOptions to derive gRPC logging options and filtered methods. If that config string is invalid JSON/YAML or structurally wrong, the setup function aborts with \"error while parsing config for request logging\" and the sidecar refuses to start.","triggerScenarios":"Running the sidecar with a --request-logging-config flag (or the corresponding conf.reqLogConfig content) that ParsegRPCOptions cannot parse — malformed JSON, unknown log level, or an entry that isn't a valid gRPC method pattern.","commonSituations":"Typos in the inline JSON config passed via flag; Kubernetes manifests quoting/escaping the YAML incorrectly so the flag value is mangled; specifying a level other than the supported levels (e.g. debug/info/error) or an invalid method filter.","solutions":["Validate the request-logging config content: it must be valid JSON/YAML with a supported log level (debug, info, error) and valid gRPC method patterns.","Fix quoting/escaping of the flag value in your manifest or systemd unit — multi-line JSON often breaks shell quoting.","Temporarily remove --request-logging-config to confirm the error is isolated to that flag, then re-add a minimal valid config.","Read the wrapped ParsegRPCOptions error in the message for the exact offending field or method entry."],"exampleFix":"// before\n--request-logging-config='{\"level\": \"verbose\"}'\n// after\n--request-logging-config='{\"level\": \"debug\"}'","handlingStrategy":"validation","validationCode":"func validReqLogConfig(cfg string) error {\n    var opts map[string]interface{}\n    return json.Unmarshal([]byte(cfg), &opts) // syntax check; level/method validation per logging docs\n}","typeGuard":"null","tryCatchPattern":"grpcLogOpts, logFilterMethods, err := logging.ParsegRPCOptions(conf.reqLogConfig)\nif err != nil {\n    logger.Error(\"invalid --request-logging-config\", \"err\", err)\n    return fmt.Errorf(\"invalid --request-logging-config: %w\", err)\n}","preventionTips":["Keep request-logging config JSON in a checked-in manifest and lint it as JSON","Only use supported levels (debug, info, error) and valid gRPC method patterns","Beware shell quoting of inline JSON flags in systemd/Kubernetes specs"],"tags":["go","config","startup","logging","thanos"],"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"}