{"record":{"id":"d02c0f18b31ec916","repo":"thanos-io/thanos","slug":"query-not-analyzable-change-engine-to-thanos","errorCode":null,"errorMessage":"Query not analyzable; change engine to 'thanos'.","messagePattern":"Query not analyzable; change engine to 'thanos'\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/api/query/v1.go","lineNumber":458,"sourceCode":"\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()\n\tanalysis.TotalSamples = a.TotalSamples()\n\tif stores := tracker.Get(a.OperatorID); len(stores) > 0 {\n\t\tanalysis.Fanout = make([]fanoutEntry, 0, len(stores))\n\t\tfor _, s := range stores {\n\t\t\tanalysis.Fanout = append(analysis.Fanout, fanoutEntry{\n\t\t\t\tEndpointAddr:   s.EndpointAddr,\n\t\t\t\tDuration:       s.Duration.String(),\n\t\t\t\tBytesProcessed: s.BytesProcessed,","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/api/query/v1.go#L440-L476","documentation":"When the query is not explainable and the requested engine is not 'thanos' (i.e. the user explicitly chose the Prometheus engine), analyzeQueryOutput returns this advisory warning telling the user to switch the engine to 'thanos' to get query analysis. The query results are still returned; only analysis output is unavailable.","triggerScenarios":"query/queryRange with `analyze=true` and `engine=prometheus` (or engine unset while prometheus is the active engine), so the query type lacks Analyze().","commonSituations":"Users testing analysis with the default Prometheus engine; clients enabling analyze on endpoints configured with engine=prometheus.","solutions":["Add `engine=thanos` to the request when you need analysis output.","Disable the analyze parameter if you intentionally use the Prometheus engine.","Configure clients/dashboards to only request analysis against Thanos-engine endpoints."],"exampleFix":"// before\nGET /api/v1/query?query=up&analyze=true&engine=prometheus\n// after\nGET /api/v1/query?query=up&analyze=true&engine=thanos","handlingStrategy":"fallback","validationCode":"if (analyzeRequested && engine !== 'thanos') {\n  console.warn('analysis requires engine=thanos; disabling analyze');\n  analyzeRequested = false;\n}","typeGuard":null,"tryCatchPattern":"const body = await res.json();\nif (body.status === 'error' && /change engine to 'thanos'/.test(body.error)) {\n  // either add engine=thanos or drop the analyze param and retry\n}","preventionTips":["Pair the analyze flag with engine=thanos in client code.","Warn users in UIs when they enable analysis on a Prometheus-engine endpoint.","Document that analysis is a Thanos-engine-only feature."],"tags":["http-api","promql","analyze","engine-selection"],"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"}