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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: add defualt for ttl to distributed_table (#9702)
Nityananda Gohain891c56b05975
diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.goindex 7216546eee..20821888fd 100644--- a/pkg/query-service/app/clickhouseReader/reader.go+++ b/pkg/query-service/app/clickhouseReader/reader.go@@ -1663,6 +1663,10 @@ func (r *ClickHouseReader) SetTTLV2(ctx context.Context, orgID string, params *mgetLocalTableName(r.logsDB + "." + r.logsAttributeKeys),getLocalTableName(r.logsDB + "." + r.logsResourceKeys),}+ distributedTableNames := []string{+ r.logsDB + "." + r.logsTableV2,+ r.logsDB + "." + r.logsResourceTableV2,+ }for _, tableName := range tableNames {statusItem, err := r.checkCustomRetentionTTLStatusItem(ctx, orgID, tableName)@@ -1682,11 +1686,17 @@ func (r *ClickHouseReader) SetTTLV2(ctx context.Context, orgID string, params *mqueries := []string{fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days UInt16 DEFAULT %s`,tableNames[0], r.cluster, multiIfExpr),+ // for distributed table+ fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days UInt16 DEFAULT %s`,+ distributedTableNames[0], r.cluster, multiIfExpr),}if len(params.ColdStorageVolume) > 0 && coldStorageDuration > 0 {queries = append(queries, fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days_cold UInt16 DEFAULT %d`,tableNames[0], r.cluster, coldStorageDuration))+ // for distributed table+ queries = append(queries, fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days_cold UInt16 DEFAULT %d`,+ distributedTableNames[0], r.cluster, coldStorageDuration))queries = append(queries, fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY TTL toDateTime(timestamp / 1000000000) + toIntervalDay(_retention_days) DELETE, toDateTime(timestamp / 1000000000) + toIntervalDay(_retention_days_cold) TO VOLUME '%s' SETTINGS materialize_ttl_after_modify=0`,tableNames[0], r.cluster, params.ColdStorageVolume))@@ -1697,12 +1707,17 @@ func (r *ClickHouseReader) SetTTLV2(ctx context.Context, orgID string, params *mresourceQueries := []string{fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days UInt16 DEFAULT %s`,tableNames[1], r.cluster, resourceMultiIfExpr),+ // for distributed table+ fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days UInt16 DEFAULT %s`,+ distributedTableNames[1], r.cluster, resourceMultiIfExpr),}if len(params.ColdStorageVolume) > 0 && coldStorageDuration > 0 {resourceQueries = append(resourceQueries, fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days_cold UInt16 DEFAULT %d`,tableNames[1], r.cluster, coldStorageDuration))-+ // for distributed table+ resourceQueries = append(resourceQueries, fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY COLUMN _retention_days_cold UInt16 DEFAULT %d`,+ distributedTableNames[1], r.cluster, coldStorageDuration))resourceQueries = append(resourceQueries, fmt.Sprintf(`ALTER TABLE %s ON CLUSTER %s MODIFY TTL toDateTime(seen_at_ts_bucket_start) + toIntervalSecond(1800) + toIntervalDay(_retention_days) DELETE, toDateTime(seen_at_ts_bucket_start) + toIntervalSecond(1800) + toIntervalDay(_retention_days_cold) TO VOLUME '%s' SETTINGS materialize_ttl_after_modify=0`,tableNames[1], r.cluster, params.ColdStorageVolume))}