Skip to content

Commit

Permalink
update audit log examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Dec 16, 2024
1 parent 435c006 commit 3a729ed
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,44 @@ sqlite3 ./relay.sqlite
```

```sql
select * from audit_logs order by created_at desc limit 25;
select * from audit_logs joins event_types on event_types.id = event_type_id where event_types.name = 'license.leased' order by created_at desc limit 5;
-- recent events
SELECT
*
FROM
audit_logs
ORDER BY
created_at DESC
LIMIT
25;

-- recently leased licenses
SELECT
audit_logs.*
FROM
audit_logs
JOIN
event_types ON event_types.id = audit_logs.event_type_id
WHERE
event_types.name = 'license.leased'
ORDER BY
created_at DESC
LIMIT
5;

-- entire history in chronological order
SELECT
datetime(audit_logs.created_at, 'unixepoch') AS created_at,
event_types.name AS event_type,
entity_types.name AS entity_type,
audit_logs.entity_id
FROM
audit_logs
JOIN
event_types ON event_types.id = audit_logs.event_type_id
JOIN
entity_types ON entity_types.id = audit_logs.entity_type_id
ORDER BY
audit_logs.created_at ASC;
```

If you have concerns about storage, or do not wish to keep audit logs, use
Expand Down

0 comments on commit 3a729ed

Please sign in to comment.