> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Handling and Retention

> What the Connector, Endpoint, and Control Plane send and store, how long Formal keeps it, and how to redact or export it

## Overview

The Connector and the Endpoint run in your environment and see your traffic. The Control Plane runs in Formal's infrastructure and stores the logs they send.
This page lists what each component sends, where it is stored, how long Formal keeps it, and which settings control it.

## What Each Component Sends and Stores

| Component | Runs in | What it sends to the Control Plane | What it keeps locally |
| - | - | - | - |
| **Connector** | Your infrastructure | Activity logs for sessions and requests. Policy evaluation inputs, only if retention is on | Process logs on stdout/stderr. Undelivered logs in the `/formal/logs` spool |
| **Endpoint** | Your users' hosts | Activity logs for intercepted traffic. Policy evaluation inputs, only if retention is on | Agent logs in a per-user log directory |
| **Control Plane** | Formal's infrastructure | Not applicable | Activity logs from all sources, Control Plane audit logs, and retained policy inputs |

The Control Plane does not connect to your Resources. Only the Connector and the Endpoint handle your data. See [Architecture](https://docs.formal.ai/docs/guides/getting-started/architecture.md).

### Activity Logs

Connector and Endpoint logs record each session and request.
Depending on the technology, a log can include query text, HTTP headers and bodies, SSH commands, and LLM messages.
See [What Gets Logged](https://docs.formal.ai/docs/guides/observability/logs.md#what-gets-logged) and the [Log Schema Reference](https://docs.formal.ai/docs/guides/observability/logs.md#log-schema-reference) for every field.

Endpoint logs can also include device details and the command line of the connecting process.
See [Protect Git Tokens in Command Lines](https://docs.formal.ai/docs/guides/example-use-cases/protect-git-tokens-in-command-lines.md) for an example.

### Session Data

Completed sessions keep their query and command history.
SSH and Kubernetes sessions also keep a terminal recording.
See [Sessions](https://docs.formal.ai/docs/guides/observability/sessions.md).

### Control Plane Audit Logs

The Control Plane logs authenticated API calls from app.formal.ai, the public API, and Terraform.
Fields marked sensitive in the API schema, such as passwords, are redacted from the logged arguments.
See [Control Plane Logs](https://docs.formal.ai/docs/guides/observability/control-plane-logs.md).

### Policy Evaluation Inputs

Policy evaluation inputs are the `input` documents your policies evaluate, such as query text or response rows.
They power [policy impact reports](https://docs.formal.ai/docs/guides/policies/operations.md#3-impact-reports-backtesting).

Retention is **off by default**. With no log configuration, every stage has a retention of zero.
When retention for a stage is zero, the Connector and the Endpoint do not send that stage's inputs to the Control Plane at all.
They also drop any single input that exceeds a size limit.

### Connector Process Logs

The Connector writes its own operational logs to stdout and stderr.
They stay in your environment unless you ship them to your own log collector.
See [Connector Health](https://docs.formal.ai/docs/guides/core-concepts/connectors/health.md#logs).

When the Connector can't reach the Control Plane, it buffers activity logs in memory, then spools them to `/formal/logs`.
It retries delivery and recovers spooled logs on restart if the disk is persistent.
See [Log Spool](https://docs.formal.ai/docs/guides/core-concepts/connectors/operations.md#log-spool).

### Endpoint Agent Logs

The Endpoint agent writes `main.log` to a log directory on each host:

| OS | Log directory |
| - | - |
| macOS | `~/Library/Logs/Formal` |
| Linux | `~/.local/state/formal` |
| Windows | `%USERPROFILE%\AppData\Local\Formal\Logs` |

Agent logs include destination hostnames and the local processes that connected to them.

### Satellites

The [Data Discovery Satellite](https://docs.formal.ai/docs/guides/core-concepts/satellites.md) runs in your infrastructure.
When you configure prompt labels, it samples row values from each table and sends column metadata to the classifier.

## Debug Bundles

`formal debug` collects Endpoint diagnostics for Formal support.
It writes a zip to your current directory and does not upload it.
The file is readable only by the user who ran the command. Nothing reaches Formal unless you share the file.

The zip always contains:

* Agent memory diagnostics: heap profile, goroutine dump, memory statistics, and stack samples
* Formal processes, listed by executable name without command-line arguments
* Content filter state (macOS)
* Endpoint logs: `main.log` and, on macOS, `postinstall-once.log`

On macOS, `formal debug` first asks:

```text theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
Collect a network extension sample, content filter owners and sysdiagnose (requires sudo)
```

The default answer is no. If you answer `y`, the zip also includes a network extension sample and an Apple **sysdiagnose**.
A sysdiagnose is a full macOS system report. It can contain usernames, serial numbers, configuration profiles, running processes with their arguments, network details, and system logs.
Treat a zip that contains a sysdiagnose as confidential. Answer `N` unless Formal support asks for it.

**Verify:**

```bash theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
formal debug -o formal-debug.zip
unzip -l formal-debug.zip
# A zip without sysdiagnose has no sysdiagnose/ entries
```

## Retention

| Data | Stored in | Retention |
| - | - | - |
| Activity logs and Control Plane audit logs | Formal's log index | For as long as your account is active |
| Policy evaluation inputs | Formal's log index | Off by default. Configurable per stage, up to 30 days |
| Connector log spool | `/formal/logs` in your environment | Until the Connector delivers the logs |
| Endpoint agent logs | Each host's log directory | Managed on the host |
| Debug bundles | The machine where you ran `formal debug` | Until you delete the file |

For longer retention or your own deletion schedule, forward logs to storage you own. See [Export Logs to Your Own Storage](#export-logs-to-your-own-storage).

### Configure Policy Input Retention

Set retention for the **Session**, **Request**, and **Response** stages in [Log Configurations](https://app.formal.ai/log-configurations).
Scope a configuration to a Resource, a Connector, a Space, or the whole account. The most specific match wins.
Valid durations are `1d`, `2d`, `3d`, `7d`, `14d`, `21d`, and `30d`. Changes can take up to a day to apply.

See [Policy Evaluation Input Retention](https://docs.formal.ai/docs/guides/observability/logs.md#policy-evaluation-input-retention) for the Terraform resource.

> [!WARNING]
>
> Policy inputs contain the data your policies inspect, including any secrets
> in queries, headers, or command lines. Keep retention off for Resources that
> carry secrets. [Log schemas](https://docs.formal.ai/docs/guides/observability/log-schemas.md) do not
> apply to retained policy inputs.

**Verify:**

Open [Log Configurations](https://app.formal.ai/log-configurations).
If no configuration lists a retention for a stage, Formal does not retain that stage's inputs.

## Redact Sensitive Data

Formal has three controls for sensitive data. Each acts at a different point.

| Control | What it changes | Where it runs |
| - | - | - |
| [Log schemas](https://docs.formal.ai/docs/guides/observability/log-schemas.md) | Drops, encrypts, truncates, or strips SQL literals from log fields | In the Connector and the Endpoint, before they send the log |
| [Masking policies](https://docs.formal.ai/docs/guides/policies/enforcement.md) | Masks response data returned to the client | In the Connector, on live traffic |
| [Request rewrites](https://docs.formal.ai/docs/guides/policies/examples.md#redact-ssns-from-llm-request-messages) | Replaces sensitive text before it reaches the upstream | In the Connector or the Endpoint, on live traffic |

Log schemas run before a log leaves your environment, so dropped fields never reach the Control Plane.
`encrypt` and `encrypt_sql` use an asymmetric key you manage. See [Encryption Keys](https://docs.formal.ai/docs/guides/integrations/encryption_keys.md).

**Verify:**

After you apply a log schema, open [Logs](https://app.formal.ai/logs) and inspect a new matching log.
The selected fields are missing, truncated, or encrypted.

## Export Logs to Your Own Storage

[Log Integration](https://docs.formal.ai/docs/guides/integrations/log.md) forwards all logs to a destination you own.
Supported destinations include AWS S3, Google Cloud Storage, Google Cloud Pub/Sub, Azure Blob Storage, Datadog, Splunk, and Panther.
You then control retention and deletion in that system.

Log schemas apply before forwarding, so forwarded logs carry the same changes.

**Verify:**

Open [SIEM](https://app.formal.ai/log-integrations) and confirm your integration is listed.
Then check your destination for new log objects or events.

## Troubleshooting

> [accordion] A secret appears in a log
>
> **Cause:** The log field holds the raw query, header, body, or command line.
> **Fix:** Add a [log schema](https://docs.formal.ai/docs/guides/observability/log-schemas.md) that
> drops or encrypts that field. The schema applies to new logs only.

> [accordion] Policy impact reports show no data
>
> **Cause:** Policy input retention is off for that stage, which is the
> default. **Fix:** Set a retention in
> [Log Configurations](https://app.formal.ai/log-configurations), then wait
> up to a day for new inputs.

> [accordion] Logs are missing after a Connector restart
>
> **Cause:** The `/formal/logs` spool wasn't on a persistent volume.
> **Fix:** Mount a persistent volume at `/formal/logs`. See
> [Log Spool](https://docs.formal.ai/docs/guides/core-concepts/connectors/operations.md#log-spool).

> [accordion] A debug bundle contains system data
>
> **Cause:** The user answered `y` to the sysdiagnose prompt on macOS.
> **Fix:** Run `formal debug` again and answer `N` to get a zip with only
> Formal diagnostics and logs.

## Next Steps

> [card] [Log Schemas](https://docs.formal.ai/docs/guides/observability/log-schemas.md)
>
> Drop or encrypt sensitive log fields

> [card] [Log Integration](https://docs.formal.ai/docs/guides/integrations/log.md)
>
> Forward logs to your own storage

> [card] [Logs](https://docs.formal.ai/docs/guides/observability/logs.md)
>
> Search and configure policy input retention

> [card] [Connector Deployment](https://docs.formal.ai/docs/guides/core-concepts/connectors/deployment.md)
>
> Deploy the Connector in your infrastructure


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.