{"record":{"id":"2456e98212ef6073","repo":"thanos-io/thanos","slug":"query-v-not-analyzable","errorCode":null,"errorMessage":"Query: %v not analyzable","messagePattern":"Query: (.+?) not analyzable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/api/query/v1.go","lineNumber":450,"sourceCode":"}\n\nfunc (qapi *QueryAPI) getQueryExplain(query promql.Query) (*engine.ExplainOutputNode, *api.ApiError) {\n\tif eq, ok := query.(engine.ExplainableQuery); ok {\n\t\treturn eq.Explain(), nil\n\t}\n\treturn nil, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Errorf(\"Query not explainable\")}\n}\n\nfunc (qapi *QueryAPI) parseQueryAnalyzeParam(r *http.Request) bool {\n\treturn (r.FormValue(QueryAnalyzeParam) == \"true\" || r.FormValue(QueryAnalyzeParam) == \"1\")\n}\n\nfunc analyzeQueryOutput(query promql.Query, engineType PromqlEngineType, tracker *fanout.Tracker) (queryTelemetry, error) {\n\tif eq, ok := query.(engine.ExplainableQuery); ok {\n\t\tif analyze := eq.Analyze(); analyze != nil {\n\t\t\treturn processAnalysis(analyze, tracker), nil\n\t\t} else {\n\t\t\treturn queryTelemetry{}, errors.Errorf(\"Query: %v not analyzable\", query)\n\t\t}\n\t}\n\n\tvar warning error\n\tif engineType == PromqlEngineThanos {\n\t\twarning = errors.New(\"Query fallback to prometheus engine; not analyzable.\")\n\t} else {\n\t\twarning = errors.New(\"Query not analyzable; change engine to 'thanos'.\")\n\t}\n\n\treturn queryTelemetry{}, warning\n}\n\nfunc processAnalysis(a *engine.AnalyzeOutputNode, tracker *fanout.Tracker) queryTelemetry {\n\tvar analysis queryTelemetry\n\tanalysis.OperatorName = a.OperatorTelemetry.String()\n\tanalysis.Execution = a.OperatorTelemetry.ExecutionTimeTaken().String()\n\tanalysis.PeakSamples = a.PeakSamples()","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/api/query/v1.go#L432-L468","documentation":"analyzeQueryOutput returns this error when the query implements ExplainableQuery (i.e. runs on the Thanos engine) but eq.Analyze() returns nil, meaning the engine could not produce an analysis plan for the query. It surfaces as a warning/error on /api/v1/query and /api/v1/query_range when the analyze parameter is set.","triggerScenarios":"Calling query/queryRange with `analyze=true` (or `analyze=1`) on a Thanos-engine query whose Analyze() returns nil, typically for trivial or unsupported query shapes the analyzer cannot represent.","commonSituations":"Profiled/analyzed dashboards where the query is a constant expression or otherwise has no execution plan nodes; querying with analyze enabled during engine upgrades where analysis is partially supported.","solutions":["Retry the query without the analyze parameter to get results without analysis telemetry.","Simplify or reshape the query so the Thanos engine produces a non-nil analysis plan.","Upgrade Thanos; newer engines return an analysis for more query shapes instead of nil."],"exampleFix":"// before\nGET /api/v1/query?query=vector(1)&analyze=true\n// after\nGET /api/v1/query?query=vector(1)","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"const body = await res.json();\nif (body.status === 'error' && /not analyzable/.test(body.error)) {\n  // retry once without the analyze parameter\n  return fetch(urlWithoutAnalyze);\n}","preventionTips":["Make analyze opt-in and non-fatal in clients; retry without it on failure.","Avoid analyze on trivial/constant queries where the engine has no plan.","Keep Thanos up to date for broader Analyze() coverage."],"tags":["http-api","promql","analyze","telemetry"],"backgroundTag":"unsupported-operation","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"}