AgentSkillsCN

altinity-expert-clickhouse-logs

分析 ClickHouse 系统日志表的健康状况,包括 TTL 配置、磁盘使用率、数据新鲜度以及清理机制。可用于解决系统日志相关问题,并优化 TTL 配置。

SKILL.md
--- frontmatter
name: altinity-expert-clickhouse-logs
description: Analyze ClickHouse system log table health including TTL configuration, disk usage, freshness, and cleanup. Use for system log issues and TTL configuration.

System Log Table Health

Analyze system log table health: TTL configuration, disk usage, freshness, and cleanup.


Diagnostics

Run all queries from the file checks.sql and analyze the results.


TTL Recommendations

Log TableRecommended TTLNotes
query_log7-30 daysBalance debugging vs disk
query_thread_logDisable or 3 daysVery verbose
part_log14-30 daysImportant for RCA
trace_log3-7 daysLarge, mostly for debugging
text_log7-14 daysImportant for debugging
metric_log7-14 daysUseful for trending
asynchronous_metric_log7-14 daysLow volume
crash_log90+ daysRare, keep longer

Add TTL Example

sql
-- Example: Add 14-day TTL to query_log
-- ALTER TABLE system.query_log MODIFY TTL event_date + INTERVAL 14 DAY;

Force TTL Cleanup

sql
-- Force TTL evaluation and cleanup
-- OPTIMIZE TABLE system.query_log FINAL;
-- Or: ALTER TABLE system.query_log MATERIALIZE TTL;

Cross-Module Triggers

FindingLoad ModuleReason
Logs filling diskaltinity-expert-clickhouse-storageDisk space analysis
query_log missing dataaltinity-expert-clickhouse-overviewError summary + routing
High log volumealtinity-expert-clickhouse-ingestionBatch sizing (affects part_log)
No query_log entriesaltinity-expert-clickhouse-overviewSystem configuration

Settings Reference

SettingNotes
log_queriesEnable query_log
log_queries_min_query_duration_msMinimum duration to log
log_queries_min_typeMinimum query type to log
query_log_databaseDatabase for query_log
part_log_databaseDatabase for part_log
text_log_levelMinimum level for text_log