Skip to main content
LangSmith Self-Hosted supports automatic TTL and data retention for traces. Use this to comply with data privacy regulations or to reduce storage by automatically cleaning up old traces. Run rules and other qualifying actions can also extend a trace’s retention period automatically.
Self-hosted Enterprise customers: You can configure extended data retention at the workspace level through the UI. No environment variable changes are required. See Customize extended retention policy. The system-wide TTL configuration on this page is still supported.

TTL configuration precedence

LangSmith determines how long to keep a trace in two steps: which retention tier the trace belongs to, and what period applies to that tier. LangSmith assigns the tier in the following order, highest precedence first:
  1. Trace upgrade: A run rule or other qualifying action promotes an individual trace to longlived, overriding whatever tier would otherwise apply.
  2. Project tier: The tier configured for the tracing project.
  3. Workspace default: New projects inherit this tier. Changing it affects new projects only unless you apply it to all existing projects.
  4. Organization default: Applies to workspaces with no default of their own.
  5. shortlived: The fallback when no default is set.
LangSmith then resolves the retention period for the assigned tier:
  • longlived: The workspace extended retention period (if set through the UI), otherwise the longlived value from the Helm configuration.
  • shortlived: The shortlived value from the Helm configuration.
The Helm chart defaults to 14 days for shortlived and 400 days for longlived.

Requirements

Configure retention through Helm or environment variable settings:
  • Enabled: Enable or disable automatic data retention. When enabled, set your default organization and project TTL tiers through the UI (see data retention guide).
  • Retention periods: Set system-wide retention periods for shortlived and longlived traces. Once set, manage retention at the project level or set an organization-wide default for new projects.
Helm

ClickHouse TTL cleanup job

As of version 0.11, a cron job runs on weekends to delete expired data that ClickHouse’s built-in TTL mechanism may not have cleaned up.
This job uses mutations (ALTER TABLE DELETE), which are expensive operations that can affect ClickHouse performance. Run them only during off-peak hours (nights and weekends). Testing with 1 concurrent active mutation (the default) did not produce significant CPU, memory, or latency increases.

Default schedule

By default, the cleanup job runs:
  • Saturday: 8pm and 10pm UTC.
  • Sunday: 12am, 2am, and 4am UTC.

Disabling the job

To disable the cleanup job entirely:

Configuring the schedule

Customize when the cleanup job runs by modifying the cron expressions:
To use a single cron schedule, set both CLICKHOUSE_TTL_CLEANUP_CRON_WEEKEND_EVENING and CLICKHOUSE_TTL_CLEANUP_CRON_WEEKEND_MORNING to the same value. Job locking prevents overlapping executions.

Configuring minimum expired rows per part

The job works through the tables one at a time. Within each table it scans the parts and deletes data from any part holding at least a minimum number of expired rows. This threshold balances efficiency and thoroughness:
  • Too low: The job scans entire parts to clear minimal data (inefficient).
  • Too high: The job skips parts with significant expired data.

Checking expired rows

Run this query to see expired rows per table part, then tune your minimum value:

Configuring maximum active mutations

Delete operations can take around 50 minutes for a 100 GB part. Increase concurrent mutations to speed up cleanup:
More concurrent DELETE operations can significantly slow inserts and reads. Increase this value only if you can tolerate slower insert and read latencies, and monitor the system after you do.

Emergency: Stopping running mutations

If you see latency spikes and need to stop a running mutation:
  1. Find active mutations:
    Find the mutation_id where the command column contains a DELETE statement.
  2. Kill the mutation:

Backups and data retention

If disk space does not decrease after the job runs, or keeps growing, backups may be the cause. Backup processes create filesystem hard links that prevent ClickHouse from releasing data. Check these directories inside your ClickHouse pod:
  • /var/lib/clickhouse/backup
  • /var/lib/clickhouse/shadow
If backups are present, copy them to external storage (for example, S3), then clear the directories. Disk space should start releasing within a few minutes.