GitLab query editor
This document explains how to use the GitLab query editor to build queries and visualize GitLab data. The query editor provides 13 resource types that map to the GitLab API, letting you query everything from commits and merge requests to pipelines, deployments, and audit events. Each resource type has its own set of filters to narrow results.
Before you begin
- Configure the GitLab data source.
- Verify your personal access token has the
read_apiscope.
Resource types
The query editor supports the following resource types. Select a resource type from the Resource Type drop-down to configure the query.
- Audit events
- Commits
- Deployments
- Environments
- Issues
- Labels
- Merge request approvals
- Merge requests
- Pipelines
- Projects
- Releases
- Tags
- Users
Audit events
Query audit events for a specific project, group, or (on self-hosted GitLab with admin privileges) the entire instance.
Note
Audit events require a GitLab Premium subscription for project and group queries, or a self-hosted instance with admin privileges for instance-level queries.
On self-hosted GitLab, if no project ID or group ID is set, the data source returns all audit events for the instance.
Commits
Query commits from a specific project.
Deployments
Query deployments from a specific project.
Environments
Query environments from a specific project.
Issues
Query issues from a specific project.
Labels
Query labels from a specific project.
Merge request approvals
Retrieve approval information for a specific merge request.
Merge requests
Query merge requests for a project, group, or all merge requests associated with the configured GitLab account.
If no Project Id or Group Id is provided, the data source returns all merge requests associated with the configured GitLab account.
Pipelines
Query pipelines from a specific project.
Projects
Query projects accessible to the configured GitLab account.
Note
Fetching all projects (with Owned set to
AllorFalse) may take a long time depending on how many projects are accessible.
Releases
Query releases from a specific project.
Tags
Query tags from a specific project.
Users
Query users. Most filter fields require GitLab admin privileges.
Use transformations to answer common questions
You can use transformations to aggregate, group, and join query results to answer more complex questions.
Count commits, issues, or deployments per day
To count the number of commits (or issues, or deployments) per day:
Add a query:
a. Select the resource type (for example, Commits).
b. Enter the Project Id.
Add a Group by transformation:
a. Set Group by to
created_at_date.b. Set Calculate to Count on the
idfield.Select the Time series visualization.
Track open merge requests in a table
To display a table of currently open merge requests:
Add a query:
a. Select the Merge Requests resource type.
b. Enter the Project Id.
c. Set State to
opened.Select the Table visualization.
Optionally, add an Organize fields by name transformation to reorder or hide columns. A useful column order is
title,author,source_branch,target_branch,created_at.
Track deployment frequency by environment
To visualize how often deployments occur across environments:
Add a query:
a. Select the Deployments resource type.
b. Enter the Project Id.
c. Optionally, set Status Query to
successto count only successful deployments.Add a Group by transformation:
a. Set Group by to
environment.b. Set Calculate to Count on the
idfield.Select the Bar chart visualization to compare deployment counts across environments.
Monitor pipeline failure rate
To track the ratio of failed pipelines over time:
Add two queries, both using the Pipelines resource type with the same Project Id:
a. Query A: Set Status to
failed.b. Query B: Leave Status empty to return all pipelines.
For each query, add a Group by transformation:
a. Set Group by to
created_at_date.b. Set Calculate to Count on the
idfield.Add a Merge transformation to join both queries by
created_at_date.Add an Add field from calculation transformation:
a. Set Mode to Binary Operation.
b. Set the operation to Query A
id (count)/ Query Bid (count).c. Set Alias to
failure_rate.Select the Time series visualization to chart the failure rate over time.
Calculate average issue resolution time
To find the average time to close issues:
Add a query:
a. Select the Issues resource type.
b. Enter the Project Id.
Add an Add field from calculation transformation:
a. Set Mode to Binary Operation.
b. Set the operation to
closed_at-created_at.c. Set Alias to
resolution_time.Add another Add field from calculation transformation:
a. Set Mode to Binary Operation.
b. Set the operation to
resolution_time/86400000(milliseconds in a day: 1000 x 3600 x 24).c. Set Alias to
resolution_time.d. Enable Replace all fields.
Select the Stat visualization:
a. Set Show to Calculate.
b. Set Calculation to Mean.
c. Set Fields to
resolution_time.



