# Data Retention

> Delete Observations once they're older than a Time To Live, with rules for each kind of DataItem.

URL: https://www.trakhound.com/docs/mtconnect-server/data-retention

By default, Observations are kept indefinitely. A Tables Profile's **Retention** rules delete Observations from the Profile's destinations once they're older than a **TTL** (Time To Live), so a database doesn't keep growing.

## Add a Rule

1. Open a Tables Profile (**Collection > Configuration > Profiles**) and go to its **Retention** tab.
2. Click **Add Rule**.
3. Set **Keep Observations For (TTL)** in Minutes, Hours, or Days (default 30 days), and optionally a **Description**.
4. Optionally select the DataItems the rule applies to, with Allow and Deny patterns, the same as a [Filter](https://www.trakhound.com/docs/mtconnect-server/filters). A rule without Allow patterns matches all DataItems.
5. Click **Save Changes**.

## How Rules Apply

- The **first matching rule** applies to each DataItem, so put specific rules before general ones.
- DataItems without a matching rule are kept.
- A rule can be disabled without removing it.

For example, to keep alarms for a year and everything else for 30 days:

| Order | TTL | Allow |
| --- | --- | --- |
| 1 | 365 Days | `category=CONDITION` |
| 2 | 30 Days | (all DataItems) |

## How Retention Runs

Retention runs in the background and deletes in batches, catching up on large backlogs over time. Its progress is shown under **Collection > Statistics > Retention**: for each rule and Device, the Observations deleted (in total and in the last run), the TTL, when it last ran, whether it's catching up, and any errors (see [Monitoring Collection](https://www.trakhound.com/docs/mtconnect-server/monitoring)).

> Retention only deletes historical Observations. The current value of each DataItem, the Device models, and the Assets are kept.
