From efffb0a0e95abb53b4cefb85ec5901b9bd02792d Mon Sep 17 00:00:00 2001 From: Ildar Nurislamov Date: Fri, 20 Sep 2024 21:35:21 +0400 Subject: [PATCH] console: docker image: run events-log-trim on cron FIX --- webapps/console/pages/api/admin/events-log-trim.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webapps/console/pages/api/admin/events-log-trim.ts b/webapps/console/pages/api/admin/events-log-trim.ts index 50f68df77..aed0938e8 100644 --- a/webapps/console/pages/api/admin/events-log-trim.ts +++ b/webapps/console/pages/api/admin/events-log-trim.ts @@ -29,7 +29,8 @@ export default createRoute() log.atInfo().log(`Trimming events log`); const metricsSchema = process.env.CLICKHOUSE_METRICS_SCHEMA || process.env.CLICKHOUSE_DATABASE || "newjitsu_metrics"; - const clickhouseCluster = process.env.CLICKHOUSE_CLUSTER || "jitsu_cluster"; + const metricsCluster = process.env.CLICKHOUSE_METRICS_CLUSTER || process.env.CLICKHOUSE_CLUSTER; + const onCluster = metricsCluster ? ` ON CLUSTER ${metricsCluster}` : ""; const eventsLogSize = process.env.EVENTS_LOG_SIZE ? parseInt(process.env.EVENTS_LOG_SIZE) : 200000; // trim logs to eventsLogSize only after exceeding threshold const thresholdSize = Math.floor(eventsLogSize * 1.25); @@ -49,7 +50,7 @@ export default createRoute() and timestamp < {timestamp :DateTime64};`; - const dropPartitionQuery: string = `alter table ${metricsSchema}.events_log on cluster ${clickhouseCluster} drop partition {partition:String}`; + const dropPartitionQuery: string = `alter table ${metricsSchema}.events_log ${onCluster} drop partition {partition:String}`; const result: any[] = []; const sw = stopwatch(); let actorsResult: any = {}; @@ -149,7 +150,7 @@ export default createRoute() }); log.atInfo().log(`Deleted partition ${oldPartition}`); } catch (e: any) { - log.atError().withCause(e).log(`Failed to delete partition ${oldPartition}`); + log.atDebug().withCause(e).log(`Failed to delete partition ${oldPartition}`); } log.atInfo().log(`Completed in ${sw.elapsedPretty()}`); if (admin) {