2020-06-23 00:09:42 +05:30
---
stage: Monitor
2022-04-04 11:22:00 +05:30
group: Respond
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-06-23 00:09:42 +05:30
---
2021-03-11 19:13:27 +05:30
# Grafana Configuration **(FREE SELF)**
2016-11-03 12:29:30 +05:30
2020-07-28 23:09:34 +05:30
[Grafana ](https://grafana.com/ ) is a tool that enables you to visualize time
series metrics through graphs and dashboards. GitLab writes performance data to Prometheus,
and Grafana allows you to query the data to display useful graphs.
2016-11-03 12:29:30 +05:30
## Installation
2020-07-28 23:09:34 +05:30
Omnibus GitLab can [help you install Grafana (recommended) ](https://docs.gitlab.com/omnibus/settings/grafana.html )
2019-09-04 21:01:54 +05:30
or Grafana supplies package repositories (Yum/Apt) for easy installation.
2022-08-13 15:12:31 +05:30
See [Grafana installation documentation ](https://grafana.com/docs/grafana/latest/setup-grafana/installation/ )
2016-11-03 12:29:30 +05:30
for detailed steps.
2021-03-11 19:13:27 +05:30
Before starting Grafana for the first time, set the administration user
2020-07-28 23:09:34 +05:30
and password in `/etc/grafana/grafana.ini` . If you don't, the default password
is `admin` .
2016-11-03 12:29:30 +05:30
## Configuration
2021-03-11 19:13:27 +05:30
1. Log in to Grafana as the administration user.
1. Select **Data Sources** from the **Configuration** menu.
2023-03-17 16:20:25 +05:30
1. Select **Add data source** .
2021-03-11 19:13:27 +05:30
1. Select the required data source type. For example, [Prometheus ](../prometheus/index.md#prometheus-as-a-grafana-data-source ).
2023-03-17 16:20:25 +05:30
1. Complete the details for the data source and select **Save & Test** .
2021-03-11 19:13:27 +05:30
Grafana should indicate the data source is working.
2016-11-03 12:29:30 +05:30
## Import Dashboards
2020-07-28 23:09:34 +05:30
You can now import a set of default dashboards to start displaying useful information.
GitLab has published a set of default
2021-03-11 19:13:27 +05:30
[Grafana dashboards ](https://gitlab.com/gitlab-org/grafana-dashboards ) to get you started. To use
them:
2020-07-28 23:09:34 +05:30
2021-03-11 19:13:27 +05:30
1. Clone the repository, or download a ZIP file or tarball.
1. Follow these steps to import each JSON file individually:
2020-07-28 23:09:34 +05:30
2021-03-11 19:13:27 +05:30
1. Log in to Grafana as the administration user.
1. Select **Manage** from the **Dashboards** menu.
2023-03-17 16:20:25 +05:30
1. Select **Import** , then **Upload JSON file** .
1. Locate the JSON file to import and select **Choose for Upload** . Select **Import** .
2021-03-11 19:13:27 +05:30
1. After the dashboard is imported, select the **Save dashboard** icon in the top bar.
2016-11-03 12:29:30 +05:30
2021-03-11 19:13:27 +05:30
If you don't save the dashboard after importing it, the dashboard is removed
when you navigate away from the page. Repeat this process for each dashboard you wish to import.
2016-11-03 12:29:30 +05:30
2020-07-28 23:09:34 +05:30
Alternatively, you can import all the dashboards into your Grafana
instance. For more information about this process, see the
[README of the Grafana dashboards ](https://gitlab.com/gitlab-org/grafana-dashboards )
repository.
2016-11-03 12:29:30 +05:30
2019-09-30 21:07:59 +05:30
## Integration with GitLab UI
2020-06-23 00:09:42 +05:30
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/61005) in GitLab 12.1.
2019-09-30 21:07:59 +05:30
2020-07-28 23:09:34 +05:30
After setting up Grafana, you can enable a link to access it easily from the
GitLab sidebar:
2019-09-30 21:07:59 +05:30
2022-10-11 01:57:18 +05:30
1. On the top bar, select **Main menu > Admin** .
2021-09-04 01:27:46 +05:30
1. On the left sidebar, select **Settings > Metrics and profiling**
and expand **Metrics - Grafana** .
2021-10-27 15:23:28 +05:30
1. Select the **Add a link to Grafana** checkbox.
2020-07-28 23:09:34 +05:30
1. Configure the **Grafana URL** :
- *If Grafana is enabled through Omnibus GitLab and on the same server,*
leave **Grafana URL** unchanged. It should be `/-/grafana` .
- *Otherwise,* enter the full URL of the Grafana instance.
2021-10-27 15:23:28 +05:30
1. Select **Save changes** .
2020-07-28 23:09:34 +05:30
2022-10-11 01:57:18 +05:30
GitLab displays your link in the **Main menu > Admin > Monitoring > Metrics Dashboard** .
2019-09-30 21:07:59 +05:30
2021-10-27 15:23:28 +05:30
## Required Scopes
> [Introduced](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/5822) in GitLab 13.10.
When setting up Grafana through the process above, no scope shows in the screen at
2022-10-11 01:57:18 +05:30
**Main menu > Admin > Applications > GitLab Grafana**. However, the `read_user` scope is
2021-10-27 15:23:28 +05:30
required and is provided to the application automatically. Setting any scope other than
2022-11-25 23:54:43 +05:30
`read_user` without also including `read_user` leads to this error when you try to sign in using
2021-10-27 15:23:28 +05:30
GitLab as the OAuth provider:
```plaintext
The requested scope is invalid, unknown, or malformed.
```
If you see this error, make sure that one of the following is true in the GitLab Grafana
configuration screen:
- No scopes appear.
- The `read_user` scope is included.
> Versions of GitLab prior 13.10 use the API scope instead of `read_user`. In versions of GitLab
> prior to 13.10, the API scope:
>
> - Is required to access Grafana through the GitLab OAuth provider.
> - Is set by enabling the Grafana application as shown in [Integration with GitLab UI](#integration-with-gitlab-ui).
2019-10-12 21:52:04 +05:30
## Security Update
2020-07-28 23:09:34 +05:30
Users running GitLab version 12.0 or later should immediately upgrade to one of the
following security releases due to a known vulnerability with the embedded Grafana dashboard:
2019-10-12 21:52:04 +05:30
- 12.0.6
- 12.1.6
2020-07-28 23:09:34 +05:30
After upgrading, the Grafana dashboard is disabled, and the location of your
existing Grafana data is changed from `/var/opt/gitlab/grafana/data/` to
`/var/opt/gitlab/grafana/data.bak.#{Date.today}/` .
2019-10-12 21:52:04 +05:30
To prevent the data from being relocated, you can run the following command prior to upgrading:
2020-03-13 15:44:24 +05:30
```shell
2019-10-12 21:52:04 +05:30
echo "0" > /var/opt/gitlab/grafana/CVE_reset_status
```
To reinstate your old data, move it back into its original location:
2020-03-13 15:44:24 +05:30
```shell
2019-10-12 21:52:04 +05:30
sudo mv /var/opt/gitlab/grafana/data.bak.xxxx/ /var/opt/gitlab/grafana/data/
```
However, you should **not** reinstate your old data _except_ under one of the following conditions:
2021-03-11 19:13:27 +05:30
1. If you're certain that you changed your default administration password when you enabled Grafana.
2020-07-28 23:09:34 +05:30
1. If you run GitLab in a private network, accessed only by trusted users, and your
Grafana login page has not been exposed to the internet.
2019-10-12 21:52:04 +05:30
2020-07-28 23:09:34 +05:30
If you require access to your old Grafana data but don't meet one of these criteria, you may consider:
2020-04-08 14:13:33 +05:30
1. Reinstating it temporarily.
2023-01-13 00:05:48 +05:30
1. [Exporting the dashboards ](https://grafana.com/docs/grafana/latest/dashboards/manage-dashboards/#export-and-import-dashboards ) you need.
1. Refreshing the data and [re-importing your dashboards ](https://grafana.com/docs/grafana/latest/dashboards/manage-dashboards/#export-and-import-dashboards ).
2020-04-08 14:13:33 +05:30
2021-02-22 17:27:13 +05:30
WARNING:
2020-07-28 23:09:34 +05:30
These actions pose a temporary vulnerability while your old Grafana data is in use.
Deciding to take any of these actions should be weighed carefully with your need to access
existing data and dashboards.
2019-10-12 21:52:04 +05:30
2023-01-13 00:05:48 +05:30
For more information and further mitigation details, refer to our
2020-07-28 23:09:34 +05:30
[blog post on the security release ](https://about.gitlab.com/releases/2019/08/12/critical-security-release-gitlab-12-dot-1-dot-6-released/ ).
2019-10-12 21:52:04 +05:30
2016-11-03 12:29:30 +05:30
Read more on:
2020-03-13 15:44:24 +05:30
- [Introduction to GitLab Performance Monitoring ](index.md )
2016-11-03 12:29:30 +05:30
- [GitLab Configuration ](gitlab_configuration.md )