{"record":{"id":"a7944819b1af6a38","repo":"thanos-io/thanos","slug":"create-prometheus-store","errorCode":null,"errorMessage":"create Prometheus store","messagePattern":"create Prometheus store","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/sidecar.go","lineNumber":320,"sourceCode":"\t}\n\n\t// Setup the Reloader.\n\t{\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tg.Add(func() error {\n\t\t\treturn reloader.Watch(ctx)\n\t\t}, func(error) {\n\t\t\tcancel()\n\t\t})\n\t}\n\n\t// Setup the gRPC server.\n\t{\n\t\tc := promclient.NewWithTracingClient(logger, httpClient, clientconfig.ThanosUserAgent)\n\n\t\tpromStore, err := store.NewPrometheusStore(logger, reg, c, conf.prometheus.url, component.Sidecar, m.Labels, m.Timestamps, m.Version)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"create Prometheus store\")\n\t\t}\n\n\t\ttlsCfg, err := tls.NewServerConfig(log.With(logger, \"protocol\", \"gRPC\"),\n\t\t\tconf.grpc.tlsSrvCert, conf.grpc.tlsSrvKey, conf.grpc.tlsSrvClientCA, conf.grpc.tlsMinVersion, conf.grpc.tlsCiphers, conf.grpc.tlsCurves)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"setup gRPC server\")\n\t\t}\n\n\t\texemplarSrv := exemplars.NewPrometheus(conf.prometheus.url, c, m.Labels)\n\n\t\tinfoSrv := info.NewInfoServer(\n\t\t\tcomponent.Sidecar.String(),\n\t\t\tinfo.WithLabelSetFunc(func() []labelpb.ZLabelSet {\n\t\t\t\treturn promStore.LabelSet()\n\t\t\t}),\n\t\t\tinfo.WithStoreInfoFunc(func() (*infopb.StoreInfo, error) {\n\t\t\t\tif httpProbe.IsReady() {\n\t\t\t\t\tmint, maxt := m.Timestamps()","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/sidecar.go#L302-L338","documentation":"store.NewPrometheusStore failed to construct the Prometheus store proxy (StoreAPI served over gRPC). Construction validates the client and metadata functions; failures are wrapped as 'create Prometheus Store'. This happens before the gRPC server starts, so the sidecar exits.","triggerScenarios":"errors.Wrap in runSidecar: NewPrometheusStore returned an error — e.g. an invalid --prometheus.url (unparseable/unsupported scheme) passed to the underlying HTTP client construction.","commonSituations":"Malformed --prometheus.url value (missing scheme, invalid characters); regression when wiring custom client functions; nil metadata functions from a failed earlier step in modified builds.","solutions":["Correct the --prometheus.url flag value (include scheme, e.g. http://prometheus:9090)","Check earlier log lines for the underlying error detail; fix what NewPrometheusStore reports","Ensure you run a thanos version whose sidecar expects the current flag format","If running patched code, verify the promclient and metadata funcs passed to NewPrometheusStore are non-nil"],"exampleFix":"// before\n--prometheus.url=prometheus.monitoring:9090   # no scheme\n// after\n--prometheus.url=http://prometheus.monitoring:9090","handlingStrategy":"validation","validationCode":"u, err := url.Parse(promURL)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") {\n    return fmt.Errorf(\"--prometheus.url must be an absolute http(s) URL, got %q\", promURL)\n}","typeGuard":null,"tryCatchPattern":"promStore, err := store.NewPrometheusStore(...)\nif err != nil {\n    return errors.Wrap(err, \"create Prometheus store\")\n}","preventionTips":["Always include the scheme in --prometheus.url","Validate flag URLs at deploy time (Helm/chart linting)","Keep client constructor arguments non-nil when customizing promclient","Test sidecar startup in CI with a representative prometheus.url"],"tags":["thanos","store-api","url","startup"],"backgroundTag":"invalid-url","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"}