审计事件 API
- Tier: 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
History
- 将作者邮件添加到响应体的功能引入于极狐GitLab 15.9。
实例审计事件
- Tier: Premium, Ultimate
- Offering: 极狐GitLab私有化部署, 极狐GitLab Dedicated
使用此 API 来检索实例审计事件。
要使用 API 检索审计事件,您必须作为管理员进行身份验证。
检索所有实例审计事件
History
- 支持键集分页在极狐GitLab 15.11 中引入。
- 实例审计事件的实体类型 Gitlab::Audit::InstanceScope 在极狐GitLab 16.2 中引入。
plaintextGET /audit_events
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| created_after | string | no | 返回在给定时间或之后创建的审计事件。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) |
| created_before | string | no | 返回在给定时间或之前创建的审计事件。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) |
| entity_type | string | no | 返回给定实体类型的审计事件。有效值为:User,Group,Project 或 Gitlab::Audit::InstanceScope。 |
| entity_id | integer | no | 返回给定实体 ID 的审计事件。需要 entity_type 属性存在。 |
偏移分页在极狐GitLab 17.8 中被弃用,计划在 19.0 中移除。请使用[基于键集](rest/_index.md#keyset-based-pagination)的分页。此更改是一个重大更改。
此端点支持偏移分页和基于键集的分页。请求连续结果页时,应使用基于键集的分页。
阅读更多关于分页的信息。
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/audit_events"
示例响应:
json1[ 2 { 3 "id": 1, 4 "author_id": 1, 5 "entity_id": 6, 6 "entity_type": "Project", 7 "details": { 8 "custom_message": "Project archived", 9 "author_name": "Administrator", 10 "author_email": "admin@example.com", 11 "target_id": "flightjs/flight", 12 "target_type": "Project", 13 "target_details": "flightjs/flight", 14 "ip_address": "127.0.0.1", 15 "entity_path": "flightjs/flight" 16 }, 17 "created_at": "2019-08-30T07:00:41.885Z" 18 }, 19 { 20 "id": 2, 21 "author_id": 1, 22 "entity_id": 60, 23 "entity_type": "Group", 24 "details": { 25 "add": "group", 26 "author_name": "Administrator", 27 "author_email": "admin@example.com", 28 "target_id": "flightjs", 29 "target_type": "Group", 30 "target_details": "flightjs", 31 "ip_address": "127.0.0.1", 32 "entity_path": "flightjs" 33 }, 34 "created_at": "2019-08-27T18:36:44.162Z" 35 }, 36 { 37 "id": 3, 38 "author_id": 51, 39 "entity_id": 51, 40 "entity_type": "User", 41 "details": { 42 "change": "email address", 43 "from": "hello@flightjs.com", 44 "to": "maintainer@flightjs.com", 45 "author_name": "Andreas", 46 "author_email": "admin@example.com", 47 "target_id": 51, 48 "target_type": "User", 49 "target_details": "Andreas", 50 "ip_address": null, 51 "entity_path": "Andreas" 52 }, 53 "created_at": "2019-08-22T16:34:25.639Z" 54 }, 55 { 56 "id": 4, 57 "author_id": 43, 58 "entity_id": 1, 59 "entity_type": "Gitlab::Audit::InstanceScope", 60 "details": { 61 "author_name": "Administrator", 62 "author_class": "User", 63 "target_id": 32, 64 "target_type": "AuditEvents::Streaming::InstanceHeader", 65 "target_details": "unknown", 66 "custom_message": "Created custom HTTP header with key X-arg.", 67 "ip_address": "127.0.0.1", 68 "entity_path": "gitlab_instance" 69 }, 70 "ip_address": "127.0.0.1", 71 "author_name": "Administrator", 72 "entity_path": "gitlab_instance", 73 "target_details": "unknown", 74 "created_at": "2023-08-01T11:29:44.764Z", 75 "target_type": "AuditEvents::Streaming::InstanceHeader", 76 "target_id": 32, 77 "event_type": "audit_events_streaming_instance_headers_create" 78 } 79]
检索单个实例审计事件
plaintextGET /audit_events/:id
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer | yes | 审计事件的 ID |
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/audit_events/1"
示例响应:
json1{ 2 "id": 1, 3 "author_id": 1, 4 "entity_id": 6, 5 "entity_type": "Project", 6 "details": { 7 "custom_message": "Project archived", 8 "author_name": "Administrator", 9 "author_email": "admin@example.com", 10 "target_id": "flightjs/flight", 11 "target_type": "Project", 12 "target_details": "flightjs/flight", 13 "ip_address": "127.0.0.1", 14 "entity_path": "flightjs/flight" 15 }, 16 "created_at": "2019-08-30T07:00:41.885Z" 17}
群组审计事件
History
- 支持键集分页在极狐GitLab 15.2 中引入。
使用此 API 来检索群组审计事件。
具有以下角色的用户可以:
- 所有者角色可以检索所有用户的群组审计事件。
- 开发者或维护者角色仅限于基于其个人操作的群组审计事件。
偏移分页在极狐GitLab 17.8 中被弃用,计划在 19.0 中移除。请使用[基于键集](rest/_index.md#keyset-based-pagination)的分页。此更改是一个重大更改。
此端点支持偏移分页和基于键集的分页。请求连续结果页时,建议使用基于键集的分页。
检索所有群组审计事件
History
- 支持键集分页在极狐GitLab 15.2 中引入。
plaintextGET /groups/:id/audit_events
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | yes | 群组的 ID 或 URL 编码路径 |
| created_after | string | no | 返回在给定时间或之后创建的群组审计事件。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) |
| created_before | string | no | 返回在给定时间或之前创建的群组审计事件。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) |
默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的。
阅读更多关于分页的信息。
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/groups/60/audit_events"
示例响应:
json1[ 2 { 3 "id": 2, 4 "author_id": 1, 5 "entity_id": 60, 6 "entity_type": "Group", 7 "details": { 8 "custom_message": "Group marked for deletion", 9 "author_name": "Administrator", 10 "author_email": "admin@example.com", 11 "target_id": "flightjs", 12 "target_type": "Group", 13 "target_details": "flightjs", 14 "ip_address": "127.0.0.1", 15 "entity_path": "flightjs" 16 }, 17 "created_at": "2019-08-28T19:36:44.162Z" 18 }, 19 { 20 "id": 1, 21 "author_id": 1, 22 "entity_id": 60, 23 "entity_type": "Group", 24 "details": { 25 "add": "group", 26 "author_name": "Administrator", 27 "author_email": "admin@example.com", 28 "target_id": "flightjs", 29 "target_type": "Group", 30 "target_details": "flightjs", 31 "ip_address": "127.0.0.1", 32 "entity_path": "flightjs" 33 }, 34 "created_at": "2019-08-27T18:36:44.162Z" 35 } 36]
检索特定群组审计事件
仅对群组所有者和管理员可用。
plaintextGET /groups/:id/audit_events/:audit_event_id
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | yes | 群组的 ID 或 URL 编码路径 |
| audit_event_id | integer | yes | 审计事件的 ID |
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/groups/60/audit_events/2"
示例响应:
json1{ 2 "id": 2, 3 "author_id": 1, 4 "entity_id": 60, 5 "entity_type": "Group", 6 "details": { 7 "custom_message": "Group marked for deletion", 8 "author_name": "Administrator", 9 "author_email": "admin@example.com", 10 "target_id": "flightjs", 11 "target_type": "Group", 12 "target_details": "flightjs", 13 "ip_address": "127.0.0.1", 14 "entity_path": "flightjs" 15 }, 16 "created_at": "2019-08-28T19:36:44.162Z" 17}
项目审计事件
使用此 API 来检索项目审计事件。
具有维护者角色(或更高)权限的用户可以检索所有用户的项目审计事件。具有开发者角色的用户仅限于基于其个人操作的项目审计事件。
检索所有项目审计事件
History
- 支持键集分页在极狐GitLab 15.10 中引入。
plaintextGET /projects/:id/audit_events
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | yes | 项目的 ID 或 URL 编码路径 |
| created_after | string | no | 返回在给定时间或之后创建的项目审计事件。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) |
| created_before | string | no | 返回在给定时间或之前创建的项目审计事件。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) |
偏移分页在极狐GitLab 17.8 中被弃用,计划在 19.0 中移除。请使用[基于键集](rest/_index.md#keyset-based-pagination)的分页。此更改是一个重大更改。
默认情况下,GET 请求一次返回 20 个结果,因为 API 结果是分页的。请求连续结果页时,应使用基于键集的分页。
阅读更多关于分页的信息。
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/projects/7/audit_events"
示例响应:
json1[ 2 { 3 "id": 5, 4 "author_id": 1, 5 "entity_id": 7, 6 "entity_type": "Project", 7 "details": { 8 "change": "prevent merge request approval from committers", 9 "from": "", 10 "to": "true", 11 "author_name": "Administrator", 12 "author_email": "admin@example.com", 13 "target_id": 7, 14 "target_type": "Project", 15 "target_details": "twitter/typeahead-js", 16 "ip_address": "127.0.0.1", 17 "entity_path": "twitter/typeahead-js" 18 }, 19 "created_at": "2020-05-26T22:55:04.230Z" 20 }, 21 { 22 "id": 4, 23 "author_id": 1, 24 "entity_id": 7, 25 "entity_type": "Project", 26 "details": { 27 "change": "prevent merge request approval from authors", 28 "from": "false", 29 "to": "true", 30 "author_name": "Administrator", 31 "author_email": "admin@example.com", 32 "target_id": 7, 33 "target_type": "Project", 34 "target_details": "twitter/typeahead-js", 35 "ip_address": "127.0.0.1", 36 "entity_path": "twitter/typeahead-js" 37 }, 38 "created_at": "2020-05-26T22:55:04.218Z" 39 } 40]
检索特定项目审计事件
仅对具有至少项目维护者角色的用户可用。
plaintextGET /projects/:id/audit_events/:audit_event_id
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | yes | 项目的 ID 或 URL 编码路径 |
| audit_event_id | integer | yes | 审计事件的 ID |
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/projects/7/audit_events/5"
示例响应:
json1{ 2 "id": 5, 3 "author_id": 1, 4 "entity_id": 7, 5 "entity_type": "Project", 6 "details": { 7 "change": "prevent merge request approval from committers", 8 "from": "", 9 "to": "true", 10 "author_name": "Administrator", 11 "author_email": "admin@example.com", 12 "target_id": 7, 13 "target_type": "Project", 14 "target_details": "twitter/typeahead-js", 15 "ip_address": "127.0.0.1", 16 "entity_path": "twitter/typeahead-js" 17 }, 18 "created_at": "2020-05-26T22:55:04.230Z" 19}