22 Commits

Author SHA1 Message Date
695de6e0c0 chore(coderd/database): optimize AuditLogs queries (#18600)
Closes #17689

This PR optimizes the audit logs query performance by extracting the
count operation into a separate query and replacing the OR-based
workspace_builds with conditional joins.

## Query changes
* Extracted count query to separate one
* Replaced single `workspace_builds` join with OR conditions with
separate conditional joins
* Added conditional joins
* `wb_build` for workspace_build audit logs (which is a direct lookup)
    * `wb_workspace` for workspace create audit logs (via workspace)

Optimized AuditLogsOffset query:
https://explain.dalibo.com/plan/4g1hbedg4a564bg8

New CountAuditLogs query:
https://explain.dalibo.com/plan/ga2fbcecb9efbce3
2025-07-01 07:31:14 +02:00
9041646b81 chore: add "user_configs" db table (#16564) 2025-03-05 10:46:03 -07:00
b5329ae1cd feat: add workspace agent connect and app open audit types (#16493)
This commit adds new audit resource types for workspace agents and
workspace apps, as well as connect/disconnect and open/close actions.

The idea is that we will log new audit events for connecting to the
agent via SSH/editor.

Likewise, we will log openings of `coder_app`s.

This change also introduces support for filtering by `request_id`.

Updates #15139
2025-02-17 13:02:30 +00:00
a27ac30e11 chore: add sql filter to fetching audit logs (#14070)
* chore: add sql filter to fetching audit logs
* use sqlc.embed for audit logs
* fix sql query matcher
2024-08-01 12:07:19 -05:00
a8e6e89f65 feat: add organization details to audit log response (#13961)
* Allow creating test audits with nil org

Not all audit entries have organization IDs, so this will allow us to
test those cases.

* Add organization details to audit log queries

* Add organization to audit log response

This replaces the old ID.  This is a breaking change but organizations
were not being used before.
2024-07-22 13:28:44 -08:00
3cc86cf62d chore: implement sane default pagination limit for audit logs (#13676)
* chore: implement sane default pagination limit for audit logs
2024-06-28 07:38:04 -05:00
08e728bcb2 chore: implement organization scoped audit log requests (#13663)
* chore: add organization_id filter to audit logs
* chore: implement organization scoped audit log requests
2024-06-26 12:38:46 -05:00
43e45f4ab7 fix: fill out zero-value user properties in /audit (#13604) 2024-06-20 12:40:08 -08:00
74ffd2756a fix: respect uppercase letters in username filter for audit (#7880)
* fix: respect uppercase letters in username filter for audit

* updated documentation
2023-06-07 05:48:08 -07:00
b81d8464df fix: audit log query when Postgres TZ isn't UTC (#6067) 2023-02-06 21:36:39 +00:00
322a4d93e1 feat: add audit log filter for autostarted and autostopped workspace builds (#5830)
* added query

* fixed query

* added example to dropdown

* added documentation

* added test

* fixed formatting

* fixed format
2023-01-24 15:34:29 -05:00
67941b4f80 chore: refactor audit page to use window function for count (#5133)
* Move count query to window function

* Unpack count and update types

* Remove count endpoint

* Update tests, wip

* Fix tests

* Update frontend, wip

* Remove space

* Fix frontend test

* Don't hang on error

* Handle no results

* Don't omit count

* Fix frontend tests
2022-11-21 11:30:41 -05:00
65ffa20ba2 fix: use correct empty uuids (#4917) 2022-11-06 16:49:43 -06:00
a73dd4f45d Audit date filter/kira pilot (#4845)
* sql query

* added time_to

* added validation error

* documentation

* attempt to add test

* removed whiitespace

* fix: ensure date_from and date_to are applied correct audit logs

* added more tests

* ran make gen

* PR feedback

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-11-03 11:04:36 -04:00
bc47d7ce69 feat: Add extra fields to the audit filter (#4123) 2022-09-20 13:07:21 -03:00
adad347902 refactor: Refactor audit logs count to support filtering (#4113) 2022-09-19 17:08:25 +00:00
bf8d823ae3 feat: Add audit log filters in the API (#4078) 2022-09-19 10:37:33 -03:00
762063ed8f fix: add avatar_url to user object in audit log response (#3939) 2022-09-07 19:22:04 +00:00
3d6d51fbd0 feat: audit log api (#3898) 2022-09-07 16:38:19 +00:00
00da01fdf7 chore: rearrange audit logging code into enterprise folder (#3741) 2022-08-31 21:12:54 +00:00
20caee1502 feat: add audit exporting and filtering (#1314) 2022-05-09 22:05:01 +00:00
81bef1c83e feat: add audit logging database schema (#1225) 2022-05-02 19:30:46 +00:00