Skip to main content

Disk use and ClickHouse log retention

MonoPbx keeps call records and call quality data in ClickHouse. ClickHouse also writes diagnostic tables of its own (the system database: query log, text log, metric log and similar). Left alone these grow without limit and can use many gigabytes, far more than your real data, until the disk is full.

What MonoPbx does​

New installs and upgraded servers keep these tables small:

  • The profiler trace table (trace_log) is switched off. Nothing in MonoPbx reads it.
  • The text log records warnings and errors only.
  • Every other system log table keeps 7 days of history and then deletes older rows.

The settings are a ClickHouse configuration file, clickhouse/config.d/system-logs.xml, shipped with the install bundle (Docker Compose) and with the Kubernetes and Helm manifests. Your call records and other business data are never touched.

Upgrading a server that already has large logs​

ClickHouse applies a retention only to tables it creates itself, so an upgraded server still has its old, large tables. mpbx-ctl upgrade handles this before it checks the free disk space for the pre-upgrade snapshot:

  • A system log table over 256 MiB, and the old copies ClickHouse leaves behind after a schema change, are dropped. ClickHouse creates the table again with the new retention.
  • Smaller tables without a retention get the 7 day retention.

Each action is printed as a mpbx-ctl: ClickHouse system.<table> ... line. The data is diagnostic only, so nothing of value is lost.

If mpbx-ctl preflight reports too little disk space and ClickHouse system logs hold more than 1 GiB, the message says so. Running the upgrade clears them.

Changing the retention​

Edit the <ttl> lines in clickhouse/config.d/system-logs.xml and restart ClickHouse. A new retention applies to tables created after the change; for an existing table run ALTER TABLE system.<table> MODIFY TTL event_date + INTERVAL <n> DAY DELETE.