{{< details >}}
- Tier: 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
{{< /details >}}
{{< history >}}
- 将作者邮件添加到响应体的功能引入于极狐GitLab 15.9。
{{< /history >}}
实例审计事件
{{< details >}}
- Tier: Premium, Ultimate
- Offering: 极狐GitLab私有化部署, 极狐GitLab Dedicated
{{< /details >}}
使用此 API 来检索实例审计事件。
要使用 API 检索审计事件,您必须作为管理员进行身份验证。
检索所有实例审计事件
{{< history >}}
- 支持键集分页在极狐GitLab 15.11 中引入。
- 实例审计事件的实体类型
Gitlab::Audit::InstanceScope
在极狐GitLab 16.2 中引入。
{{< /history >}}
GET /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 属性存在。 |
{{< alert type=”warning” >}}
偏移分页在极狐GitLab 17.8 中被弃用,计划在 19.0 中移除。请使用基于键集的分页。此更改是一个重大更改。
{{< /alert >}}
此端点支持偏移分页和基于键集的分页。请求连续结果页时,应使用基于键集的分页。
阅读更多关于分页的信息。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/audit_events"
示例响应:
[
{
"id": 1,
"author_id": 1,
"entity_id": 6,
"entity_type": "Project",
"details": {
"custom_message": "Project archived",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": "flightjs/flight",
"target_type": "Project",
"target_details": "flightjs/flight",
"ip_address": "127.0.0.1",
"entity_path": "flightjs/flight"
},
"created_at": "2019-08-30T07:00:41.885Z"
},
{
"id": 2,
"author_id": 1,
"entity_id": 60,
"entity_type": "Group",
"details": {
"add": "group",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": "flightjs",
"target_type": "Group",
"target_details": "flightjs",
"ip_address": "127.0.0.1",
"entity_path": "flightjs"
},
"created_at": "2019-08-27T18:36:44.162Z"
},
{
"id": 3,
"author_id": 51,
"entity_id": 51,
"entity_type": "User",
"details": {
"change": "email address",
"from": "hello@flightjs.com",
"to": "maintainer@flightjs.com",
"author_name": "Andreas",
"author_email": "admin@example.com",
"target_id": 51,
"target_type": "User",
"target_details": "Andreas",
"ip_address": null,
"entity_path": "Andreas"
},
"created_at": "2019-08-22T16:34:25.639Z"
},
{
"id": 4,
"author_id": 43,
"entity_id": 1,
"entity_type": "Gitlab::Audit::InstanceScope",
"details": {
"author_name": "Administrator",
"author_class": "User",
"target_id": 32,
"target_type": "AuditEvents::Streaming::InstanceHeader",
"target_details": "unknown",
"custom_message": "Created custom HTTP header with key X-arg.",
"ip_address": "127.0.0.1",
"entity_path": "gitlab_instance"
},
"ip_address": "127.0.0.1",
"author_name": "Administrator",
"entity_path": "gitlab_instance",
"target_details": "unknown",
"created_at": "2023-08-01T11:29:44.764Z",
"target_type": "AuditEvents::Streaming::InstanceHeader",
"target_id": 32,
"event_type": "audit_events_streaming_instance_headers_create"
}
]
检索单个实例审计事件
GET /audit_events/:id
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer | yes | 审计事件的 ID |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/audit_events/1"
示例响应:
{
"id": 1,
"author_id": 1,
"entity_id": 6,
"entity_type": "Project",
"details": {
"custom_message": "Project archived",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": "flightjs/flight",
"target_type": "Project",
"target_details": "flightjs/flight",
"ip_address": "127.0.0.1",
"entity_path": "flightjs/flight"
},
"created_at": "2019-08-30T07:00:41.885Z"
}
群组审计事件
{{< history >}}
- 支持键集分页在极狐GitLab 15.2 中引入。
{{< /history >}}
使用此 API 来检索群组审计事件。
具有以下角色的用户可以:
- 所有者角色可以检索所有用户的群组审计事件。
- 开发者或维护者角色仅限于基于其个人操作的群组审计事件。
{{< alert type=”warning” >}}
偏移分页在极狐GitLab 17.8 中被弃用,计划在 19.0 中移除。请使用基于键集的分页。此更改是一个重大更改。
{{< /alert >}}
此端点支持偏移分页和基于键集的分页。请求连续结果页时,建议使用基于键集的分页。
检索所有群组审计事件
{{< history >}}
- 支持键集分页在极狐GitLab 15.2 中引入。
{{< /history >}}
GET /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 结果是分页的。
阅读更多关于分页的信息。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/groups/60/audit_events"
示例响应:
[
{
"id": 2,
"author_id": 1,
"entity_id": 60,
"entity_type": "Group",
"details": {
"custom_message": "Group marked for deletion",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": "flightjs",
"target_type": "Group",
"target_details": "flightjs",
"ip_address": "127.0.0.1",
"entity_path": "flightjs"
},
"created_at": "2019-08-28T19:36:44.162Z"
},
{
"id": 1,
"author_id": 1,
"entity_id": 60,
"entity_type": "Group",
"details": {
"add": "group",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": "flightjs",
"target_type": "Group",
"target_details": "flightjs",
"ip_address": "127.0.0.1",
"entity_path": "flightjs"
},
"created_at": "2019-08-27T18:36:44.162Z"
}
]
检索特定群组审计事件
仅对群组所有者和管理员可用。
GET /groups/:id/audit_events/:audit_event_id
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | yes | 群组的 ID 或 URL 编码路径 |
audit_event_id |
integer | yes | 审计事件的 ID |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/groups/60/audit_events/2"
示例响应:
{
"id": 2,
"author_id": 1,
"entity_id": 60,
"entity_type": "Group",
"details": {
"custom_message": "Group marked for deletion",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": "flightjs",
"target_type": "Group",
"target_details": "flightjs",
"ip_address": "127.0.0.1",
"entity_path": "flightjs"
},
"created_at": "2019-08-28T19:36:44.162Z"
}
项目审计事件
使用此 API 来检索项目审计事件。
具有维护者角色(或更高)权限的用户可以检索所有用户的项目审计事件。具有开发者角色的用户仅限于基于其个人操作的项目审计事件。
检索所有项目审计事件
{{< history >}}
- 支持键集分页在极狐GitLab 15.10 中引入。
{{< /history >}}
GET /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 ) |
{{< alert type=”warning” >}}
偏移分页在极狐GitLab 17.8 中被弃用,计划在 19.0 中移除。请使用基于键集的分页。此更改是一个重大更改。
{{< /alert >}}
默认情况下,GET
请求一次返回 20 个结果,因为 API 结果是分页的。请求连续结果页时,应使用基于键集的分页。
阅读更多关于分页的信息。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/projects/7/audit_events"
示例响应:
[
{
"id": 5,
"author_id": 1,
"entity_id": 7,
"entity_type": "Project",
"details": {
"change": "prevent merge request approval from committers",
"from": "",
"to": "true",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": 7,
"target_type": "Project",
"target_details": "twitter/typeahead-js",
"ip_address": "127.0.0.1",
"entity_path": "twitter/typeahead-js"
},
"created_at": "2020-05-26T22:55:04.230Z"
},
{
"id": 4,
"author_id": 1,
"entity_id": 7,
"entity_type": "Project",
"details": {
"change": "prevent merge request approval from authors",
"from": "false",
"to": "true",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": 7,
"target_type": "Project",
"target_details": "twitter/typeahead-js",
"ip_address": "127.0.0.1",
"entity_path": "twitter/typeahead-js"
},
"created_at": "2020-05-26T22:55:04.218Z"
}
]
检索特定项目审计事件
仅对具有至少项目维护者角色的用户可用。
GET /projects/:id/audit_events/:audit_event_id
属性 | 类型 | 必需 | 描述 |
---|---|---|---|
id |
integer/string | yes | 项目的 ID 或 URL 编码路径 |
audit_event_id |
integer | yes | 审计事件的 ID |
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://primary.example.com/api/v4/projects/7/audit_events/5"
示例响应:
{
"id": 5,
"author_id": 1,
"entity_id": 7,
"entity_type": "Project",
"details": {
"change": "prevent merge request approval from committers",
"from": "",
"to": "true",
"author_name": "Administrator",
"author_email": "admin@example.com",
"target_id": 7,
"target_type": "Project",
"target_details": "twitter/typeahead-js",
"ip_address": "127.0.0.1",
"entity_path": "twitter/typeahead-js"
},
"created_at": "2020-05-26T22:55:04.230Z"
}