Skip to content

Commit 6b17aee

Browse files
docs: add connection logs page (#18739)
This is the final PR for moving connection logs out of the audit log and into the new connection logs page. This PR documents the feature. [preview](https://coder.com/docs/@ethan%2Fdocs-add-connection-logs/admin/monitoring/connection-logs)
1 parent f42de9f commit 6b17aee

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Connection Logs
2+
3+
> [!NOTE]
4+
> Connection logs require a
5+
> [Premium license](https://coder.com/pricing#compare-plans).
6+
> For more details, [contact your account team](https://coder.com/contact).
7+
8+
The **Connection Log** page in the dashboard allows Auditors to monitor workspace agent connections.
9+
10+
## Workspace App Connections
11+
12+
The connection log contains a complete record of all workspace app connections.
13+
These originate from within the Coder deployment, and thus the connection log
14+
is a source of truth for these events.
15+
16+
## Browser Port Forwarding
17+
18+
The connection log contains a complete record of all workspace port forwarding
19+
performed via the dashboard.
20+
21+
## SSH and IDE Sessions
22+
23+
The connection log aims to capture a record of all workspace SSH and IDE sessions.
24+
These events are reported by workspace agents, and their receipt by the server
25+
is not guaranteed.
26+
27+
## How to Filter Connection Logs
28+
29+
You can filter connection logs by the following parameters:
30+
31+
- `organization` - The name or ID of the organization of the workspace being
32+
connected to.
33+
- `workspace_owner` - The username of the owner of the workspace being connected
34+
to.
35+
- `type` - The type of the connection, such as SSH, VS Code, or workspace app.
36+
For more connection types, refer to the
37+
[CoderSDK documentation](https://pkg.go.dev/github.com/coder/coder/v2/codersdk#ConnectionType).
38+
- `username`: The name of the user who initiated the connection.
39+
Results will not include SSH or IDE sessions.
40+
- `user_email`: The email of the user who initiated the connection.
41+
Results will not include SSH or IDE sessions.
42+
- `connected_after`: The time after which the connection started.
43+
Uses the RFC3339Nano format.
44+
- `connected_before`: The time before which the connection started.
45+
Uses the RFC3339Nano format.
46+
- `workspace_id`: The ID of the workspace being connected to.
47+
- `connection_id`: The ID of the connection.
48+
- `status`: The status of the connection, either `ongoing` or `completed`.
49+
Some events are neither ongoing nor completed, such as the opening of a
50+
workspace app.
51+
52+
## Capturing/Exporting Connection Logs
53+
54+
In addition to the Coder dashboard, there are multiple ways to consume or query
55+
connection events.
56+
57+
### REST API
58+
59+
You can retrieve connection logs via the Coder API.
60+
Visit the
61+
[`get-connection-logs` endpoint documentation](../../reference/api/enterprise.md#get-connection-logs)
62+
for details.
63+
64+
### Service Logs
65+
66+
Connection events are also dispatched as service logs and can be captured and
67+
categorized using any log management tool such as [Splunk](https://splunk.com).
68+
69+
Example of a [JSON formatted](../../reference/cli/server.md#--log-json)
70+
connection log entry, when an SSH connection is made:
71+
72+
```json
73+
{
74+
"ts": "2025-07-03T05:09:41.929840747Z",
75+
"level": "INFO",
76+
"msg": "connection_log",
77+
"caller": "/home/coder/coder/enterprise/audit/backends/slog.go:38",
78+
"func": "github.com/coder/coder/v2/enterprise/audit/backends.(*SlogExporter).ExportStruct",
79+
"logger_names": ["coderd"],
80+
"fields": {
81+
"request_id": "916ad077-e120-4861-8640-f449d56d2bae",
82+
"ID": "ca5dfc63-dc43-463a-bb3e-38526866fd4b",
83+
"OrganizationID": "1a2bb67e-0117-4168-92e0-58138989a7f5",
84+
"WorkspaceOwnerID": "fe8f4bab-3128-41f1-8fec-1cc0755affe5",
85+
"WorkspaceID": "05567e23-31e2-4c00-bd05-4d499d437347",
86+
"WorkspaceName": "dev",
87+
"AgentName": "main",
88+
"Type": "ssh",
89+
"Code": null,
90+
"Ip": "fd7a:115c:a1e0:4b86:9046:80e:6c70:33b7",
91+
"UserAgent": "",
92+
"UserID": null,
93+
"SlugOrPort": "",
94+
"ConnectionID": "7a6fafdc-e3d0-43cb-a1b7-1f19802d7908",
95+
"DisconnectReason": "",
96+
"Time": "2025-07-10T10:14:38.942776145Z",
97+
"ConnectionStatus": "connected"
98+
}
99+
}
100+
```
101+
102+
Example of a [human readable](../../reference/cli/server.md#--log-human)
103+
connection log entry, when `code-server` is opened:
104+
105+
```console
106+
[API] 2025-07-03 06:57:16.157 [info] coderd: connection_log request_id=de3f6004-6cc1-4880-a296-d7c6ca1abf75 ID=f0249951-d454-48f6-9504-e73340fa07b7 Time="2025-07-03T06:57:16.144719Z" OrganizationID=0665a54f-0b77-4a58-94aa-59646fa38a74 WorkspaceOwnerID=6dea5f8c-ecec-4cf0-a5bd-bc2c63af2efa WorkspaceID=3c0b37c8-e58c-4980-b9a1-2732410480a5 WorkspaceName=dev AgentName=main Type=workspace_app Code=200 Ip=127.0.0.1 UserAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36" UserID=6dea5f8c-ecec-4cf0-a5bd-bc2c63af2efa SlugOrPort=code-server ConnectionID=<nil> DisconnectReason="" ConnectionStatus=connected
107+
```
108+
109+
## How to Enable Connection Logs
110+
111+
This feature is only available with a [Premium license](../licensing/index.md).

docs/manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,12 @@
765765
"description": "Learn about Coder's automated health checks",
766766
"path": "./admin/monitoring/health-check.md"
767767
},
768+
{
769+
"title": "Connection Logs",
770+
"description": "Monitor connections to workspaces",
771+
"path": "./admin/monitoring/connection-logs.md",
772+
"state": ["premium"]
773+
},
768774
{
769775
"title": "Notifications",
770776
"description": "Configure notifications for your deployment",

0 commit comments

Comments
 (0)