Storage: Retention & Tiered Storage
TTL (Time-To-Live) Policies
Section titled “TTL (Time-To-Live) Policies”ClickHouse TTL policies automatically expire old data. The default Aires schema sets a 30-day TTL:
When a partition exceeds the TTL, ClickHouse drops it during background merges. No manual cleanup is needed.
Customizing TTL
Section titled “Customizing TTL”Change the retention period by altering the table:
Per-Severity TTL
Section titled “Per-Severity TTL”Keep errors longer than debug logs:
This keeps:
traceanddebugevents for 7 daysinfoevents for 30 dayswarn,error, andfatalevents for 90 days
Per-Category TTL
Section titled “Per-Category TTL”Keep HTTP request logs shorter than business events:
Tiered Storage
Section titled “Tiered Storage”ClickHouse supports tiered storage policies that move data between storage volumes as it ages. This lets you keep recent data on fast NVMe drives and older data on cheaper storage.
Storage Policy Configuration
Section titled “Storage Policy Configuration”Configure storage policies in ClickHouse’s config.xml (or the config.d/ directory):
Apply Storage Policy to Table
Section titled “Apply Storage Policy to Table”Or alter an existing table:
Tier Strategy
Section titled “Tier Strategy”| Tier | Storage | Age | Use Case |
|---|---|---|---|
| Hot | NVMe SSD | 0-7 days | Real-time dashboards, alerting, active debugging |
| Warm | SATA SSD / HDD | 7-30 days | Incident investigation, trend analysis |
| Cold | S3 / GCS / MinIO | 30-365 days | Compliance, audit trails, historical analysis |
S3 Integration
Section titled “S3 Integration”AWS S3
Section titled “AWS S3”S3-Compatible (MinIO)
Section titled “S3-Compatible (MinIO)”For self-hosted S3-compatible storage:
Google Cloud Storage
Section titled “Google Cloud Storage”GCS works with ClickHouse’s S3 disk type via the S3-compatible API.
Manual Partition Management
Section titled “Manual Partition Management”List partitions
Section titled “List partitions”Move a partition to cold storage
Section titled “Move a partition to cold storage”Drop a specific day
Section titled “Drop a specific day”Detach and re-attach (for backup)
Section titled “Detach and re-attach (for backup)”Cost Estimation
Section titled “Cost Estimation”Assuming 10x compression and the following event volumes:
| Daily Volume | Raw/Day | Compressed/Day | Hot (7d) | Warm (30d) | Cold (365d) |
|---|---|---|---|---|---|
| 10M events | 5 GB | 0.5 GB | 3.5 GB | 15 GB | 183 GB |
| 100M events | 50 GB | 5 GB | 35 GB | 150 GB | 1.8 TB |
| 1B events | 500 GB | 50 GB | 350 GB | 1.5 TB | 18 TB |
With S3 at ~$0.023/GB/month, 1 year of cold storage for 100M events/day costs ~$41/month. Compare this to Datadog at $0.10/GB ingested: 50 GB/day * 30 days * $0.10 = $150/day = $4,500/month.