---
title: "Configure data retention"
description: "Configure how long to retain logs and compliance reports."
product: "Calico Enterprise"
version: "3.21"
section: "Observability"
canonical_url: "https://docs.tigera.io/calico-enterprise/3.21/observability/elastic/retention"
---

# Configure data retention

## Big picture

Configure how long to retain logs and compliance reports.

## Before you begin...

Review [LogStorageSpec.Retention](https://docs.tigera.io/calico-enterprise/3.21/reference/installation/api.md#retention) and determine the appropriate values for your deployment.

## How to

### Configure data retention

Create or update the **LogStorage** resource by adding or updating the `retention` section. In the following example, auditReports, snapshots, and complianceReports are retained for 90 days, and flows are retained for 7 days.

```yaml
apiVersion: operator.tigera.io/v1
kind: LogStorage
metadata:
  name: tigera-secure
spec:
  retention:
    auditReports: 91
    snapshots: 91
    complianceReports: 91
    flows: 8
  nodes:
    count: 1
```

This configuration can be done at initial creation of the **LogStorage** resource or by updating it after it is created, like in the following example:

```text
kubectl patch logstorage tigera-secure --type merge -p '{"spec":{"retention":{"flows":8}}}'
kubectl patch logstorage tigera-secure --type merge -p '{"spec":{"retention":{"auditReports":91}}}'
kubectl patch logstorage tigera-secure --type merge -p '{"spec":{"retention":{"snapshots":91}}}'
kubectl patch logstorage tigera-secure --type merge -p '{"spec":{"retention":{"complianceReports":91}}}'
```
