Skip to content

feat: add connectionlogs 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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: ethan/reroute-connection-logs
Choose a base branch
from

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Jun 27, 2025

This is the second PR for moving connection events out of the audit log.

This PR:

  • Adds the /api/v2/connectionlogs 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. username:<username>
      • Only includes web-based connection events (workspace apps, web port forwarding) as only those include user metadata.
    4. email:<email>
    5. started_after:<time>
    6. started_before:<time>
    7. closed_after:<time>
    8. workspace_id:<id>
    9. 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.
    10. 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 Audit log slows to a crawl when nearing 1 million entries #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)

Copy link
Member Author

ethanndickson commented Jun 27, 2025

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 stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copilot

This comment was marked as outdated.


httpapi.Write(ctx, rw, http.StatusOK, codersdk.ConnectionLogResponse{
ConnectionLogs: convertConnectionLogs(dblogs),
Count: 0, // TODO(ethanndickson): Set count
Copy link
Member Author

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.

@ethanndickson ethanndickson force-pushed the ethan/connection-logs-api branch 2 times, most recently from 8cec6d1 to 482a5d3 Compare June 30, 2025 04:28
@ethanndickson ethanndickson force-pushed the ethan/reroute-connection-logs branch from e4e1a04 to 1fcd8d7 Compare June 30, 2025 12:03
@ethanndickson ethanndickson force-pushed the ethan/connection-logs-api branch from 482a5d3 to ccc7539 Compare June 30, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant