Skip to content

Commit efffb0a

Browse files
committed
console: docker image: run events-log-trim on cron FIX
1 parent 13c2e56 commit efffb0a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

webapps/console/pages/api/admin/events-log-trim.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export default createRoute()
2929
log.atInfo().log(`Trimming events log`);
3030
const metricsSchema =
3131
process.env.CLICKHOUSE_METRICS_SCHEMA || process.env.CLICKHOUSE_DATABASE || "newjitsu_metrics";
32-
const clickhouseCluster = process.env.CLICKHOUSE_CLUSTER || "jitsu_cluster";
32+
const metricsCluster = process.env.CLICKHOUSE_METRICS_CLUSTER || process.env.CLICKHOUSE_CLUSTER;
33+
const onCluster = metricsCluster ? ` ON CLUSTER ${metricsCluster}` : "";
3334
const eventsLogSize = process.env.EVENTS_LOG_SIZE ? parseInt(process.env.EVENTS_LOG_SIZE) : 200000;
3435
// trim logs to eventsLogSize only after exceeding threshold
3536
const thresholdSize = Math.floor(eventsLogSize * 1.25);
@@ -49,7 +50,7 @@ export default createRoute()
4950
and
5051
timestamp
5152
< {timestamp :DateTime64};`;
52-
const dropPartitionQuery: string = `alter table ${metricsSchema}.events_log on cluster ${clickhouseCluster} drop partition {partition:String}`;
53+
const dropPartitionQuery: string = `alter table ${metricsSchema}.events_log ${onCluster} drop partition {partition:String}`;
5354
const result: any[] = [];
5455
const sw = stopwatch();
5556
let actorsResult: any = {};
@@ -149,7 +150,7 @@ export default createRoute()
149150
});
150151
log.atInfo().log(`Deleted partition ${oldPartition}`);
151152
} catch (e: any) {
152-
log.atError().withCause(e).log(`Failed to delete partition ${oldPartition}`);
153+
log.atDebug().withCause(e).log(`Failed to delete partition ${oldPartition}`);
153154
}
154155
log.atInfo().log(`Completed in ${sw.elapsedPretty()}`);
155156
if (admin) {

0 commit comments

Comments
 (0)