SigNoz/signoz · error · model.InternalError
couldn't query clickhouse for received metrics status: %w
Error message
couldn't query clickhouse for received metrics status: %w
What it means
Internal error wrapping a ClickHouse query failure while fetching the latest-received status of a metric (last received timestamp and labels) from the time_series table. The %w wrapping preserves the underlying ClickHouse error for diagnosis.
Source
Thrown at pkg/query-service/app/clickhouseReader/reader.go:3404
group by metric_name
limit 1
`, signozMetricDBName, signozTSTableNameV4, whereClause,
signozMetricDBName, signozTSTableNameV4Reduced, whereClause,
)
} else {
query = fmt.Sprintf(`
SELECT metric_name, anyLast(labels), max(unix_milli)
from %s.%s
where %s
group by metric_name
limit 1
`, signozMetricDBName, signozTSTableNameV4, whereClause,
)
}
rows, err := r.db.Query(ctx, query)
if err != nil {
return nil, model.InternalError(fmt.Errorf(
"couldn't query clickhouse for received metrics status: %w", err,
))
}
defer rows.Close()
var result *model.MetricStatus
if rows.Next() {
result = &model.MetricStatus{}
var labelsJson string
err := rows.Scan(
&result.MetricName,
&labelsJson,
&result.LastReceivedTsMillis,
)
if err != nil {View on GitHub (pinned to 5069bf80b0)
Solutions
- Read the wrapped ClickHouse error to classify cause
- Test the same query manually in clickhouse-client with the quoted metric names
- Verify signoz_metrics.time_series exists and query-service version matches schema
- Check ClickHouse health and query-service connection pool metrics
Defensive patterns
Strategy: retry
Validate before calling
// Verify table exists before heavy calls
if !chTableExists(ctx, db, "signoz_metrics", "time_series") {
return errors.New("time_series table missing; run migrations")
} Try / catch
if err != nil {
var ich *chError
if errors.As(err, &ich) && ich.Transient() { retry(ctx, call) }
} Prevention
- Quote metric names with ClickHouseFormattedValue
- Health-check ClickHouse before batch operations
When it happens
Trigger: GetLatestReceivedMetric successfully validated names but the status query failed — bad quoted metric name interpolation, missing time_series table, timeout, or connection failure.
Common situations: Metric names with special characters breaking utils.ClickHouseFormattedValue quoting; ClickHouse unavailable; schema migration pending after SigNoz upgrade.
Related errors
- error while querying histogram buckets: %s
- CodeLicenseUnavailable
- CodeForbidden
- CodeNotFound
- ErrCodeInvalidState
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/49b4e0bb7b9dc6ec.
Report an issue: GitHub.