- Notifications
You must be signed in to change notification settings - Fork927
feat: addconnectionlogs
API#18628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:ethan/reroute-connection-logs
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ethanndickson commentedJun 27, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stackon Graphite.
This stack of pull requests is managed byGraphite. Learn more aboutstacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
Adds a new/api/v2/connectionlogs
endpoint with filtering support and related types, routes, and database queries to move connection events out of the audit log.
- Introduces
ConnectionLog
types in TS (typesGenerated.ts
) and Go SDK (codersdk/connectionlog.go
) - Implements HTTP handler, search query parsing, DB queries (SQL and in-memory), and tests
- Renames
parsePagination
toParsePagination
across codebase for consistency
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
site/src/api/typesGenerated.ts | Generated TS interfaces for connection log payloads |
enterprise/coderd/connectionlog.go | Endpoint handler and conversion from DB rows to SDK |
enterprise/coderd/connectionlog_test.go | Tests for/connectionlogs endpoint |
enterprise/coderd/coderdenttest/coderdenttest.go | AddedConnectionLogging flag to test setup |
enterprise/coderd/coderd.go | Registered new route under/connectionlogs |
codersdk/connectionlog.go | Added Go SDK client method and types for connection logs |
coderd/searchquery/search.go | Parsing logic for connection log query filters |
coderd/database/queries/connectionlogs.sql | SQL query with new filter clauses |
coderd/database/queries.sql.go | Generated SQL constants and param mappings |
coderd/database/querier_test.go | Added tests for new DB filters |
coderd/database/modelqueries.go | Updated authorized query to include all filter params |
coderd/database/dbmem/dbmem.go | In-memory filtering logic for connection logs |
coderd/pagination.go | RenamedparsePagination toParsePagination |
coderd/* | Updated calls fromparsePagination toParsePagination |
docs/reference/api/schemas.md | Added OpenAPI schemas for connection logs |
docs/reference/api/enterprise.md | Added docs for/connectionlogs endpoint |
coderd/apidoc/* | Swagger JSON and template updates |
Comments suppressed due to low confidence (4)
codersdk/connectionlog.go:32
- The comment references a non-existent
ConnectionTypeWeb
. Update it to describe the actual types (e.g., workspace_app and port_forwarding) that produce WebInfo.
// WebInfo is only set for `ConnectionTypeWeb` logs.
codersdk/connectionlog.go:35
- The comment refers to
ConnectionTypeWeb
which doesn't exist; clarify that SSHInfo applies to non-web-based connection types (all except workspace_app and port_forwarding).
// SSHInfo is only set for logs that aren't of type `ConnectionTypeWeb`.
docs/reference/api/schemas.md:1152
- The description mentions
ConnectionTypeWeb
, which is not a valid type. Replace with a clear list of types (e.g., applies when type is not workspace_app or port_forwarding).
| `ssh_info` | [codersdk.ConnectionLogSSHInfo](#codersdkconnectionlogsshinfo) | false | | Ssh info is only set for logs that aren't of type `ConnectionTypeWeb`. |
docs/reference/api/schemas.md:1155
- The description refers to a non-existent
ConnectionTypeWeb
; specify that WebInfo is included only for workspace_app and port_forwarding types.
| `web_info` | [codersdk.ConnectionLogWebInfo](#codersdkconnectionlogwebinfo) | false | | Web info is only set for `ConnectionTypeWeb` logs. |
httpapi.Write(ctx, rw, http.StatusOK, codersdk.ConnectionLogResponse{ | ||
ConnectionLogs: convertConnectionLogs(dblogs), | ||
Count: 0, // TODO(ethanndickson): Set count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is populated in the next PR in the stack.
ed8e139
to8cec6d1
Compare
Uh oh!
There was an error while loading.Please reload this page.
This is the second PR for moving connection events out of the audit log.
This PR:
/api/v2/connectionlogs
endpointGetAuthorizedConnectionLogsOffset
and thus the endpoint.There's quite a few, but I was aiming for feature parity with the audit log.
organization:<id|name>
workspace_owner:<username>
username:<username>
email:<email>
started_after:<time>
started_before:<time>
closed_after:<time>
workspace_id:<id>
connection_id:<id>
status:<connected|disconnected>
connected
only sessions with a nullclose_time
are returned, ifdisconnected, only those with a non-null
close_time`.Future PRs:
count
onConnectionLogResponse
using a seperate query (to preemptively mitigate the issue described inAudit log slows to a crawl when nearing 1 million entries #17689)