Skip to content

Commit 7a339a1

Browse files
feat: add connectionlogs API (#18628)
This is the second PR for moving connection events out of the audit log. This PR: - Adds the `/api/v2/connectionlog` endpoint - Adds filtering for `GetAuthorizedConnectionLogsOffset` and thus the endpoint. There's quite a few, but I was aiming for feature parity with the audit log. 1. `organization:<id|name>` 2. `workspace_owner:<username>` 3. `workspace_owner_email:<email>` 4. `type:<ssh|vscode|jetbrains|reconnecting_pty|workspace_app|port_forwarding>` 5. `username:<username>` - Only includes web-based connection events (workspace apps, web port forwarding) as only those include user metadata. 6. `user_email:<email>` 7. `connected_after:<time>` 8. `connected_before:<time>` 9. `workspace_id:<id>` 10. `connection_id:<id>` - If you have one snapshot of the connection log, and some sessions are ongoing in that snapshot, you could use this filter to check if they've been closed since. 11. `status:<connected|disconnected>` - If `connected` only sessions with a null `close_time` are returned, if `disconnected`, only those with a non-null `close_time`. If filter is omitted, both are returned. Future PRs: - Populate `count` on `ConnectionLogResponse` using a seperate query (to preemptively mitigate the issue described in #17689) - Implement a table in the Web UI for viewing connection logs. - Write a query to delete old events from the audit log, call it from dbpurge. - Write documentation for the endpoint / feature (including these filters)
1 parent 08e17a0 commit 7a339a1

25 files changed

+1863
-30
lines changed

coderd/apidoc/docs.go

Lines changed: 179 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 175 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/audit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (api *API) auditLogs(rw http.ResponseWriter, r *http.Request) {
4040
ctx := r.Context()
4141
apiKey := httpmw.APIKey(r)
4242

43-
page, ok := parsePagination(rw, r)
43+
page, ok := ParsePagination(rw, r)
4444
if !ok {
4545
return
4646
}

0 commit comments

Comments
 (0)