Configure the GitLab data source
This document explains how to configure the GitLab data source in Grafana.
Before you begin
Before configuring the data source, ensure you have:
- Grafana permissions: Organization administrator role
- GitLab account: A GitLab.com or self-hosted GitLab instance
- GitLab personal access token: A token with the
read_apiscope
Create a GitLab personal access token
To authenticate with GitLab, create a personal access token with read_api permissions:
- In GitLab, navigate to your Personal Access Tokens page.
- Enter a name in the Token name field.
- Set an expiration date in the Expiration date field.
- Under Select scopes, select read_api.
- Click Create personal access token.
- Copy the token value. You can’t view the token again after you leave the page.
Add the data source
To add the GitLab data source:
- Click Connections in the left-side menu.
- Click Add new connection.
- Type
GitLabin the search bar. - Select GitLab.
- Click Add new data source.
Configure settings
The following table describes the available configuration settings:
Verify the connection
Click Save & test to verify the connection.
If the connection is successful, you see the message Plugin health check successful.
If you see an error, refer to Troubleshoot GitLab data source issues for help resolving common errors.
Provision the data source
You can define the data source using YAML files as part of Grafana’s provisioning system. For more information about provisioning, refer to Provision Grafana.
apiVersion: 1
datasources:
- name: GitLab
type: grafana-gitlab-datasource
access: proxy
url: https://gitlab.com/api/v4
jsonData:
pageLimit: 5
enableSecureSocksProxy: false
secureJsonData:
accessToken: <YOUR_ACCESS_TOKEN>Replace <YOUR_ACCESS_TOKEN> with your GitLab personal access token.
Provision the data source with Terraform
You can provision the GitLab data source with the Grafana Terraform provider.
resource "grafana_data_source" "gitlab" {
type = "grafana-gitlab-datasource"
name = "GitLab"
url = "https://gitlab.com/api/v4"
json_data_encoded = jsonencode({
pageLimit = 5
enableSecureSocksProxy = false
})
secure_json_data_encoded = jsonencode({
accessToken = var.gitlab_access_token
})
}


