Bug: ClickHouse system log tables never expire: <table_ttl> in assets/clickhouse-config.xml is ignored
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- clickhouse, docker
- Domain
- databases, observability
Research direction
Start by reading assets/clickhouse-config.xml and the ClickHouse system log configuration docs linked in the issue. Check how the configured log tables express TTLs and account for processors_profile_log, which is also growing; docker-compose.yml shows how the config is mounted. Done when the configured system logs retain about seven days of data and the issue's SHOW CREATE or TTL query confirms the TTLs.
Written by the indexing model from the issue text.
Description
Component
OpenLIT
What happened?
assets/clickhouse-config.xml (added in #790) tries to keep ClickHouse's system log tables for 7 days with <table_ttl>604800</table_ttl> on query_log, trace_log, text_log, metric_log, asynchronous_metric_log, part_log and latency_log.
ClickHouse has no table_ttl setting. It ignores the key without a warning, so these tables are created with no TTL and keep growing. On an idle OpenLIT 2.2.0 stack (no traffic) we measured about 1.1 MB/h (≈27 MB/day, ≈0.8 GB/month) of system-log data that is never deleted. Most of it is system.asynchronous_metric_log, followed by processors_profile_log and query_log. OpenLIT's own tables don't grow at idle. processors_profile_log (≈0.27 MB/h) isn't in clickhouse-config.xml, so fixing the TTL key alone won't cap it. A <processors_profile_log> block with the same <ttl> (or remove="1") would.
SHOW CREATE on a stack started with this config shows no TTL clause:
system.query_log:
MergeTree PARTITION BY toYYYYMM(event_date) ORDER BY (event_date, event_time) SETTINGS index_granularity = 8192
All 7 configured tables are the same: query_log, trace_log, text_log, metric_log, asynchronous_metric_log and part_log report "no TTL". latency_log does not exist on 24.4.
ClickHouse's per-table key for this is <ttl>, which takes a TTL expression, for example <ttl>event_date + INTERVAL 7 DAY DELETE</ttl> (docs).
Steps to reproduce
-
Start ClickHouse with the shipped config, as
docker-compose.ymldoes:docker run -d --rm --name ttl-repro -e CLICKHOUSE_PASSWORD=x \ -v "$PWD/assets/clickhouse-config.xml:/etc/clickhouse-server/config.d/custom-config.xml:ro" \ clickhouse/clickhouse-server:24.4.1 -
Write a log row and list the TTLs:
docker exec ttl-repro clickhouse-client --password x -q "SYSTEM FLUSH LOGS" docker exec ttl-repro clickhouse-client --password x -q " SELECT name, if(engine_full LIKE '%TTL%', 'TTL', 'no TTL') FROM system.tables WHERE database = 'system' AND name IN ('query_log','trace_log','text_log','metric_log','asynchronous_metric_log','part_log')"Every table returns
no TTL. -
Optional: show that old rows are kept. Insert a 10-day-old and a 3-day-old row, then force a merge:
docker exec ttl-repro clickhouse-client --password x -q " INSERT INTO system.query_log (event_date, event_time, type, query) VALUES (today()-10, now()-864000, 'QueryFinish', 'age10'), (today()-3, now()-259200, 'QueryFinish', 'age3')" docker exec ttl-repro clickhouse-client --password x -q "OPTIMIZE TABLE system.query_log FINAL" docker exec ttl-repro clickhouse-client --password x -q " SELECT query, count() FROM system.query_log WHERE query IN ('age10','age3') GROUP BY query"Both rows are still there. With
<ttl>event_date + INTERVAL 7 DAY DELETE</ttl>, onlyage3remains.
Expected behavior
System log tables keep about 7 days of data, as the config's comments say, and the ClickHouse volume stops growing while OpenLIT is idle.
Environment
- OpenLIT version: 2.2.0 (
ghcr.io/openlit/openlit:2.2.0).assets/clickhouse-config.xmlonmainis identical to the 2.2.0 copy as of 2026-12-04. - ClickHouse:
clickhouse/clickhouse-server:24.4.1, the version pinned indocker-compose.yml - Deployment: the repo's
docker-compose.ymlon Linux arm64
Additional context
-
The same file is mounted by
docker-compose.yml,src/dev-docker-compose.ymlandexamples/linux/docker-compose.yaml.examples/kubernetes/clickhouse.yamluses its own inline ConfigMap and doesn't use this file. -
Existing installs: when the TTL changes, ClickHouse renames the old table to
<name>_0(for examplesystem.query_log_0) and creates a new one with the TTL. The renamed tables still have no TTL and keep their data. Users who want the space back must drop them by hand:SELECT name, formatReadableSize(total_bytes) FROM system.tables WHERE database = 'system' AND match(name, '_log_[0-9]+$'); -- then, for each one: DROP TABLE system.<name>; -
Other keys in the file that ClickHouse also ignores. These are not in the proposed fix and could be a separate change if you want one:
<level>undertrace_logandpart_log. It is valid only undertext_log.- The
<system_log>block. <log_queries_min_query_duration_ms>underquery_log. This is a user/profile setting, so it has no effect inconfig.dand queries are not filtered to slow ones. It would need ausers.dprofile file.
Pre-submission checklist
- I searched existing issues and didn't find a duplicate
Are you willing to submit PR?
Yes, I am willing to submit a PR!
- Dominant language
- TypeScript
- Stars
- 2.8k
- Forks
- 385
- Avg merge
- 7d 4h
- Merged PRs (30d)
- 74
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openlit/openlit
-
Bug: TypeScript SDK OpenAI Responses streams that end incomplete or failed lose usage and statusPossibly taken @bleedZzzz claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days
-
Bug: TypeScript SDK OpenAI spans ignore max_completion_tokensPossibly taken @bleedZzzz claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 5 days
-
Bug: TypeScript SDK OpenAI chat completion spans do not record reasoning tokensPossibly taken @bleedZzzz claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 5 days
-
Bug: TypeScript SDK Cohere wrapper ignores the SDK's camelCase request parametersPossibly taken @bleedZzzz claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 5 days
-
Bug: TypeScript SDK Mistral non-streaming spans drop camelCase toolCallsPossibly taken @bleedZzzz claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 5 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tenstorrent/ttnn-visualizer#2526 ·
Maintainers usually reply within 1 day
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
neondatabase/neon-js#301 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tashfeenahmed/freellmapi#2305 ·
Maintainers usually reply within 1 day