Skip to content

Commit

Permalink
console: docker image: run events-log-trim on cron FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Sep 20, 2024
1 parent 13c2e56 commit efffb0a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions webapps/console/pages/api/admin/events-log-trim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit efffb0a

Please sign in to comment.