{"record":{"id":"3e6f0f39c7a5eca2","repo":"thanos-io/thanos","slug":"fetch-prometheus-flags","errorCode":null,"errorMessage":"fetch Prometheus flags","messagePattern":"fetch Prometheus flags","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/sidecar.go","lineNumber":505,"sourceCode":"\t\t}, func(error) {\n\t\t\tcancel()\n\t\t})\n\t}\n\n\tlevel.Info(logger).Log(\"msg\", \"starting sidecar\")\n\treturn nil\n}\n\nfunc validatePrometheus(ctx context.Context, client *promclient.Client, logger log.Logger, conf *sidecarConfig, m *promMetadata) error {\n\tvar (\n\t\tflagErr error\n\t\tflags   promclient.Flags\n\t)\n\n\tif err := runutil.Retry(2*time.Second, ctx.Done(), func() error {\n\t\tif flags, flagErr = client.ConfiguredFlags(ctx, m.promURL); flagErr != nil && flagErr != promclient.ErrFlagEndpointNotFound {\n\t\t\tlevel.Warn(logger).Log(\"msg\", \"failed to get Prometheus flags. Is Prometheus running? Retrying\", \"err\", flagErr)\n\t\t\treturn errors.Wrapf(flagErr, \"fetch Prometheus flags\")\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\treturn errors.Wrapf(err, \"fetch Prometheus flags\")\n\t}\n\n\tif flagErr != nil {\n\t\tlevel.Warn(logger).Log(\"msg\", \"failed to check Prometheus flags, due to potentially older Prometheus. No extra validation is done.\", \"err\", flagErr)\n\t\treturn nil\n\t}\n\n\tif flags.TSDBDelayCompact != \"\" {\n\t\tthanosMetaPath := filepath.Join(conf.tsdb.path, conf.shipper.metaFileName)\n\t\tif filepath.Clean(flags.TSDBDelayCompact) != filepath.Clean(thanosMetaPath) {\n\t\t\treturn errors.Errorf(\n\t\t\t\t\"found that Prometheus and Thanos use different paths for tracking block uploads. \"+\n\t\t\t\t\t\"Prometheus uses --storage.tsdb.delay-compact-file.path=%s while Thanos will write to %s, they must both use the same path.\",\n\t\t\t\tflags.TSDBDelayCompact, thanosMetaPath,","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/sidecar.go#L487-L523","documentation":"Inside validatePrometheus, the sidecar repeatedly calls client.ConfiguredFlags against the Prometheus /api/v1/status/flags endpoint. If the call fails with anything other than ErrFlagEndpointNotFound, the error is logged as a warning, retried, and wrapped as 'fetch Prometheus flags'; if the whole retry loop exits (ctx cancelled), the outer wrap also produces this message.","triggerScenarios":"Prometheus is unreachable (connection refused/timeout) or returns a failing HTTP status from /api/v1/status/flags while the sidecar validates its configuration; retries continue every 2s until success or ctx cancellation.","commonSituations":"Prometheus down during sidecar startup; wrong --prometheus.url; a load balancer stripping the status endpoint; ctx cancelled because the operator stopped Thanos during a long Prometheus outage.","solutions":["Check Prometheus health and --prometheus.url reachability (curl <url>/api/v1/status/flags).","Wait for Prometheus to become fully started; the sidecar retries automatically every 2s.","If the outer wrap fired, the context was cancelled — investigate why the run group shut down.","Note ErrFlagEndpointNotFound is tolerated (older Prometheus); other failures are not."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"resp, err := http.Get(promURL + \"/api/v1/status/flags\")\nif err != nil || resp.StatusCode != 200 { /* defer validation */ }","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var ctxErr bool = errors.Is(err, context.Canceled)\n    if ctxErr { return err } // cancelled: abort, don't retry\n}","preventionTips":["Ensure Prometheus is up before launching Thanos components (readiness probes).","Keep the status flags endpoint reachable through any proxy."],"tags":["prometheus","validation","network","retry"],"backgroundTag":"http-request-failed","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"}