Skip to content

Commit 47adbb4

Browse files
committed
add docs for audit logs
1 parent 185fcfa commit 47adbb4

File tree

6 files changed

+192
-4
lines changed

6 files changed

+192
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- Added audit logging. [#355](https://github.com/sourcebot-dev/sourcebot/pull/355)
12+
1013
### Fixed
1114
- Delete account join request when redeeming an invite. [#352](https://github.com/sourcebot-dev/sourcebot/pull/352)
1215
- Fix issue where a repository would not be included in a search context if the context was created before the repository. [#354](https://github.com/sourcebot-dev/sourcebot/pull/354)

docs/docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
]
7676
},
7777
"docs/configuration/transactional-emails",
78-
"docs/configuration/structured-logging"
78+
"docs/configuration/structured-logging",
79+
"docs/configuration/audit-logs"
7980
]
8081
},
8182
{
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
title: Audit Logs
3+
sidebarTitle: Audit logs
4+
---
5+
6+
import LicenseKeyRequired from '/snippets/license-key-required.mdx'
7+
8+
<LicenseKeyRequired />
9+
10+
Audit logs are a collection of notable events performed by users within a Sourcebot deployment. Each audit log records information on the action taken, the user who performed the
11+
action, and when the action took place.
12+
13+
This feature gives security and compliance teams the necessary information to ensure proper governance and administration of your Sourcebot deployment.
14+
15+
## Enabling Audit Logs
16+
Audit logs must be explicitly enabled by setting the `SOURCEBOT_EE_AUDIT_LOGGING_ENABLED` [environment variable](/docs/configuration/environment-variables) to `true`
17+
18+
## Fetching Audit Logs
19+
Audit logs are stored in the [postgres database](/docs/overview#architecture) connected to Sourcebot. To fetch all of the audit logs, you can use the following API:
20+
21+
```bash icon="terminal" Fetch audit logs
22+
curl --request GET '$SOURCEBOT_URL/api/ee/audit' \
23+
--header 'X-Org-Domain: ~' \
24+
--header 'X-Sourcebot-Api-Key: $SOURCEBOT_OWNER_API_KEY'
25+
```
26+
27+
```json icon="brackets-curly" wrap expandable Fetch audit logs example response
28+
[
29+
{
30+
"id": "cmc146k7m0003xgo2tri5t4br",
31+
"timestamp": "2025-06-17T22:48:08.914Z",
32+
"action": "api_key.created",
33+
"actorId": "cmc12tnje0000xgn58jj8655h",
34+
"actorType": "user",
35+
"targetId": "205d1da1c6c3772b81d4ad697f5851fa11195176c211055ff0c1509772645d6d",
36+
"targetType": "api_key",
37+
"sourcebotVersion": "unknown",
38+
"orgId": 1
39+
},
40+
{
41+
"id": "cmc146c8r0001xgo2xyu0p463",
42+
"timestamp": "2025-06-17T22:47:58.587Z",
43+
"action": "query.code_search",
44+
"actorId": "cmc12tnje0000xgn58jj8655h",
45+
"actorType": "user",
46+
"targetId": "1",
47+
"targetType": "org",
48+
"sourcebotVersion": "unknown",
49+
"metadata": {
50+
"message": "render branch:HEAD"
51+
},
52+
"orgId": 1
53+
},
54+
{
55+
"id": "cmc12vqgb0008xgn5nv5hl9y5",
56+
"timestamp": "2025-06-17T22:11:44.171Z",
57+
"action": "query.code_search",
58+
"actorId": "cmc12tnje0000xgn58jj8655h",
59+
"actorType": "user",
60+
"targetId": "1",
61+
"targetType": "org",
62+
"sourcebotVersion": "unknown",
63+
"metadata": {
64+
"message": "render branch:HEAD"
65+
},
66+
"orgId": 1
67+
},
68+
{
69+
"id": "cmc12txwn0006xgn51ow1odid",
70+
"timestamp": "2025-06-17T22:10:20.519Z",
71+
"action": "query.code_search",
72+
"actorId": "cmc12tnje0000xgn58jj8655h",
73+
"actorType": "user",
74+
"targetId": "1",
75+
"targetType": "org",
76+
"sourcebotVersion": "unknown",
77+
"metadata": {
78+
"message": "render branch:HEAD"
79+
},
80+
"orgId": 1
81+
},
82+
{
83+
"id": "cmc12tnjx0004xgn5qqeiv1ao",
84+
"timestamp": "2025-06-17T22:10:07.101Z",
85+
"action": "user.owner_created",
86+
"actorId": "cmc12tnje0000xgn58jj8655h",
87+
"actorType": "user",
88+
"targetId": "1",
89+
"targetType": "org",
90+
"sourcebotVersion": "unknown",
91+
"metadata": null,
92+
"orgId": 1
93+
},
94+
{
95+
"id": "cmc12tnjh0002xgn5h6vzu3rl",
96+
"timestamp": "2025-06-17T22:10:07.086Z",
97+
"action": "user.signed_in",
98+
"actorId": "cmc12tnje0000xgn58jj8655h",
99+
"actorType": "user",
100+
"targetId": "cmc12tnje0000xgn58jj8655h",
101+
"targetType": "user",
102+
"sourcebotVersion": "unknown",
103+
"metadata": null,
104+
"orgId": 1
105+
}
106+
]
107+
```
108+
109+
## Response schema
110+
111+
```json icon="brackets-curly" expandable wrap Audit log fetch response schema
112+
{
113+
"$schema": "http://json-schema.org/draft-07/schema#",
114+
"title": "FetchAuditLogsResponse",
115+
"type": "array",
116+
"items": {
117+
"type": "object",
118+
"required": [
119+
"id",
120+
"timestamp",
121+
"action",
122+
"actorId",
123+
"actorType",
124+
"targetId",
125+
"targetType",
126+
"sourcebotVersion",
127+
"metadata",
128+
"orgId"
129+
],
130+
"properties": {
131+
"id": {
132+
"type": "string"
133+
},
134+
"timestamp": {
135+
"type": "string",
136+
"format": "date-time"
137+
},
138+
"action": {
139+
"type": "string"
140+
},
141+
"actorId": {
142+
"type": "string"
143+
},
144+
"actorType": {
145+
"type": "string",
146+
"enum": ["user", "api_key"]
147+
},
148+
"targetId": {
149+
"type": "string"
150+
},
151+
"targetType": {
152+
"type": "string",
153+
"enum": ["user", "org", "file", "api_key", "account_join_request", "invite"]
154+
},
155+
"sourcebotVersion": {
156+
"type": "string"
157+
},
158+
"metadata": {
159+
"anyOf": [
160+
{
161+
"type": "object",
162+
"properties": {
163+
"message": { "type": "string" },
164+
"api_key": { "type": "string" },
165+
"emails": { "type": "string" }
166+
},
167+
"additionalProperties": false
168+
},
169+
{
170+
"type": "null"
171+
}
172+
]
173+
},
174+
"orgId": {
175+
"type": "integer"
176+
}
177+
},
178+
"additionalProperties": false
179+
}
180+
}
181+
182+
```

docs/docs/configuration/environment-variables.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The following environment variables allow you to configure your Sourcebot deploy
3939
### Enterprise Environment Variables
4040
| Variable | Default | Description |
4141
| :------- | :------ | :---------- |
42+
| `SOURCEBOT_EE_AUDIT_LOGGING_ENABLED` | `false` | <p>Enables/disables audit logging</p> |
4243
| `AUTH_EE_ENABLE_JIT_PROVISIONING` | `false` | <p>Enables/disables just-in-time user provisioning for SSO providers.</p> |
4344
| `AUTH_EE_GITHUB_BASE_URL` | `https://github.com` | <p>The base URL for GitHub Enterprise SSO authentication.</p> |
4445
| `AUTH_EE_GITHUB_CLIENT_ID` | `-` | <p>The client ID for GitHub Enterprise SSO authentication.</p> |

docs/docs/configuration/structured-logging.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
title: Structured logging
2+
title: Structured Logging
3+
sidebarTitle: Structured logging
34
---
45

56
By default, Sourcebot will output logs to the console in a human readable format. If you'd like Sourcebot to output structured JSON logs, set the following env vars:

docs/docs/deployment-guide.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Watch this 1:51 minute video to get a quick overview of how to deploy Sourcebot
3333
<Step title="Create a config.json">
3434
Create a `config.json` file that tells Sourcebot which repositories to sync and index:
3535

36-
```bash
36+
```bash wrap icon="terminal" Create example config
3737
touch config.json
3838
echo '{
3939
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
@@ -58,7 +58,7 @@ Watch this 1:51 minute video to get a quick overview of how to deploy Sourcebot
5858

5959
In the same directory as `config.json`, run the following command to start your instance:
6060

61-
``` bash
61+
``` bash icon="terminal" Start the Sourcebot container
6262
docker run \
6363
-p 3000:3000 \
6464
--pull=always \

0 commit comments

Comments
 (0)