監査イベントAPI

インスタンス監査イベント

Audit Events API を使用すると、インスタンスの監査イベントを取得できます。

API を使用して監査イベントを取得するには、管理者として認証する必要があります。

すべてのインスタンス監査イベントの取得

GET /audit_events
属性 タイプ 必須 説明
created_after いいえ 指定した時刻以降に作成された監査イベントを返します。 形式:ISO 8601 YYYY-MM-DDTHH:MM:SSZ
created_before いいえ 指定した時刻以前に作成された監査イベントを返します。 形式:ISO 8601 YYYY-MM-DDTHH:MM:SSZ
entity_type いいえ 指定されたエンティティタイプの監査イベントを返します。 有効な値は、UserGroup、またはProjectです。
entity_id 整数 いいえ 指定されたエンティティ ID の監査イベントを返します。entity_type 属性が存在する必要があります。

デフォルトでは、APIの結果はページ分割されているため、GET リクエストは一度に20件の結果を返します。

ページネーションについてもっと読む

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",
      "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",
      "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",
      "target_id": 51,
      "target_type": "User",
      "target_details": "Andreas",
      "ip_address": null,
      "entity_path": "Andreas"
    },
    "created_at": "2019-08-22T16:34:25.639Z"
  }
]

インスタンス監査イベントの取得

GET /audit_events/:id
属性 タイプ 必須 説明
id 整数 はい 監査イベントの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",
    "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"
}

グループ監査イベント

GitLab 12.5で導入されました

Group Audit Events API を使用すると、グループ監査イベントを取得できます。

APIを使用してグループの監査イベントを取得するには、管理者またはグループのオーナーとして認証する必要があります。

すべてのグループ監査イベントの取得

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 --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",
      "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",
      "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 --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",
    "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"
}

プロジェクト監査イベント

GitLab 13.1で導入されました。

Project Audit Events API を使用すると、プロジェクト監査イベントを取得できます。

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

デフォルトでは、APIの結果はページ分割されているため、GET リクエストは一度に20件の結果を返します。

ページネーションについてもっと読む

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 reviewers",
        "from": "",
        "to": "true",
        "author_name": "Administrator",
        "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",
          "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 --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 reviewers",
      "from": "",
      "to": "true",
      "author_name": "Administrator",
      "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"
}