Skip to content

Commit f1b2715

Browse files
authored
docs: add data retention and export documentation for AI Bridge (#21055)
Previously AI Bridge retention was only documented in the auto-generated CLI reference, making it difficult for administrators to discover and understand how to configure data retention for compliance requirements. This adds retention configuration to the AI Bridge setup guide with examples, documents the REST API and CLI export options in the monitoring guide, and cross-references AI Bridge from the central data retention page for discoverability. Closes #21038
1 parent ad93262 commit f1b2715

File tree

4 files changed

+113
-4
lines changed

4 files changed

+113
-4
lines changed

docs/admin/setup/data-retention.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Data Retention
22

33
Coder supports configurable retention policies that automatically purge old
4-
Audit Logs, Connection Logs, Workspace Agent Logs, and API keys. These policies
5-
help manage database growth by removing records older than a specified duration.
4+
Audit Logs, Connection Logs, Workspace Agent Logs, API keys, and AI Bridge
5+
records. These policies help manage database growth by removing records older
6+
than a specified duration.
67

78
## Overview
89

@@ -32,6 +33,12 @@ a YAML configuration file.
3233
| Connection Logs | `--connection-logs-retention` | `CODER_CONNECTION_LOGS_RETENTION` | `0` (disabled) | How long to retain Connection Logs |
3334
| API Keys | `--api-keys-retention` | `CODER_API_KEYS_RETENTION` | `7d` | How long to retain expired API keys |
3435
| Workspace Agent Logs | `--workspace-agent-logs-retention` | `CODER_WORKSPACE_AGENT_LOGS_RETENTION` | `7d` | How long to retain workspace agent logs |
36+
| AI Bridge | `--aibridge-retention` | `CODER_AIBRIDGE_RETENTION` | `60d` | How long to retain AI Bridge records |
37+
38+
> [!NOTE]
39+
> AI Bridge retention is configured separately from other retention settings.
40+
> See [AI Bridge Setup](../../ai-coder/ai-bridge/setup.md#data-retention) for
41+
> detailed configuration options.
3542
3643
### Duration Format
3744

@@ -51,7 +58,8 @@ coder server \
5158
--audit-logs-retention=365d \
5259
--connection-logs-retention=90d \
5360
--api-keys-retention=7d \
54-
--workspace-agent-logs-retention=7d
61+
--workspace-agent-logs-retention=7d \
62+
--aibridge-retention=60d
5563
```
5664

5765
### Environment Variables Example
@@ -61,6 +69,7 @@ export CODER_AUDIT_LOGS_RETENTION=365d
6169
export CODER_CONNECTION_LOGS_RETENTION=90d
6270
export CODER_API_KEYS_RETENTION=7d
6371
export CODER_WORKSPACE_AGENT_LOGS_RETENTION=7d
72+
export CODER_AIBRIDGE_RETENTION=60d
6473
```
6574

6675
### YAML Configuration Example
@@ -71,6 +80,9 @@ retention:
7180
connection_logs: 90d
7281
api_keys: 7d
7382
workspace_agent_logs: 7d
83+
84+
aibridge:
85+
retention: 60d
7486
```
7587
7688
## How Retention Works
@@ -116,6 +128,17 @@ For non-latest builds, logs are deleted if the agent hasn't connected within the
116128
retention period. Setting `--workspace-agent-logs-retention=7d` deletes logs for
117129
agents that haven't connected in 7 days (excluding those from the latest build).
118130

131+
### AI Bridge Data Behavior
132+
133+
AI Bridge retention applies to interception records and all related data,
134+
including token usage, prompts, and tool invocations. The default of 60 days
135+
provides a reasonable balance between storage costs and the ability to analyze
136+
usage patterns.
137+
138+
For details on what data is retained, see the
139+
[AI Bridge Data Retention](../../ai-coder/ai-bridge/setup.md#data-retention)
140+
documentation.
141+
119142
## Best Practices
120143

121144
### Recommended Starting Configuration
@@ -128,6 +151,9 @@ retention:
128151
connection_logs: 90d
129152
api_keys: 7d
130153
workspace_agent_logs: 7d
154+
155+
aibridge:
156+
retention: 60d
131157
```
132158

133159
### Compliance Considerations
@@ -171,6 +197,9 @@ retention:
171197
connection_logs: 0s # Keep connection logs forever
172198
api_keys: 0s # Keep expired API keys forever
173199
workspace_agent_logs: 0s # Keep workspace agent logs forever
200+
201+
aibridge:
202+
retention: 0s # Keep AI Bridge records forever
174203
```
175204

176205
## Monitoring
@@ -185,3 +214,9 @@ containing the table name (e.g., `audit_logs`, `connection_logs`, `api_keys`).
185214
purge procedures.
186215
- [Connection Logs](../monitoring/connection-logs.md): Learn about Connection
187216
Logs and monitoring.
217+
- [AI Bridge](../../ai-coder/ai-bridge/index.md): Learn about AI Bridge for
218+
centralized LLM and MCP proxy management.
219+
- [AI Bridge Setup](../../ai-coder/ai-bridge/setup.md#data-retention): Configure
220+
AI Bridge data retention.
221+
- [AI Bridge Monitoring](../../ai-coder/ai-bridge/monitoring.md): Monitor AI
222+
Bridge usage and metrics.

docs/ai-coder/ai-bridge/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ AI Bridge is best suited for organizations facing these centralized management a
3535
- [Set up AI Bridge](./setup.md) on your Coder deployment
3636
- [Configure AI clients](./client-config.md) to use AI Bridge
3737
- [Configure MCP servers](./mcp.md) for tool access
38-
- [Monitor usage and metrics](./monitoring.md)
38+
- [Monitor usage and metrics](./monitoring.md) and [configure data retention](./setup.md#data-retention)
3939
- [Reference documentation](./reference.md)

docs/ai-coder/ai-bridge/monitoring.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,54 @@ AI Bridge records the last `user` prompt, token usage, and every tool invocation
99
We provide an example Grafana dashboard that you can import as a starting point for your metrics. See [the Grafana dashboard README](https://github.com/coder/coder/blob/main/examples/monitoring/dashboards/grafana/aibridge/README.md).
1010

1111
These logs and metrics can be used to determine usage patterns, track costs, and evaluate tooling adoption.
12+
13+
## Exporting Data
14+
15+
AI Bridge interception data can be exported for external analysis, compliance reporting, or integration with log aggregation systems.
16+
17+
### REST API
18+
19+
You can retrieve AI Bridge interceptions via the Coder API with filtering and pagination support.
20+
21+
```sh
22+
curl -X GET "https://coder.example.com/api/v2/aibridge/interceptions?q=initiator:me" \
23+
-H "Coder-Session-Token: $CODER_SESSION_TOKEN"
24+
```
25+
26+
Available query filters:
27+
28+
- `initiator` - Filter by user ID or username
29+
- `provider` - Filter by AI provider (e.g., `openai`, `anthropic`)
30+
- `model` - Filter by model name
31+
- `started_after` - Filter interceptions after a timestamp
32+
- `started_before` - Filter interceptions before a timestamp
33+
34+
See the [API documentation](../../reference/api/aibridge.md) for full details.
35+
36+
### CLI
37+
38+
Export interceptions as JSON using the CLI:
39+
40+
```sh
41+
coder aibridge interceptions list --initiator me --limit 1000
42+
```
43+
44+
You can filter by time range, provider, model, and user:
45+
46+
```sh
47+
coder aibridge interceptions list \
48+
--started-after "2025-01-01T00:00:00Z" \
49+
--started-before "2025-02-01T00:00:00Z" \
50+
--provider anthropic
51+
```
52+
53+
See `coder aibridge interceptions list --help` for all options.
54+
55+
## Data Retention
56+
57+
AI Bridge data is retained for **60 days by default**. Configure the retention
58+
period to balance storage costs with your organization's compliance and analysis
59+
needs.
60+
61+
For configuration options and details, see [Data Retention](./setup.md#data-retention)
62+
in the AI Bridge setup guide.

docs/ai-coder/ai-bridge/setup.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,26 @@ AI Bridge can relay traffic to other OpenAI- or Anthropic-compatible services or
9494

9595
> [!NOTE]
9696
> See the [Supported APIs](./reference.md#supported-apis) section below for precise endpoint coverage and interception behavior.
97+
98+
## Data Retention
99+
100+
AI Bridge records prompts, token usage, and tool invocations for auditing and
101+
monitoring purposes. By default, this data is retained for **60 days**.
102+
103+
Configure retention using `--aibridge-retention` or `CODER_AIBRIDGE_RETENTION`:
104+
105+
```sh
106+
coder server --aibridge-retention=90d
107+
```
108+
109+
Or in YAML:
110+
111+
```yaml
112+
aibridge:
113+
retention: 90d
114+
```
115+
116+
Set to `0` to retain data indefinitely.
117+
118+
For duration formats, how retention works, and best practices, see the
119+
[Data Retention](../../admin/setup/data-retention.md) documentation.

0 commit comments

Comments
 (0)