SigNoz/signoz · error
error while scanning rows: %s
Error message
error while scanning rows: %s
What it means
Iterating the metric attribute-key query results, rows.Scan(&attributeKey) failed because a row could not be deserialized into a single string. Indicates the result column is not a plain string for that row (Nullable, wrong column count due to schema drift, or driver type mapping change).
Source
Thrown at pkg/query-service/app/clickhouseReader/reader.go:3128
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, nil
}
func (r *ClickHouseReader) GetMeterAttributeKeys(ctx context.Context, req *v3.FilterAttributeKeyRequest) (*v3.FilterAttributeKeyResponse, error) {
ctx = ctxtypes.NewContextWithCommentVals(ctx, map[string]string{
instrumentationtypes.TelemetrySignal: telemetrytypes.SignalMetrics.StringValue(),
instrumentationtypes.CodeNamespace: "clickhouse-reader",
instrumentationtypes.CodeFunctionName: "GetMeterAttributeKeys",View on GitHub (pinned to 5069bf80b0)
Solutions
- Run the logged query manually and inspect result column types/NULLs
- Align query-service and schema versions
- Scan into sql.NullString and skip invalid rows
- Report/check driver compatibility if it began after a dependency upgrade
Example fix
// before
var attributeKey string
if err := rows.Scan(&attributeKey); err != nil { ... }
// after
var attributeKey sql.NullString
if err := rows.Scan(&attributeKey); err != nil { ... }
if !attributeKey.Valid { continue } Defensive patterns
Strategy: try-catch
Try / catch
for rows.Next() {
var key sql.NullString
if err := rows.Scan(&key); err != nil { logger.Warn(...); continue }
if !key.Valid { continue }
...
} Prevention
- Scan into sql.NullString to tolerate NULL tag keys
- Keep schema and app versions aligned; integration-test against real schema
When it happens
Trigger: The attribute-key SELECT runs but its result column type doesn't match string: e.g. Nullable(String) rows with NULLs, or a redefined view returning extra columns.
Common situations: Schema drift after partial upgrades; NULL tag keys in noisy data; clickhouse-go version changes affecting LowCardinality(String) scanning.
Related errors
- error while scanning metric name: %s
- error while scanning meter name: %s
- error while executing query: %s
- CodeLicenseUnavailable
- CodeForbidden
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/e129e989777c3197.
Report an issue: GitHub.