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

chore: route connection logs to new table#18340

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 merge12 commits intomain
base:main
Choose a base branch
Loading
fromethan/reroute-connection-logs

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedJun 12, 2025
edited
Loading

This is the first PR of a few for moving connection events out of the audit log, and into a new database table and web UI page called the 'Connection Log'.

This PR:

  • Creates the new table
  • Adds and tests queries for inserting and reading, including reading with an RBAC filter.
  • Implements the corresponding RBAC changes, such that anyone who can view the audit log can read from the table
  • Implements, under the enterprise package, aConnectionLogger abstraction to replace theAuditor abstraction for these logs. (No-op'd in AGPL, like theAuditor)
  • Routes SSH connection and Workspace App events into the newConnectionLogger
  • Updates all existing tests to check the values of theConnectionLogger instead of theAuditor.

Future PRs:

  • Add filtering to the query
  • Add an enterprise endpoint to query the new table
  • Write a query to move N entries from the audit logs table to the connection logs table, call it fromdbpurge.
  • Implement a table in the Web UI for viewing connection logs.

Note

The PRs in this stack obviously won't be (completely) atomic. Whilst they'll each pass CI, the stack is designed to be merged all at once. I'm splitting them up for the sake of those reviewing, and so changes can be reviewed as early as possible. Despite this, it's really hard to make this PR any smaller than it already is. I'll be keeping it in draft until it's actually ready to merge.

@ethanndicksonGraphite App
Copy link
MemberAuthor

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

Copilot

This comment was marked as resolved.

@ethanndickson
Copy link
MemberAuthor

Requesting a draft review just to confirm we're happy with the DB schema, the RBAC setup, and the overall direction.

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice work! I think this looks great in general, but the upsert part of the logic here doesn't fully make sense to me (see related comment). Could you elaborate on the intent?

return nil
}

func NewMock() *MockConnectionLogger {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggestion: This feels more like a "fake" than a "mock".

connection_logs
LEFT JOIN users ON
connection_logs.user_id = users.id
LEFT JOIN users as workspace_owner ON
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
LEFT JOIN usersas workspace_ownerON
LEFT JOIN usersAS workspace_ownerON

-- limit of 100 to prevent accidental excessively large queries.
COALESCE(NULLIF(@limit_opt :: int, 0), 100)
OFFSET
@offset_opt;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Note: Using limit/offset will get increasingly more slow as the table grows and you paginate further. First page will usually remain fast though.

Fine for now, though. Just raising awareness.

close_reason
) VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
ON CONFLICT (connection_id, workspace_id, agent_name)
Copy link
Member

@mafredrimafredriJun 15, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Considering we have both connect and disconnect enums andtype isnot part of this conflict handling, it suggests to me there is some gap in the logic. Considering connect/disconnect both share the same connection ID, we'll never write the disconnect but upsert the connect with close time and reason.

Either writing two entries, or doing a upsert, might make sense. But I think we have to ask what are we trying to achieve here and how are we looking to display the data?

My take as a user would be that I want to see two separate entries in the log, appearing in their chronological order. When viewing the connect, it would be an additional nice bonus to be able to see when the disconnect happened, and vice-versa that could simply be achieved by applying the connection ID as search filter.

EDIT: Correction, I was referring to "connection_action" (connect/disconnect), not "connection_type". But upon closer inspection that database type is not even used so it should probably be removed if not intended to be used.

That said, I want to clarify that I'm not concerned with whether or not we write two entries or upsert one, but in the latter case I do think we should make sure to "explode" the data when queried so that we can show the events in their chronological order.

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

@mafredrimafredrimafredri left review comments

@EmyrkEmyrkEmyrk left review comments

@deansheatherdeansheatherdeansheather left review comments

Copilot code reviewCopilotCopilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@ethanndickson@mafredri@Emyrk@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp