Retrieve GitLab Duo and SDLC trend data
- Tier: Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
Use the GraphQL API to retrieve and export GitLab Duo data.
Retrieve AI usage data
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
The AiUsageData endpoint provides raw event data. It exposes Code Suggestions-specific events through codeSuggestionEvents and all raw event data through all.
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 all GitLab Duo events.
Data is retained for three months for customers without ClickHouse installed. For customers with ClickHouse configured, there is currently no data retention policy.
The all attribute is filterable by startDate, endDate, events, userIds, and standard pagination values.
To see which events are being tracked, you can examine the events declared in the ai_tracking.rb file.
For projects and groups
For example, to retrieve usage data for all Code Suggestions events for the gitlab-org group:
query {
group(fullPath: "gitlab-org") {
aiUsageData {
codeSuggestionEvents(startDate: "2025-09-26") {
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": "2025-09-26T18:17:25Z",
"language": "python",
"suggestionSize": 2,
"user": {
"username": "jasbourne"
}
},
{
"event": "CODE_SUGGESTION_REJECTED_IN_IDE",
"timestamp": "2025-09-26T18:13:45Z",
"language": "python",
"suggestionSize": 2,
"user": {
"username": "jasbourne"
}
},
{
"event": "CODE_SUGGESTION_ACCEPTED_IN_IDE",
"timestamp": "2025-09-26T18:13:44Z",
"language": "python",
"suggestionSize": 2,
"user": {
"username": "jasbourne"
}
}
]
}
}
}
}
}Alternatively, to retrieve usage data for all GitLab Duo events for the gitlab-org group:
query {
group(fullPath: "gitlab-org") {
aiUsageData {
all(startDate: "2025-09-26") {
nodes {
event
timestamp
user {
username
}
}
}
}
}
}The query returns the following output:
{
"data": {
"group": {
"aiUsageData": {
"all": {
"nodes": [
{
"event": "FIND_NO_ISSUES_DUO_CODE_REVIEW_AFTER_REVIEW",
"timestamp": "2025-09-26T18:17:25Z",
"user": {
"username": "jasbourne"
}
},
{
"event": "REQUEST_REVIEW_DUO_CODE_REVIEW_ON_MR_BY_AUTHOR",
"timestamp": "2025-09-26T18:13:45Z",
"user": {
"username": "jasbourne"
}
},
{
"event": "AGENT_PLATFORM_SESSION_STARTED",
"timestamp": "2025-09-26T18:13:44Z",
"user": {
"username": "jasbourne"
}
}
]
}
}
}
}
}For instances
- Offering: GitLab Self-Managed, GitLab Dedicated
Prerequisites:
- You must be an administrator for the instance.
For example, to retrieve all GitLab Duo usage events for the entire instance:
query {
aiUsageData {
all(startDate: "2025-09-26", endDate: "2025-09-30") {
nodes {
event
timestamp
user {
username
}
extras
}
}
}
}The query returns the following output:
{
"data": {
"aiUsageData": {
"all": {
"nodes": [
{
"event": "CODE_SUGGESTION_SHOWN_IN_IDE",
"timestamp": "2025-09-26T18:17:25Z",
"user": {
"username": "jasbourne"
},
"extras": {}
},
{
"event": "AGENT_PLATFORM_SESSION_STARTED",
"timestamp": "2025-09-26T18:13:44Z",
"user": {
"username": "johndoe"
},
"extras": {
"session_id": "abc123"
}
}
]
}
}
}
}Retrieve AI user metrics
- Offering: GitLab.com, GitLab Dedicated
The AiUserMetrics endpoint provides pre-aggregated per-user metrics for all registered GitLab Duo features, including Code Suggestions, GitLab Duo Chat, Code Review, Agent Platform (Agentic Chat), Job Troubleshooting, and Model Context Protocol (MCP) tool calls.
You can use this endpoint to analyze GitLab Duo user engagement and measure usage frequency across different GitLab Duo features.
Prerequisites:
- You must have ClickHouse configured.
Total event counts
The AiUserMetrics endpoint provides the following levels of event count aggregation:
- Top-level
totalEventCount: Returns the sum of all event counts across all GitLab Duo features for a user. - Feature-level
totalEventCount: Available in each feature metric type, returns the sum of all event counts for that specific feature.
You can use these fields to get aggregate counts at different levels of granularity.
For example, to retrieve both top-level and feature-level totals:
query {
group(fullPath:"gitlab-org") {
aiUserMetrics {
nodes {
user {
username
}
totalEventCount
codeSuggestions {
totalEventCount
codeSuggestionAcceptedInIdeEventCount
codeSuggestionShownInIdeEventCount
}
chat {
totalEventCount
requestDuoChatResponseEventCount
}
}
}
}
}The query returns the following output:
{
"data": {
"group": {
"aiUserMetrics": {
"nodes": [
{
"user": {
"username": "USER_1"
},
"totalEventCount": 82,
"codeSuggestions": {
"totalEventCount": 60,
"codeSuggestionAcceptedInIdeEventCount": 10,
"codeSuggestionShownInIdeEventCount": 50
},
"chat": {
"totalEventCount": 22,
"requestDuoChatResponseEventCount": 22
}
},
{
"user": {
"username": "USER_2"
},
"totalEventCount": 102,
"codeSuggestions": {
"totalEventCount": 72,
"codeSuggestionAcceptedInIdeEventCount": 12,
"codeSuggestionShownInIdeEventCount": 60
},
"chat": {
"totalEventCount": 30,
"requestDuoChatResponseEventCount": 30
}
}
]
}
}
}
}In this example:
- The top-level
totalEventCount(82 for USER_1) is the sum of all events across all features. - Each feature’s
totalEventCountrepresents the sum of events within that feature only.- Code Suggestions: 60 events (10 accepted + 50 shown)
- Chat: 22 events
Feature-specific metric types
The AiUserMetrics endpoint provides detailed metrics through feature-specific nested types. Each GitLab Duo feature has its own dedicated metric type that exposes event count fields for all tracked events related to that feature.
Available feature metric types include:
codeSuggestions: Code Suggestions-specific metricschat: GitLab Duo Chat-specific metricscodeReview: Code Review-specific metricsagentPlatform: Agent Platform-specific metrics (includes Agentic Chat sessions)troubleshootJob: Job troubleshooting-specific metricsmcp: Model Context Protocol (MCP) tool call metrics
Each feature metric type includes:
- Individual event count fields for all tracked events in that feature
- A
totalEventCountfield that sums all events for that specific feature
The available event count fields are dynamically generated based on the events registered in the system. To see which events are tracked for each feature, examine the events declared in the ai_tracking.rb file.
For example, to retrieve detailed metrics across multiple GitLab Duo features:
query {
group(fullPath:"gitlab-org") {
aiUserMetrics {
nodes {
user {
username
}
codeSuggestions {
totalEventCount
codeSuggestionAcceptedInIdeEventCount
codeSuggestionShownInIdeEventCount
}
chat {
totalEventCount
requestDuoChatResponseEventCount
}
codeReview {
totalEventCount
requestReviewDuoCodeReviewOnMrByAuthorEventCount
findNoIssuesDuoCodeReviewAfterReviewEventCount
}
agentPlatform {
totalEventCount
agentPlatformSessionStartedEventCount
agentPlatformSessionFinishedEventCount
}
}
}
}
}The query returns the following output:
{
"data": {
"group": {
"aiUserMetrics": {
"nodes": [
{
"user": {
"username": "USER_1"
},
"codeSuggestions": {
"totalEventCount": 60,
"codeSuggestionAcceptedInIdeEventCount": 10,
"codeSuggestionShownInIdeEventCount": 50
},
"chat": {
"totalEventCount": 22,
"requestDuoChatResponseEventCount": 22
},
"codeReview": {
"totalEventCount": 8,
"requestReviewDuoCodeReviewOnMrByAuthorEventCount": 5,
"findNoIssuesDuoCodeReviewAfterReviewEventCount": 3
},
"agentPlatform": {
"totalEventCount": 15,
"agentPlatformSessionStartedEventCount": 8,
"agentPlatformSessionFinishedEventCount": 7
}
},
{
"user": {
"username": "USER_2"
},
"codeSuggestions": {
"totalEventCount": 72,
"codeSuggestionAcceptedInIdeEventCount": 12,
"codeSuggestionShownInIdeEventCount": 60
},
"chat": {
"totalEventCount": 30,
"requestDuoChatResponseEventCount": 30
},
"codeReview": {
"totalEventCount": 5,
"requestReviewDuoCodeReviewOnMrByAuthorEventCount": 3,
"findNoIssuesDuoCodeReviewAfterReviewEventCount": 2
},
"agentPlatform": {
"totalEventCount": 20,
"agentPlatformSessionStartedEventCount": 12,
"agentPlatformSessionFinishedEventCount": 8
}
}
]
}
}
}
}Retrieve GitLab Duo and SDLC trend metrics
- Offering: GitLab.com, GitLab Dedicated
The AiMetrics endpoint powers the GitLab Duo and SDLC trends dashboard and provides the following pre-aggregated metrics for Code Suggestions and GitLab Duo Chat:
codeSuggestionsShowncodeSuggestionsAcceptedcodeSuggestionAcceptanceRatecodeSuggestionUsersduoChatUsers
Prerequisites:
- You must have ClickHouse configured.
For example, to retrieve Code Suggestions and GitLab 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.