doc/api/graphql/duo_and_sdlc_trends.md
{{< details >}}
{{< /details >}}
Use the GraphQL API to retrieve and export GitLab Duo data.
{{< details >}}
{{< /details >}}
{{< history >}}
code_suggestions_usage_events_in_pg. Disabled by default.move_ai_tracking_to_instrumentation_layer added in GitLab 17.7. Disabled by default.move_ai_tracking_to_instrumentation_layer removed in GitLab 17.8.code_suggestions_usage_events_in_pg removed in GitLab 17.8.AiUsageData removed in GitLab 18.7.{{< /history >}}
The AiUsageData endpoint provides raw event data. It exposes Code Suggestions-specific events through codeSuggestionEvents and all raw event data through all.
[!note] On earlier versions with GitLab Duo Pro, the
AiUsageDataendpoint returnsnullwithout an error message.
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 and codeSuggestionEvents attributes have a maximum date range of one month. If you need data spanning multiple months, run separate queries for each month.
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.
GitLab Duo Chat events (request_duo_chat_response) do not populate the extras field.
Unlike Code Suggestions events, Chat interactions do not carry language or suggestion metadata.
An empty extras object on Chat events is expected behavior.
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"
}
}
]
}
}
}
}
}
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
Prerequisites:
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"
}
}
]
}
}
}
}
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
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, 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:
The AiUserMetrics endpoint provides the following levels of event count aggregation:
totalEventCount: Returns the sum of all event counts across all GitLab Duo features for a user.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:
totalEventCount (82 for USER_1) is the sum of all events across all features.totalEventCount represents the sum of events within that feature only.
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 metricsEach feature metric type includes:
totalEventCount field that sums all events for that specific featureThe 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
}
}
]
}
}
}
}
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
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:
codeSuggestionsShowncodeSuggestionsAcceptedcodeSuggestionAcceptanceRatecodeSuggestionUsersduoChatUsersPrerequisites:
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
duoUsedCount
}
}
}
The query returns the following output:
{
"data": {
"group": {
"aiMetrics": {
"codeSuggestions": {
"shownCount": 88728,
"acceptedCount": 7016,
"acceptedLinesOfCode": 9334,
"shownLinesOfCode": 124118
},
"codeContributorsCount": 719,
"duoChatContributorsCount": 681,
"duoUsedCount": 714
}
}
},
}
You can export AI metrics data to a CSV file with the GitLab AI Metrics Exporter tool.