[Yandex Cloud documentation](../../index.md) > [Yandex DataLens](../index.md) > [Tutorials](index.md) > Service analytics > Visualizing Yandex Monitoring data

# Visualizing Yandex Monitoring data


This tutorial will be useful if you have already deployed and started one of the Yandex Cloud services.

You will create a chart using the [Yandex Monitoring query language](../../monitoring/concepts/querying.md) and add it to the dashboard.


To visualize and explore data, [set up DataLens](#before-you-begin) and follow the steps below:


1. [Create a connection](#create-connection).
1. [Create a QL chart](#create-sql-chart).
1. [Create a dashboard](#create-dashboard).
1. [Add the QL chart to the dashboard](#add-sql-chart-to-dashboard).
1. [Add selectors to the dashboard](#add-selectors-to-dashboard).


## Getting started {#before-you-begin}

To get started with DataLens:

1. [Log in](https://passport.yandex.com/auth) to your Yandex account.
1. Open the DataLens [home page](https://datalens.ru/?skipPromo=true).
1. Click **Open Datalens**.
1. Select one of these options:

   * If you already have an organization, select it from the drop-down menu in the **Organizations** tab and click **Open DataLens**.
      
      {% note info %}

      To activate a DataLens instance, the user must have the `admin` or `owner` role. For more information about roles, see [Access management in Yandex Identity Hub](../../organization/security/index.md).

      {% endnote %}

   * If you have a cloud but no organization, click **Add new DataLens**. In the window that opens, enter a name and description for your organization and click **Create organization and DataLens**. For more information about working with organizations, see [Getting started with organizations](../../organization/quickstart.md).

   If you encounter a technical issue with the service, contact Yandex Cloud [support](https://center.yandex.cloud/support). To ask for advice, discuss a solution to your issue, or explore current best practices, join the [DataLens](https://t.me/YandexDataLens) chat in Telegram. 


## Create a connection {#create-connection}

{% note info %}

To create a connection, you need a [service account](../../iam/concepts/users/service-accounts.md) with the `monitoring.viewer` or `viewer` [role](../../iam/operations/sa/assign-role-for-sa.md).
To write queries in QL charts, use the [Yandex Monitoring query language](../../monitoring/concepts/querying.md).

{% endnote %}

### Connecting to Monitoring {#monitoring-connection}

To create a Monitoring connection:

1. Go to the [connections page](https://datalens.ru/connections).
1. Click **Create connection**.
1. Select the **Monitoring** connection.
1. Configure the connection as follows:

   * **Cloud and folder**: Select the folder with your service account.
   * **Service account**: Select an existing service account or create a new one.

1. Click **Create connection**.
1. Enter a name for the connection and click **Create**. The connection will appear in the list.

## Create a QL chart {#create-sql-chart}

1. Go to the connection you created.
1. In the top-right corner, click **Create QL chart**.
1. On the **Query** tab, enter the query text. You can either write it yourself or copy it from Monitoring.

   {% cut "How to copy a query from Monitoring" %}
   
   1. Go to the dashboard you need in Monitoring. To make your dashboards accessible, you need to have at least one of the Yandex Cloud services running.
   1. Open the chart you need in Metric Explorer by clicking ![image](../../_assets/console-icons/compass.svg) in the top-right corner of the chart.
   
      ![metrica-memory-usage](../../_assets/datalens/monitoring-visualization/metrica-memory-usage.png)

   1. At the bottom of the screen, go to the **Queries** tab.
   1. In the row with the query, click ![image](../../_assets/console-icons/ellipsis.svg) and select **Copy as text**. In DataLens, enter the query, skipping the `folderId` parameter.
      
      Example of a query in Monitoring:
      
      ```sql
      "cpu_usage"{folderId="b1g9r5h41935********", service="compute", resource_id="charts-prod-vla-1"}
      ```
      In DataLens, enter the query, skipping the `folderId` parameter:

      ```sql
      "cpu_usage"{service="compute", resource_id="charts-prod-vla-1"}
      ```

   {% endcut %}

1. On the **Parameters** tab, specify the time interval.

   ![monitoring-datetime-parameters](../../_assets/datalens/monitoring-visualization/monitoring-datetime-parameters.png)

1. Click **Start**. Check that the query runs without errors and the chart displays the data.
1. In the top-right corner, click **Save**.
1. Enter `Monitoring Data Chart` for the chart name and click **Save**.

You can add the chart to the dashboard. You can also add a selector to the dashboard to manage the `interval` parameter in the QL chart.

## Create a dashboard {#create-dashboard}

Create a [dashboard](../concepts/dashboard.md) for the charts.

1. In the left-hand panel, click ![image](../../_assets/console-icons/layout-cells-large.svg) **Dashboards**.
1. Click **Create dashboard**.

## Add the QL chart to the dashboard {#add-sql-chart-to-dashboard}

1. At the top of the page, click **Add** and select **Chart**.
   
   ![image](../../_assets/datalens/monitoring-visualization/add-chart.png)

1. In the **Chart** field, click **Select** and select the chart you created in the previous steps, `Monitoring Data Chart`, from the chart list.
   
   ![image](../../_assets/datalens/monitoring-visualization/select-chart.png)

   Click **Add**.

1. The chart is now on the dashboard. Expand it for better visualization.
1. Save the dashboard:

   1. In the top-right corner, click **Save**.
   1. Enter `Monitoring Data` for the dashboard name and click **Create**.

## Add selectors to the dashboard {#add-selectors-to-dashboard}

Add a [selector](../dashboard/selector.md) so that you can select the time interval for the displayed data:

1. At the top of the page, click **Add**.
1. Choose **Selector**.

   ![image](../../_assets/datalens/monitoring-visualization/add-selector.png)

1. Select **Manual input** as the source type.
1. In **Field or parameter name**, enter `interval`. This query variable will get the selected values from the selector.
1. Select **Calendar** as the selector type.
1. Enable **Range**.

   ![image](../../_assets/datalens/monitoring-visualization/add-selector-parameters.png)

1. In the **Default value** field, specify an offset from the current date and click **Apply**.

   ![image](../../_assets/datalens/monitoring-visualization/selector-default-values.png)

1. Enable **Name** and enter `Date interval`.
1. Click **Add**.
1. Place the selector on the dashboard above the chart.
1. Save the dashboard.
1. Your dashboard is ready for use. You can now select the time interval using the selector.
   
   ![image](../../_assets/datalens/monitoring-visualization/selector-2-values.png)

#### Useful links {#see-also}

* [Adding a chart to a dashboard in Yandex DataLens](../operations/dashboard/add-chart.md)
* [Adding a selector to a dashboard in Yandex DataLens](../operations/dashboard/add-selector.md)
* [Creating a QL chart in Yandex DataLens](../operations/chart/create-sql-chart.md)
* [QL charts](../concepts/chart/index.md#sql-charts)