SigNoz/signoz · error
error while executing query: %s
Error message
error while executing query: %s
What it means
In the metric attribute-keys lookup, the db.Query with parameters (AggregateAttribute, PastDayRoundOff, %SearchText%) failed to execute. This query lists tag keys associated with a chosen metric over the last day; failure means ClickHouse rejected or could not run it, with the raw error embedded in %s.
Source
Thrown at pkg/query-service/app/clickhouseReader/reader.go:3121
var err error
var rows driver.Rows
var response v3.FilterAttributeKeyResponse
reductionEnabled := r.fl.BooleanOrEmpty(ctx, flagger.FeatureEnableMetricsReduction, featuretypes.NewFlaggerEvaluationContext(orgID))
// skips the internal attributes i.e attributes starting with __
if reductionEnabled {
query = fmt.Sprintf("SELECT arrayJoin(tagKeys) AS distinctTagKey FROM (SELECT JSONExtractKeys(labels) AS tagKeys FROM %s.%s WHERE metric_name=$1 AND unix_milli >= $2 GROUP BY tagKeys UNION ALL SELECT JSONExtractKeys(labels) AS tagKeys FROM %s.%s WHERE metric_name=$1 AND unix_milli >= $2 GROUP BY tagKeys) WHERE distinctTagKey ILIKE $3 AND distinctTagKey NOT LIKE '\\_\\_%%' GROUP BY distinctTagKey", signozMetricDBName, signozTSTableNameV41Day, signozMetricDBName, signozTSTableNameV4Reduced)
} else {
query = fmt.Sprintf("SELECT arrayJoin(tagKeys) AS distinctTagKey FROM (SELECT JSONExtractKeys(labels) AS tagKeys FROM %s.%s WHERE metric_name=$1 AND unix_milli >= $2 GROUP BY tagKeys) WHERE distinctTagKey ILIKE $3 AND distinctTagKey NOT LIKE '\\_\\_%%' GROUP BY distinctTagKey", signozMetricDBName, signozTSTableNameV41Day)
}
if req.Limit != 0 {
query = query + fmt.Sprintf(" LIMIT %d;", req.Limit)
}
rows, err = r.db.Query(ctx, query, req.AggregateAttribute, common.PastDayRoundOff(), fmt.Sprintf("%%%s%%", req.SearchText))
if err != nil {
r.logger.Error("Error while executing query", errorsV2.Attr(err))
return nil, fmt.Errorf("error while executing query: %s", err.Error())
}
defer rows.Close()
var attributeKey string
for rows.Next() {
if err := rows.Scan(&attributeKey); err != nil {
return nil, fmt.Errorf("error while scanning rows: %s", err.Error())
}
key := v3.AttributeKey{
Key: attributeKey,
DataType: v3.AttributeKeyDataTypeString, // https://github.com/OpenObservability/OpenMetrics/blob/main/proto/openmetrics_data_model.proto#L64-L72.
Type: v3.AttributeKeyTypeTag,
IsColumn: false,
}
response.AttributeKeys = append(response.AttributeKeys, key)
}
return &response, nilView on GitHub (pinned to 5069bf80b0)
Solutions
- Inspect the %s suffix for the underlying ClickHouse error
- Verify the metrics attribute tables exist and have data within the last day (the query filters on PastDayRoundOff)
- Sanitize/limit SearchText length on the API boundary
- Retry when ClickHouse is healthy; the query is read-only
Defensive patterns
Strategy: retry
Validate before calling
// validate inputs before calling
if req.AggregateAttribute == "" || len(req.SearchText) > 100 { return empty, nil } Try / catch
if err != nil {
if strings.Contains(err.Error(), "UNKNOWN_TABLE") { return emptyKeys(), nil }
if isTransientClickhouseErr(err) { return retry(ctx) }
return nil, err
} Prevention
- Ensure metrics were ingested in the last day before querying attribute keys (past-day filter)
- Limit SearchText length; validate AggregateAttribute non-empty
When it happens
Trigger: Building a query-builder filter UI for metrics: user selects an aggregate attribute and the backend fetches available tag keys, but the time_series/attributes table is missing, unreachable, or the parameter binding fails.
Common situations: Fresh clusters with no metric data; signoz_metrics schema not created; special characters in SearchText breaking the LIKE pattern; ClickHouse overload.
Related errors
- error while executing metric name query: %s
- error while executing meter name query: %s
- error while scanning rows: %s
- CodeLicenseUnavailable
- CodeForbidden
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/baf2155ef8f0935f.
Report an issue: GitHub.