clickhouse-log-retention plugin for Tutor
Stops ClickHouse’s own system.* log tables (trace_log, text_log, metric_log, asynchronous_metric_log, …) from filling the disk. Works for both Cairn (cairn-clickhouse) and Aspects (clickhouse).
ClickHouse records its own telemetry in the system database and never expires it. On Open edX instances this telemetry is often more than 95% of what ClickHouse stores.
What it does
Sets a TTL on every system log table (default 7 days, query_log 30 days).
Turns the query profiler off (it is what makes system.trace_log huge).
Nothing else is touched: no data database, no live table is dropped.
Installation
pip install git+https://github.com/Abstract-Tech/tutor-contrib-clickhouse-log-retention
Usage
tutor plugins enable clickhouse-log-retention
tutor config save
tutor local restart clickhouse # Aspects
tutor local restart cairn-clickhouse # Cairn
Settings (tutor config save --set NAME=value):
CLICKHOUSE_LOG_RETENTION_DAYS: days to keep the diagnostic logs (default 7).
CLICKHOUSE_LOG_RETENTION_QUERY_LOG_DAYS: days to keep system.query_log (default 30). The Aspects performance dashboards read it, so keep it longer.
A value below 1 is treated as 1.
After the first restart (important)
ClickHouse renames every existing system log table to <name>_0, <name>_1, … and creates a fresh one with the TTL. The renamed copies keep their data and their disk space until you drop them. List them:
SELECT name, formatReadableSize(total_bytes) AS size
FROM system.tables
WHERE database = 'system' AND match(name, '_log_[0-9]+$')
ORDER BY total_bytes DESC;
Each system.<name>_N listed is an old copy of ClickHouse’s own diagnostics: nothing writes to it and neither Cairn nor Aspects reads it, so DROP TABLE system.<name>_N is safe. Never drop a table without a numeric suffix.
To free space that is already used, clean up before enabling the plugin: drop old monthly partitions with ALTER TABLE system.<table> DROP PARTITION ID 'YYYYMM' (the renamed copies then stay small).
Disabling the plugin does not remove what it rendered. Delete env/local/docker-compose.override.yml and env/plugins/clickhouse-log-retention and run tutor config save again.
How it works
All the XML is in tutorclickhouse_log_retention/templates (real files, easy to read). plugin.py has the full explanation.
Aspects: the TTL goes through Aspects’ own patch clickhouse-server-config (present in every release since 0.70). The profiler setting needs its own file in the users directory Aspects mounts, because ClickHouse ignores a second <profiles> block in the same file.
Cairn: no patch exists, so two XML files are rendered and mounted by a docker-compose.override.yml in env/local (Tutor loads it for tutor local). It replaces an existing override file of that name, so do not also write that file by hand or with a deploy tool. Other plugins that need compose changes can add their services to the same file with the patch local-docker-compose-override-services (service entries, rendered under services:). Kubernetes is not covered.
Requires Tutor 14.0 or newer.
Tested with:
Cairn: Tutor 14.0 to 22 (Cairn 14 to 22), with a real tutor dev start -d cairn-clickhouse on every version, against ClickHouse 21.11, 22.1, 24.1 and 24.2.
Aspects: Tutor 16 to 22 (Aspects 0.90 to 6.0), against ClickHouse 23.8, 24.3, 24.8 and 25.8 (Aspects needs Tutor 15 or newer itself).
Hosts that are not Tutor (plain Docker Compose)
Mount the two files in manual/ into the ClickHouse container (the profiler file must be in users.d, not config.d):
volumes:
- ./data:/var/lib/clickhouse/
- ./zz-system-ttl.xml:/etc/clickhouse-server/config.d/zz-system-ttl.xml:ro
- ./zz-noprofiler.xml:/etc/clickhouse-server/users.d/zz-noprofiler.xml:ro
Recreate the container (docker compose up -d). The same renaming as above happens on the first start.
License
This software is licensed under the terms of the AGPLv3.
Metadata
Release files for tutor-contrib-clickhouse-log-retention 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tutor_contrib_clickhouse_log_retention-0.1.2.tar.gz | 18.1 kB | With provenance | Details for tutor_contrib_clickhouse_log_retention-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tutor_contrib_clickhouse_log_retention-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for tutor_contrib_clickhouse_log_retention-0.1.2-py3-none-any.whl |
Total release size: 40.6 kB
Release files / tutor_contrib_clickhouse_log_retention-0.1.2.tar.gz
| Download URL | tutor_contrib_clickhouse_log_retention-0.1.2.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
002a14ae08e57b8c01973b3d6864c29dc1d1d6c42b87f0c7a8cd0c60e111d038
|
|
BLAKE2b-256 checksum How to use checksums |
629c25cfb8916715a66516797b09e9eb670ddeb4e5e3ae4db63d8c17e8d74921
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / tutor_contrib_clickhouse_log_retention-0.1.2-py3-none-any.whl
| Download URL | tutor_contrib_clickhouse_log_retention-0.1.2-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e7886c89784b53789e7298b72f24a64499d3095a16521833970eef6a98bc26b
|
|
BLAKE2b-256 checksum How to use checksums |
46f71b1fe9b4e92730a81d3b7caa4a557ad5e11cb39f775c9c3635bd63f95c8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for tutor-contrib-clickhouse-log-retention 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tutor_contrib_clickhouse_log_retention-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.