Back to Gitlabhq

Audit event schema and examples

doc/user/compliance/audit_event_schema.md

18.11.25.3 KB
Original Source

Audit event schema

{{< history >}}

  • Documentation for an audit event streaming schema was introduced in GitLab 15.3.

{{< /history >}}

Audit events have a predictable schema in the body of the response.

FieldDescriptionNotesStreaming Only Field
author_idUser ID of the user who triggered the event{{< no >}}
author_nameHuman-readable name of the author that triggered the eventHelpful when the author no longer exists{{< yes >}}
created_atTimestamp when event was triggered{{< no >}}
detailsJSON object containing additional metadataHas no defined schema but often contains additional information about an event{{< no >}}
entity_idID of the audit event's entity{{< no >}}
entity_pathFull path of the entity affected by the auditable event{{< yes >}}
entity_typeString representation of the type of entityAcceptable values include User, Group, and Key. This list is not exhaustive{{< no >}}
event_typeString representation of the type of audit event{{< yes >}}
idUnique identifier for the audit eventCan be used for deduplication if required{{< no >}}
ip_addressIP address of the host used to trigger the event{{< yes >}}
target_detailsAdditional details about the target{{< yes >}}
target_idID of the audit event's target{{< yes >}}
target_typeString representation of the target's type{{< yes >}}

Audit event JSON schema

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

Headers

{{< history >}}

  • X-Gitlab-Audit-Event-Type introduced in GitLab 15.0.

{{< /history >}}

Headers are formatted as follows:

plaintext
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

Example: audit event streaming on Git operations

Streaming audit events can be sent when authenticated users push, pull, or clone a project's remote Git repositories:

  • Using SSH.
  • Using HTTP or HTTPS.
  • Using Download ({{< icon name="download" >}}) in GitLab UI.

Audit events are not captured for users that are not signed in. For example, when downloading a public project.

Example: audit event payloads for Git over SSH events with deploy key

Fetch:

json
{
  "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"
}