Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
ethanndickson wants to merge1 commit intoethan/reroute-connection-logs
base:ethan/reroute-connection-logs
Choose a base branch
Loading
fromethan/connection-logs-api

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedJun 27, 2025
edited
Loading

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

This PR:

  • Adds the/api/v2/connectionlogs endpoint
  • Adds filtering forGetAuthorizedConnectionLogsOffset 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>
      • Ifconnected only sessions with a nullclose_time are returned, ifdisconnected, only those with a non-nullclose_time`.

Future PRs:

  • Populatecount onConnectionLogResponse using a seperate query (to preemptively mitigate the issue described inAudit log slows to a crawl when nearing 1 million entries #17689)
  • Write a query to move N entries from the audit logs table to the connection logs table, call it from dbpurge.
  • Implement a table in the Web UI for viewing connection logs.
  • Write documentation for the endpoint / feature

@ethanndicksonGraphite App
Copy link
MemberAuthor

ethanndickson commentedJun 27, 2025
edited
Loading

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.
Learn more

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

Copy link
Contributor

@CopilotCopilotAI left a 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.

  • IntroducesConnectionLog 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
  • RenamesparsePagination 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
FileDescription
site/src/api/typesGenerated.tsGenerated TS interfaces for connection log payloads
enterprise/coderd/connectionlog.goEndpoint handler and conversion from DB rows to SDK
enterprise/coderd/connectionlog_test.goTests for/connectionlogs endpoint
enterprise/coderd/coderdenttest/coderdenttest.goAddedConnectionLogging flag to test setup
enterprise/coderd/coderd.goRegistered new route under/connectionlogs
codersdk/connectionlog.goAdded Go SDK client method and types for connection logs
coderd/searchquery/search.goParsing logic for connection log query filters
coderd/database/queries/connectionlogs.sqlSQL query with new filter clauses
coderd/database/queries.sql.goGenerated SQL constants and param mappings
coderd/database/querier_test.goAdded tests for new DB filters
coderd/database/modelqueries.goUpdated authorized query to include all filter params
coderd/database/dbmem/dbmem.goIn-memory filtering logic for connection logs
coderd/pagination.goRenamedparsePagination toParsePagination
coderd/*Updated calls fromparsePagination toParsePagination
docs/reference/api/schemas.mdAdded OpenAPI schemas for connection logs
docs/reference/api/enterprise.mdAdded 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-existentConnectionTypeWeb. 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 toConnectionTypeWeb 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 mentionsConnectionTypeWeb, 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-existentConnectionTypeWeb; 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
Copy link
MemberAuthor

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@ethanndickson

[8]ページ先頭

©2009-2025 Movatter.jp