{"record":{"id":"0c15f62012e2ba8e","repo":"thanos-io/thanos","slug":"is-web-enable-admin-api-flag-enabled-got-non-20","errorCode":null,"errorMessage":"is 'web.enable-admin-api' flag enabled? got non-200 response code: %v, response: %v","messagePattern":"is 'web\\.enable-admin-api' flag enabled\\? got non-200 response code: (.+?), response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/promclient/promclient.go","lineNumber":368,"sourceCode":"\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 {\n\t\treturn \"\", errors.Wrapf(err, \"unmarshal response: %v\", string(b))\n\t}\n\n\treturn path.Join(\"snapshots\", d.Data.Name), nil\n}\n\ntype QueryOptions struct {\n\tDoNotAddThanosParams    bool\n\tDeduplicate             bool\n\tPartialResponseStrategy storepb.PartialResponseStrategy","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/promclient/promclient.go#L350-L386","documentation":"Client.Snapshot requires HTTP 200 from the admin snapshot API. Any other status triggers this error, which explicitly hints that Prometheus must be started with the --web.enable-admin-api flag. The status code and response body are included for diagnosis.","triggerScenarios":"The POST to /api/v1/admin/tsdb/snapshot returns non-200 — most commonly 405/404 because the admin API is disabled (default in Prometheus), or 401/403 due to auth, or 5xx server-side failure.","commonSituations":"Prometheus running with default flags where admin APIs are disabled — the by-far most common cause; reverse proxy blocking POST; permission-gated admin endpoints in secured clusters.","solutions":["Restart Prometheus with --web.enable-admin-api to enable the snapshot endpoint","Check the status code in the error: 404/405 means admin API disabled; 401/403 means auth required","Confirm the URL path resolves to /api/v1/admin/tsdb/snapshot","If admin API cannot be enabled, use an alternative backup mechanism (e.g. filesystem-level backup of the TSDB)"],"exampleFix":"// before\n# prometheus started with defaults\n./prometheus --config.file=prometheus.yml\n// after\n./prometheus --config.file=prometheus.yml --web.enable-admin-api","handlingStrategy":"validation","validationCode":"// Check the flag is present before calling Snapshot\nflags, err := client.ConfiguredFlags(ctx)\nif err != nil { return err }\nif _, ok := flags[\"web.enable-admin-api\"]; !ok {\n    return errors.New(\"prometheus must run with --web.enable-admin-api for snapshots\")\n}","typeGuard":null,"tryCatchPattern":"dir, err := client.Snapshot(ctx, base, skipHead)\nif err != nil && strings.Contains(err.Error(), \"web.enable-admin-api\") {\n    return fmt.Errorf(\"enable admin API on prometheus: %w\", err)\n}","preventionTips":["Start Prometheus with --web.enable-admin-api where snapshots are needed","Pre-check ConfiguredFlags for the admin-api flag","Account for 405/404 meaning admin API disabled"],"tags":["http","prometheus","admin-api","configuration"],"backgroundTag":"http-non-200-response","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"}