{"record":{"id":"ae881dbf8fb7c781","repo":"SigNoz/signoz","slug":"couldn-t-get-attribute-keys-w","errorCode":null,"errorMessage":"couldn't get attribute keys: %w","messagePattern":"couldn't get attribute keys: %w","errorType":"exception","errorClass":"model.ApiError","httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/filter_suggestions.go","lineNumber":34,"sourceCode":"\nfunc (r *ClickHouseReader) GetQBFilterSuggestionsForLogs(\n\tctx context.Context,\n\treq *v3.QBFilterSuggestionsRequest,\n) (*v3.QBFilterSuggestionsResponse, *model.ApiError) {\n\tsuggestions := v3.QBFilterSuggestionsResponse{\n\t\tAttributeKeys:  []v3.AttributeKey{},\n\t\tExampleQueries: []v3.FilterSet{},\n\t}\n\n\t// Use existing autocomplete logic for generating attribute suggestions\n\tattribKeysResp, err := r.GetLogAttributeKeys(\n\t\tctx, &v3.FilterAttributeKeyRequest{\n\t\t\tSearchText: req.SearchText,\n\t\t\tDataSource: v3.DataSourceLogs,\n\t\t\tLimit:      int(req.AttributesLimit),\n\t\t})\n\tif err != nil {\n\t\treturn nil, model.InternalError(fmt.Errorf(\"couldn't get attribute keys: %w\", err))\n\t}\n\n\tsuggestions.AttributeKeys = attribKeysResp.AttributeKeys\n\n\t// Rank suggested attributes\n\tattribRanker.sort(suggestions.AttributeKeys)\n\n\t// Put together suggested example queries.\n\n\tnewExampleQuery := func() v3.FilterSet {\n\t\t// Include existing filter in example query if specified.\n\t\tif req.ExistingFilter != nil {\n\t\t\treturn *req.ExistingFilter\n\t\t}\n\n\t\treturn v3.FilterSet{\n\t\t\tOperator: \"AND\",\n\t\t\tItems:    []v3.FilterItem{},","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/filter_suggestions.go#L16-L52","documentation":"Returned by GetQBFilterSuggestionsForLogs when the underlying call to fetch log attribute keys (GetAttributeKeys against the logs data source, e.g. signoz_logs.distributed_log_attribute_keys) fails. It is an InternalError wrapping the ClickHouse query failure, so the root cause is in the wrapped %w error.","triggerScenarios":"Calling the query-builder filter-suggestions API for logs while ClickHouse is unreachable, the attribute-keys table doesn't exist (cold cluster / migrations not run), or the query times out or is killed for resource limits.","commonSituations":"Fresh SigNoz install where ClickHouse schema/migrations haven't completed, wrong CH connection settings (CLICKHOUSE_URL misconfigured), ClickHouse overload or memory limits aborting the query, or version mismatch where the attribute keys table was renamed.","solutions":["Inspect the wrapped error and server logs for the real ClickHouse failure","Verify ClickHouse connectivity and that the logs schema (distributed_log_attribute_keys etc.) exists","Run/complete ClickHouse migrations if tables are missing","Increase ClickHouse memory/thread settings or reduce AttributesLimit if the query is being killed","Retry once ClickHouse is healthy"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: verify CH reachability and attribute-keys table exists\nif err := pingClickhouse(chAddr); err != nil { return err }\nif !tableExists(ctx, ch, \"signoz_logs\", \"distributed_log_attribute_keys\") {\n    return fmt.Errorf(\"logs schema missing; run migrations\")\n}","typeGuard":"func isInternalApiErr(err error) bool {\n    var apiErr *model.ApiError\n    return errors.As(err, &apiErr) && apiErr.Typ == model.ErrorInternal\n}","tryCatchPattern":"suggestions, err := api.GetQBFilterSuggestionsForLogs(ctx, req)\nif err != nil {\n    logAttrs(\"attr-keys failed\", err) // wrapped %w carries CH cause\n    return degradeGracefully(ctx) // e.g. empty suggestions + 5xx\n}","preventionTips":["Health-check ClickHouse before serving suggestion endpoints","Keep SigNoz migrations complete before enabling the QB","Bound AttributesLimit to keep key lookups cheap"],"tags":["clickhouse","logs","filter-suggestions","database"],"backgroundTag":"database-query-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}