Help us learn about your current experience with the documentation. Take the survey.
审计事件模式和示例
审计事件模式
审计事件在响应体中具有可预测的模式。
| 字段 | 描述 | 备注 | 仅流式传输字段 |
|---|---|---|---|
author_id |
触发事件的用户 ID | 否 | |
author_name |
触发事件的可读作者名称 | 当作者不再存在时很有用 | 是 |
created_at |
事件触发的时间戳 | 否 | |
details |
包含额外元数据的 JSON 对象 | 没有定义的模式,但通常包含事件的额外信息 | 否 |
entity_id |
审计事件实体的 ID | 否 | |
entity_path |
可审计事件影响的实体的完整路径 | 是 | |
entity_type |
实体类型的字符串表示 | 可接受的值包括 User、Group 和 Key。此列表不完整 |
否 |
event_type |
审计事件类型的字符串表示 | 是 | |
id |
审计事件的唯一标识符 | 如需要可用于去重 | 否 |
ip_address |
用于触发事件的主机的 IP 地址 | 是 | |
target_details |
关于目标的额外详细信息 | 是 | |
target_id |
审计事件目标的 ID | 是 | |
target_type |
目标类型的字符串表示 | 是 |
审计事件 JSON 模式
{
"properties": {
"id": {
"type": "string"
},
"author_id": {
"type": "integer"
},
"author_name": {
"type": "string"
},
"details": {},
"ip_address": {
"type": "string"
},
"entity_id": {
"type": "integer"
},
"entity_path": {
"type": "string"
},
"entity_type": {
"type": "string"
},
"event_type": {
"type": "string"
},
"target_id": {
"type": "integer"
},
"target_type": {
"type": "string"
},
"target_details": {
"type": "string"
},
},
"type": "object"
}标头
标头格式如下:
POST /logs HTTP/1.1
Host: <DESTINATION_HOST>
Content-Type: application/x-www-form-urlencoded
X-Gitlab-Event-Streaming-Token: <DESTINATION_TOKEN>
X-Gitlab-Audit-Event-Type: repository_git_operation示例:Git 操作的审计事件流式传输
当认证用户推送、拉取或克隆项目的远程 Git 仓库时,可以发送流式审计事件:
- 使用 SSH。
- 使用 HTTP 或 HTTPS。
- 在 GitLab UI 中使用下载( )。
未登录用户的审计事件不会被捕获。例如,下载公共项目时。
示例:使用部署密钥的 Git over SSH 事件的审计事件负载
获取:
{
"id": "1",
"author_id": -3,
"entity_id": 29,
"entity_type": "Project",
"details": {
"author_name": "deploy-key-name",
"author_class": "DeployKey",
"target_id": 29,
"target_type": "Project",
"target_details": "example-project",
"custom_message": {
"protocol": "ssh",
"action": "git-upload-pack"
},
"ip_address": "127.0.0.1",
"entity_path": "example-group/example-project"
},
"ip_address": "127.0.0.1",
"author_name": "deploy-key-name",
"entity_path": "example-group/example-project",
"target_details": "example-project",
"created_at": "2022-07-26T05:43:53.662Z",
"target_type": "Project",
"target_id": 29,
"event_type": "repository_git_operation"
}