{"record":{"id":"d7309b51c122a736","repo":"thanos-io/thanos","slug":"request-snapshot-against-s","errorCode":null,"errorMessage":"request snapshot against %s","messagePattern":"request snapshot against (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/promclient/promclient.go","lineNumber":358,"sourceCode":"\tu := *base\n\tu.Path = path.Join(u.Path, \"/api/v1/admin/tsdb/snapshot\")\n\n\treq, err := http.NewRequest(\n\t\thttp.MethodPost,\n\t\tu.String(),\n\t\tstrings.NewReader(url.Values{\"skip_head\": []string{strconv.FormatBool(skipHead)}}.Encode()),\n\t)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"create request\")\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\tspan, ctx := tracing.StartSpan(ctx, \"/prom_snapshot HTTP[client]\")\n\tdefer span.Finish()\n\n\tresp, err := c.Do(req.WithContext(ctx))\n\tif err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"request snapshot against %s\", u.String())\n\t}\n\tdefer runutil.ExhaustCloseWithLogOnErr(c.logger, resp.Body, \"query body\")\n\n\tb, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", errors.New(\"failed to read body\")\n\t}\n\n\tif resp.StatusCode != 200 {\n\t\treturn \"\", errors.Errorf(\"is 'web.enable-admin-api' flag enabled? got non-200 response code: %v, response: %v\", resp.StatusCode, string(b))\n\t}\n\n\tvar d struct {\n\t\tData struct {\n\t\t\tName string `json:\"name\"`\n\t\t} `json:\"data\"`\n\t}\n\tif err := json.Unmarshal(b, &d); err != nil {","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/promclient/promclient.go#L340-L376","documentation":"Client.Snapshot executes the snapshot POST request via the HTTP client within the request context. This error wraps any transport-level failure while requesting the snapshot, including the target URL in the message. It is thrown before any response is read.","triggerScenarios":"c.Do(req.WithContext(ctx)) fails: DNS resolution failure, connection refused/timeout, TLS handshake error, or ctx cancelled/expired mid-request.","commonSituations":"Prometheus host unreachable (wrong address/firewall); network partitions during backup jobs; context deadline exceeded because snapshot of large TSDB takes longer than the caller's timeout; TLS certificate issues.","solutions":["Check connectivity to the Prometheus endpoint (curl the URL from the error)","Increase or remove the caller's context deadline — snapshots can be slow on large TSDBs","Verify DNS/firewall/TLS configuration between caller and Prometheus","Retry with backoff on transient network errors"],"exampleFix":"// before\nctx := context.Background()\ndir, err := client.Snapshot(ctx, base, false)\n// after\nctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)\ndefer cancel()\ndir, err := client.Snapshot(ctx, base, false)","handlingStrategy":"retry","validationCode":"conn, err := net.DialTimeout(\"tcp\", \"prometheus:9090\", 5*time.Second)\nif err != nil { return fmt.Errorf(\"prometheus unreachable: %w\", err) }\nconn.Close()","typeGuard":null,"tryCatchPattern":"var dir string\nerr := backoff.Retry(func() error {\n    var e error\n    dir, e = client.Snapshot(ctx, base, skipHead)\n    return e\n}, backoff.WithContext(backoff.NewExponentialBackOff(), ctx))","preventionTips":["Use generous context timeouts — snapshots of large TSDBs are slow","Monitor network paths to Prometheus before backup windows","Retry transient transport errors with exponential backoff"],"tags":["network","http","timeout"],"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"}