---
title: "Grafana"
sidebar_label: "Grafana"
description: "How to configure Grafana for visualizing metrics and analyzing data"
sidebar_position: 4
---

import Formbricks from '@theme/MDXComponents/Formbricks';
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import CopyIcon from '@selectel/docux/icons/copy'

# Grafana

[Grafana](https://grafana.com/) is an open-source platform for visualizing metrics and real-time data analysis. The Metrics service supports full integration with Grafana. The integration allows you to view historical metrics for 30 days and build analytical queries for metrics.

To visualize metrics, [configure Grafana](#configure-grafana).

## Configure Grafana \{#configure-grafana}

1. [Add a service user](#add-service-user).
2. [Start Grafana](#start-grafana).
3. [Configure a data source](#configure-data-source).
4. [Create a dashboard](#create-dashboard).

### 1. Add a service user \{#add-service-user}

[Add a service user](/access-control/manage/add-user.mdx#add-service-user) with permission in the **Projects** access area and the role:

* `metrics.admin;`
* `member;`
* or [`reader`](/access-control/role-reference.mdx#reader).

Users can be added by the [Account Owner](/access-control/user-types.mdx#account-owner) or users with the [`iam.admin`](/access-control/role-reference.mdx#iam-admin).

### 2. Start Grafana \{#start-grafana}

:::info

This is an instruction for running Grafana locally. If you have an existing Grafana installation, start it using the [Start the Grafana server](https://grafana.com/docs/grafana/latest/setup-grafana/start-restart-grafana/) instruction in the official Grafana documentation.

:::

1. Open the CLI.

2. Start Grafana in Docker.

```bash
docker run -d -p 3000:3000 --name=grafana grafana/grafana
```

3. Open the `http://localhost:3000` page in your browser.

4. To connect to Grafana, enter the default credentials: username (`admin`) and password (`admin`).

### 3. Configure a data source \{#configure-data-source}

1. [Start Grafana](#start-grafana).

2. Go to the **Data Sources**.

3. Click **Add data source**.

4. Select [Prometheus](https://grafana.com/docs/grafana/latest/datasources/prometheus/).

5. In the **Name** field, specify a name for the data source.

6. In the **Connection** block, in the **Prometheus server URL** field, enter the Metrics service endpoint:

   ```bash
   <base_url>/projects/<project_id>/namespaces/<namespace>
   ```

   Specify:

   * `<base_url>` — API URL for the Metrics service. If you are configuring a metrics collection agent for a [dedicated server](/dedicated/), use the cloud server pool URL that corresponds to the pool where your dedicated server is located. The list of URLs can be found in the [URL list](/api/urls/);
   * `<project_id>` — project ID. Can be copied in the [control panel](https://my.selectel.ru/vpc/): from the top menu, click **Products** and select **Cloud Servers** → open the projects menu → in the row of the required project, click ;<CopyIcon />
   * `<namespace>` — name of the selected namespace, for example `compute`.

7. In the **Authentication method** field, select **Basic authentication**.

8. In the **User** field, enter the ID of the user you [added in step 1](#add-service-user);

9. In the **Password** field, enter the password of the user you [added in step 1](#add-service-user).

10. Click **Save & test** and wait for the test request to complete.

### 4. Create a dashboard \{#create-dashboard}

1. [Launch Grafana](#start-grafana).

2. Go to the **Dashboards** section.

3. Click **Create dashboard**.

4. Click **Add visualization**.

5. Select the Prometheus data source that you [configured in step 3](#configure-data-source).

6. On the **Queries** tab, in the **Metrics** field, enter the metric name. For more information about available metrics, see the [Metrics Reference](/metrics/metrics-references.mdx).

7. Optional: to add multiple metrics, click **Add query** and repeat step 5.

8. To display metric values on the dashboard, click **Run queries**.

9. Click **Save dashboard**.

<Formbricks />
