Retrieve GitLab Duo and SDLC trend data

  • Tier: Free, Premium, Ultimate
  • Add-on: GitLab Duo Pro, GitLab Duo Enterprise
  • Offering: GitLab Self-Managed

Use the GraphQL API to retrieve and export GitLab Duo and SDLC trend data.

Retrieve AI usage data

  • Add-on: GitLab Duo Enterprise

The AiUsageData endpoint provides raw event data for Code Suggestions:

  • Size
  • Language
  • User
  • Type (shown, accepted, or rejected)

You can use this endpoint to import events into a BI tool or write scripts that aggregate the data, acceptance rates, and per-user metrics for Code Suggestions events.

Data is retained for three months.

For example, to retrieve usage data for all Code Suggestions events for the gitlab-org group:

query {
  group(fullPath: "gitlab-org") {
    aiUsageData {
      codeSuggestionEvents {
        nodes {
          event
          timestamp
          language
          suggestionSize
          user {
            username
          }
        }
      }
    }
  }
}

The query returns the following output:

{
  "data": {
    "group": {
      "aiUsageData": {
        "codeSuggestionEvents": {
          "nodes": [
            {
              "event": "CODE_SUGGESTION_SHOWN_IN_IDE",
              "timestamp": "2024-12-22T18:17:25Z",
              "language": null,
              "suggestionSize": null,
              "user": {
                "username": "jasbourne"
              }
            },
            {
              "event": "CODE_SUGGESTION_REJECTED_IN_IDE",
              "timestamp": "2024-12-22T18:13:45Z",
              "language": null,
              "suggestionSize": null,
              "user": {
                "username": "jasbourne"
              }
            },
            {
              "event": "CODE_SUGGESTION_ACCEPTED_IN_IDE",
              "timestamp": "2024-12-22T18:13:44Z",
              "language": null,
              "suggestionSize": null,
              "user": {
                "username": "jasbourne"
              }
            }
          ]
        }
      }
    }
  }
}

Retrieve AI user metrics

  • Add-on: GitLab Duo Enterprise

The AiUserMetrics endpoint provides pre-aggregated per-user metrics for Code Suggestions and GitLab Duo Chat.

You can use this endpoint to list all Duo users and their usage frequency for Code Suggestions and Duo Chat.

Prerequisites:

  • You must have ClickHouse configured.

For example, to retrieve the number of accepted Code Suggestions and interactions with Duo Chat for all users in the gitlab-org group:

query {
  group(fullPath:"gitlab-org") {
    aiUserMetrics {
      nodes {
        codeSuggestionsAcceptedCount
        duoChatInteractionsCount
        user {
          username
        }
      }
    }
  }
}

The query returns the following output:

{
  "data": {
    "group": {
      "aiUserMetrics": {
        "nodes": [
          {
            "codeSuggestionsAcceptedCount": 10,
            "duoChatInteractionsCount": 22,
            "user": {
              "username": "USER_1"
            }
          },
          {
            "codeSuggestionsAcceptedCount": 12,
            "duoChatInteractionsCount": 30,
            "user": {
              "username": "USER_2"
            }
          }
        ]
      }
    }
  }
}

Retrieve GitLab Duo and SDLC trend metrics

  • Add-on: GitLab Duo Pro

The AiMetrics endpoint powers the GitLab Duo and SDLC trends dashboard and provides the following pre-aggregated metrics for Code Suggestions and Duo Chat:

  • codeSuggestionsShown
  • codeSuggestionsAccepted
  • codeSuggestionAcceptanceRate
  • codeSuggestionUsers
  • duoChatUsers

Prerequisites:

  • You must have ClickHouse configured.

For example, to retrieve Code Suggestions and Duo Chat usage data for a specified time period for the gitlab-org group:

query {
  group(fullPath: "gitlab-org") {
    aiMetrics(startDate: "2024-12-01", endDate: "2024-12-31") {
      codeSuggestions{
        shownCount
        acceptedCount
        acceptedLinesOfCode
        shownLinesOfCode
      }
      codeContributorsCount
      duoChatContributorsCount
      duoAssignedUsersCount
      duoUsedCount
    }
  }
}

The query returns the following output:

{
  "data": {
    "group": {
      "aiMetrics": {
        "codeSuggestions": {
          "shownCount": 88728,
          "acceptedCount": 7016,
          "acceptedLinesOfCode": 9334,
          "shownLinesOfCode": 124118
        },
        "codeContributorsCount": 719,
        "duoChatContributorsCount": 681,
        "duoAssignedUsersCount": 1910,
        "duoUsedCount": 714
      }
    }
  },
}

Export AI metrics data to CSV

You can export AI metrics data to a CSV file with the GitLab AI Metrics Exporter tool.