Skip to content
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

Add client metadata to PostgreSQL database session start event #50711

Merged

Conversation

gabrielcorado
Copy link
Contributor

@gabrielcorado gabrielcorado commented Jan 2, 2025

Related to #46810

Adds a new field to the database session start audit event to include client metadata (user agent). This is the field/flow used by other events, such as login and session recording access.

Motivation: Identify which client (user agent) was used to connect to the database in the audit. In addition, we'll also add this field to Prehog so we can track and analyze clients' usage, including the new Web UI client (teleport-repl).

New event (some fields were omitted):

{
  "cluster_name": "root.teleport.dev",
  "code": "TDB00I",
  "db_name": "postgres",
  "db_origin": "config-file",
  "db_protocol": "postgres",
  "db_service": "pg",
  "db_type": "self-hosted",
  "db_uri": "localhost:5432",
  "db_user": "postgres",
  "event": "db.session.start",
  "sid": "4eabbc56-1563-48b8-a637-92e2afbeb15d",
  "success": true,
  "user": "alice",
+ "user_agent": "teleport-repl",
  "user_kind": 1
}

changelog: Add user_agent field to db.session.start audit events.

@gabrielcorado gabrielcorado requested a review from greedy52 January 2, 2025 21:39
@github-actions github-actions bot requested a review from rosstimothy January 2, 2025 21:40
@github-actions github-actions bot added database-access Database access related issues and PRs size/sm labels Jan 2, 2025
Comment on lines 189 to 191
// Params contains parameters used during the session. This can hold, for
// example, PostgreSQL runtime parameters.
Params map[string]string
Copy link
Contributor

@rosstimothy rosstimothy Jan 6, 2025

Choose a reason for hiding this comment

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

This seems a bit generic for something that looks to only be for passing around an application name. Could we perhaps add a dedicated user agent field and punt runtime parameters to a future, more scoped PR that actually makes use of them in some meaningful way?

@gabrielcorado gabrielcorado added this pull request to the merge queue Jan 6, 2025
Merged via the queue into master with commit dbf8fcd Jan 6, 2025
44 of 45 checks passed
@gabrielcorado gabrielcorado deleted the gabrielcorado/add-client-useragent-db-start-event branch January 6, 2025 19:13
@public-teleport-github-review-bot

@gabrielcorado See the table below for backport results.

Branch Result
branch/v17 Failed

gabrielcorado added a commit that referenced this pull request Jan 6, 2025
* feat: add client metadata to database session start event

* refactor(test): update option to WithUserAgent
github-merge-queue bot pushed a commit that referenced this pull request Jan 7, 2025
… (#50806)

* feat: add client metadata to database session start event

* refactor(test): update option to WithUserAgent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v17 database-access Database access related issues and PRs size/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants