監査イベントAPI
- プラン: Premium、Ultimate
- 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated
インスタンス監査イベント
- プラン: Premium、Ultimate
- 提供形態: GitLab Self-Managed、GitLab Dedicated
このAPIを使用してインスタンス監査イベントを取得します。
APIを使用して監査イベントを取得するには、管理者として認証する必要があります。
すべてのインスタンス監査イベントを一覧表示
利用可能なすべてのインスタンス監査イベントを一覧表示します。各クエリで最大30日間に制限されます。
GET /audit_events| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
created_after | 文字列 | いいえ | 指定された日時以降に作成された監査イベントを返します。形式: ISO 8601(YYYY-MM-DDTHH:MM:SSZ) |
created_before | 文字列 | いいえ | 指定された日時以前に作成された監査イベントを返します。形式: ISO 8601(YYYY-MM-DDTHH:MM:SSZ) |
entity_type | 文字列 | いいえ | 指定されたエンティティタイプの監査イベントを返します。有効な値は、User、Group、Project、またはGitlab::Audit::InstanceScopeです。 |
entity_id | 整数 | いいえ | 指定されたエンティティIDの監査イベントを返します。entity_type属性が存在する必要があります。 |
オフセットベースのページネーションはGitLab 17.8で非推奨になり、19.0での削除が予定されています。代わりにキーセットページネーションを使用してください。これは破壊的な変更です。
このエンドポイントは、オフセットベースとキーセットベースのページネーションの両方をサポートしています。結果のページを連続してリクエストする場合は、キーセットページネーションを使用する必要があります。
詳細については、ページネーションを参照してください。
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "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 | 整数 | はい | 監査イベントのID |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "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"
}グループ監査イベント
このAPIを使用してグループ監査イベントを取得します。
次のユーザーの場合:
- オーナーロールを持つユーザーは、すべてのユーザーのグループ監査イベントを取得できます。
- デベロッパーまたはメンテナーロールを持つユーザーは、個人のアクションに基づいたグループ監査イベントに限定されます。
オフセットベースのページネーションはGitLab 17.8で非推奨になり、19.0での削除が予定されています。代わりにキーセットページネーションを使用してください。これは破壊的な変更です。
このエンドポイントは、オフセットベースとキーセットベースのページネーションの両方をサポートしています。連続する結果ページをリクエストする場合は、キーセットページネーションが推奨されます。
すべてのグループ監査イベントを一覧表示
指定されたグループのすべての監査イベントを一覧表示します。
GET /groups/:id/audit_events| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数または文字列 | はい | グループのIDまたはURLエンコードされたパス |
created_after | 文字列 | いいえ | 指定された日時以降に作成されたグループ監査イベントを返します。形式: ISO 8601 (YYYY-MM-DDTHH:MM:SSZ) |
created_before | 文字列 | いいえ | 指定された日時以前に作成されたグループ監査イベントを返します。形式: ISO 8601(YYYY-MM-DDTHH:MM:SSZ) |
APIの結果はページネーションされるため、デフォルトでは、GETリクエストは一度に20件の結果を返します。
詳細については、ページネーションを参照してください。
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "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 | 整数または文字列 | はい | グループのIDまたはURLエンコードされたパス |
audit_event_id | 整数 | はい | 監査イベントのID |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "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を使用してプロジェクト監査イベントを取得します。
メンテナーロール(またはそれ以上)を持つユーザーは、すべてのユーザーのプロジェクト監査イベントを取得できます。デベロッパーロールを持つユーザーは、個人のアクションに基づいたプロジェクト監査イベントに限定されます。
すべてのプロジェクト監査イベントを一覧表示
指定されたプロジェクトのすべての監査イベントを一覧表示します。
GET /projects/:id/audit_events| 属性 | 型 | 必須 | 説明 |
|---|---|---|---|
id | 整数または文字列 | はい | プロジェクトのIDまたはURLエンコードされたパス |
created_after | 文字列 | いいえ | 指定された日時以降に作成されたプロジェクト監査イベントを返します。形式: ISO 8601(YYYY-MM-DDTHH:MM:SSZ) |
created_before | 文字列 | いいえ | 指定された日時以前に作成されたプロジェクト監査イベントを返します。形式: ISO 8601(YYYY-MM-DDTHH:MM:SSZ) |
オフセットベースのページネーションはGitLab 17.8で非推奨になり、19.0での削除が予定されています。代わりにキーセットページネーションを使用してください。これは破壊的な変更です。
APIの結果はページネーションされるため、デフォルトでは、GETリクエストは一度に20件の結果を返します。連続する結果ページをリクエストする場合は、キーセットページネーションを使用する必要があります。
詳細については、ページネーションを参照してください。
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "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 | 整数または文字列 | はい | プロジェクトのIDまたはURLエンコードされたパス |
audit_event_id | 整数 | はい | 監査イベントのID |
curl --request GET \
--header "PRIVATE-TOKEN: <your_access_token>" \
--url "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"
}