{"record":{"id":"11c2749bed1a8935","repo":"SigNoz/signoz","slug":"error-while-executing-metric-name-query-s","errorCode":null,"errorMessage":"error while executing metric name query: %s","messagePattern":"error while executing metric name query: (.+?)","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":2986,"sourceCode":"\t\t\t )`,\n\t\t\tsignozMetricDBName, signozTSTableNameV41Day,\n\t\t\tsignozMetricDBName, signozTSTableNameV4Reduced)\n\t} else {\n\t\tquery = fmt.Sprintf(\n\t\t\t`SELECT DISTINCT metric_name\n\t\t\t FROM %s.%s\n\t\t\t WHERE metric_name ILIKE $1`,\n\t\t\tsignozMetricDBName, signozTSTableNameV41Day)\n\t}\n\n\tif req.Limit != 0 {\n\t\tquery = query + fmt.Sprintf(\" LIMIT %d;\", req.Limit)\n\t}\n\n\trows, err := r.db.Query(ctx, query, fmt.Sprintf(\"%%%s%%\", req.SearchText))\n\tif err != nil {\n\t\tr.logger.Error(\"Error while querying metric names\", errorsV2.Attr(err))\n\t\treturn nil, fmt.Errorf(\"error while executing metric name query: %s\", err.Error())\n\t}\n\tdefer rows.Close()\n\n\tvar metricNames []string\n\tfor rows.Next() {\n\t\tvar name string\n\t\tif err := rows.Scan(&name); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error while scanning metric name: %s\", err.Error())\n\t\t}\n\t\tif skipSignozMetrics && strings.HasPrefix(name, \"signoz\") {\n\t\t\tcontinue\n\t\t}\n\t\tmetricNames = append(metricNames, name)\n\t}\n\n\tif len(metricNames) == 0 {\n\t\treturn &response, nil\n\t}","sourceCodeStart":2968,"sourceCodeEnd":3004,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L2968-L3004","documentation":"GetMetricName from the ClickHouse reader: the SELECT against time_series metric names (filtered by a %searchText% LIKE pattern) failed to run. The raw ClickHouse error is appended (%s), so the message carries the actual driver error text — read it to distinguish missing table, bad connection, or syntax problems.","triggerScenarios":"Calling ListMetricKeyValues / metrics autocomplete APIs with a SearchText while the time_series table doesn't exist (no metrics ingested yet), ClickHouse is unreachable, or the query builder produced invalid SQL for exotic search strings.","commonSituations":"Fresh SigNoz installs with zero metrics yet; signoz_metrics schema not migrated; CLICKHOUSE_DATASOURCE misconfigured; upgrade that renamed the time_series table.","solutions":["Read the %s portion — it contains the real ClickHouse error","If 'table doesn't exist', ingest some metrics or run migrations to create signoz_metrics tables","Verify ClickHouse connectivity from query-service (ping the datasource URL)","Escape or clamp SearchText if users can inject % or _ into the LIKE pattern"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure metrics exist before listing: SELECT count() FROM signoz_metrics.time_series","typeGuard":null,"tryCatchPattern":"if err != nil {\n  if strings.Contains(err.Error(), \"Code: 60\") { // UNKNOWN_TABLE\n    return []string{}, nil // no metrics yet — not an error for the user\n  }\n  return nil, err\n}","preventionTips":["Run migrations before first use on fresh installs","Clamp/escape SearchText to avoid pathological LIKE patterns","Retry transient ClickHouse connectivity failures with backoff"],"tags":["clickhouse","metrics","query-execution","autocomplete"],"backgroundTag":"database-query-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}