Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: use correct column name for v4 tables (#5177)

Srikanth Chekuri8a9c8031f578
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go
index c4a3de87eb..c2924a6a32 100644
--- a/pkg/query-service/app/clickhouseReader/reader.go
+++ b/pkg/query-service/app/clickhouseReader/reader.go
@@ -2378,13 +2378,18 @@ func (r *ClickHouseReader) SetTTL(ctx context.Context,
zap.L().Error("Error in inserting to ttl_status table", zap.Error(dbErr))
return
}
+ timeColumn := "timestamp_ms"
+ if strings.Contains(tableName, "v4") {
+ timeColumn = "unix_milli"
+ }
+
req := fmt.Sprintf(
- "ALTER TABLE %v ON CLUSTER %s MODIFY TTL toDateTime(toUInt32(timestamp_ms / 1000), 'UTC') + "+
- "INTERVAL %v SECOND DELETE", tableName, r.cluster, params.DelDuration)
+ "ALTER TABLE %v ON CLUSTER %s MODIFY TTL toDateTime(toUInt32(%s / 1000), 'UTC') + "+
+ "INTERVAL %v SECOND DELETE", tableName, r.cluster, timeColumn, params.DelDuration)
if len(params.ColdStorageVolume) > 0 {
- req += fmt.Sprintf(", toDateTime(toUInt32(timestamp_ms / 1000), 'UTC')"+
+ req += fmt.Sprintf(", toDateTime(toUInt32(%s / 1000), 'UTC')"+
" + INTERVAL %v SECOND TO VOLUME '%s'",
- params.ToColdStorageDuration, params.ColdStorageVolume)
+ timeColumn, params.ToColdStorageDuration, params.ColdStorageVolume)
}
err := r.setColdStorage(context.Background(), tableName, params.ColdStorageVolume)
if err != nil {