|
| 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 | +-`started_after`: The time after which the connection started. |
| 43 | + Uses the RFC3339Nano format. |
| 44 | +-`started_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":"2bd88dd5-f7a5-4e29-b5ba-543400798c8c", |
| 82 | +"ID":"b4f043e3-2010-4dd2-a1fe-a7c2c923e236", |
| 83 | +"Time":"2025-07-03T05:09:41.923468875Z", |
| 84 | +"OrganizationID":"0665a54f-0b77-4a58-94aa-59646fa38a74", |
| 85 | +"WorkspaceOwnerID":"6dea5f8c-ecec-4cf0-a5bd-bc2c63af2efa", |
| 86 | +"WorkspaceID":"3c0b37c8-e58c-4980-b9a1-2732410480a5", |
| 87 | +"WorkspaceName":"dev", |
| 88 | +"AgentName":"main", |
| 89 | +"Type":"ssh", |
| 90 | +"Code":null, |
| 91 | +"Ip":"fd7a:115c:a1e0:4afd:8ffb:2fc9:4b5:da61", |
| 92 | +"UserAgent":"", |
| 93 | +"UserID":null, |
| 94 | +"SlugOrPort":"", |
| 95 | +"ConnectionID":"dcfe943f-2afb-4e3f-8f00-3eb1718a3f8b", |
| 96 | +"CloseReason":"", |
| 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> CloseReason="" ConnectionStatus=connected |
| 107 | +``` |
| 108 | + |
| 109 | +##How to Enable Connection Logs |
| 110 | + |
| 111 | +This feature is only available with a[Premium license](../licensing/index.md). |