|
| 1 | +--- |
| 2 | +title: Use Azure Monitor managed service for Prometheus (preview) as data source for Grafana |
| 3 | +description: Details on how to configure Azure Monitor managed service for Prometheus (preview) as data source for both Azure Managed Grafana and self-hosted Grafana in an Azure virtual machine. |
| 4 | +author: bwren |
| 5 | +ms.topic: conceptual |
| 6 | +ms.date: 09/28/2022 |
| 7 | +--- |
| 8 | + |
| 9 | +# Use Azure Monitor managed service for Prometheus (preview) as data source for Grafana using managed system identity |
| 10 | + |
| 11 | +[Azure Monitor managed service for Prometheus (preview)](prometheus-metrics-overview.md) allows you to collect and analyze metrics at scale using a [Prometheus](https://aka.ms/azureprometheus-promio)-compatible monitoring solution. The most common way to analyze and present Prometheus data is with a Grafana dashboard. This article explains how to configure Prometheus as a data source for both [Azure Managed Grafana](../../managed-grafana/overview.md) and [self-hosted Grafana](https://grafana.com/) running in an Azure virtual machine using managed system identity authentication. |
| 12 | + |
| 13 | + |
| 14 | +## Azure Managed Grafana |
| 15 | +The following sections describe how to configure Azure Monitor managed service for Prometheus (preview) as a data source for Azure Managed Grafana. |
| 16 | + |
| 17 | +> [!IMPORTANT] |
| 18 | +> This section describes the manual process for adding an Azure Monitor managed service for Prometheus data source to Azure Managed Grafana. You can achieve the same functionality by linking the Azure Monitor workspace and Grafana workspace as described in [Link a Grafana workspace](azure-monitor-workspace-overview.md#link-a-grafana-workspace). |
| 19 | +
|
| 20 | +### Configure system identify |
| 21 | +Your Grafana workspace requires the following: |
| 22 | + |
| 23 | +- System managed identity enabled |
| 24 | +- *Monitoring Data Reader* role for the Azure Monitor workspace |
| 25 | + |
| 26 | +Both of these settings are configured by default when you created your Grafana workspace. Verify these settings on the **Identity** page for your Grafana workspace. |
| 27 | + |
| 28 | +:::image type="content" source="media/prometheus-grafana/grafana-system-identity.png" alt-text="Screenshot of Identity page for Azure Managed Grafana." lightbox="media/prometheus-grafana/grafana-system-identity.png"::: |
| 29 | + |
| 30 | + |
| 31 | +**Configure from Grafana workspace**<br> |
| 32 | +Use the following steps to allow access all Azure Monitor workspaces in a resource group or subscription: |
| 33 | + |
| 34 | +1. Open the **Identity** page for your Grafana workspace in the Azure portal. |
| 35 | +2. If **Status** is **No**, change it to **Yes**. |
| 36 | +3. Click **Azure role assignments** to review the existing access in your subscription. |
| 37 | +4. If **Monitoring Data Reader** is not listed for your subscription or resource group: |
| 38 | + 1. Click **+ Add role assignment**. |
| 39 | + 2. For **Scope**, select either **Subscription** or **Resource group**. |
| 40 | + 3. For **Role**, select **Monitoring Data Reader**. |
| 41 | + 4. Click **Save**. |
| 42 | + |
| 43 | + |
| 44 | +**Configure from Azure Monitor workspace**<br> |
| 45 | +Use the following steps to allow access to only a specific Azure Monitor workspace: |
| 46 | + |
| 47 | +1. Open the **Access Control (IAM)** page for your Azure Monitor workspace in the Azure portal. |
| 48 | +2. Click **Add role assignment**. |
| 49 | +3. Select **Monitoring Data Reader** and click **Next**. |
| 50 | +4. For **Assign access to**, select **Managed identity**. |
| 51 | +5. Click **+ Select members**. |
| 52 | +6. For **Managed identity**, select **Azure Managed Grafana**. |
| 53 | +7. Select your Grafana workspace and then click **Select**. |
| 54 | +8. Click **Review + assign** to save the configuration. |
| 55 | + |
| 56 | +### Create Prometheus data source |
| 57 | + |
| 58 | +Azure Managed Grafana supports Azure authentication by default. |
| 59 | + |
| 60 | +1. Open the **Overview** page for your Azure Monitor workspace in the Azure portal. |
| 61 | +2. Copy the **Query endpoint**, which you'll need in a step below. |
| 62 | +3. Open your Azure Managed Grafana workspace in the Azure portal. |
| 63 | +4. Click on the **Endpoint** to view the Grafana workspace. |
| 64 | +5. Select **Configuration** and then **Data source**. |
| 65 | +6. Click **Add data source** and then **Prometheus**. |
| 66 | +7. For **URL**, paste in the query endpoint for your Azure Monitor workspace. |
| 67 | +8. Select **Azure Authentication** to turn it on. |
| 68 | +9. For **Authentication** under **Azure Authentication**, select **Managed Identity**. |
| 69 | +10. Scroll to the bottom of the page and click **Save & test**. |
| 70 | + |
| 71 | +:::image type="content" source="media/prometheus-grafana/prometheus-data-source.png" alt-text="Screenshot of configuration for Prometheus data source." lightbox="media/prometheus-grafana/prometheus-data-source.png"::: |
| 72 | + |
| 73 | + |
| 74 | +## Self-managed Grafana |
| 75 | +The following sections describe how to configure Azure Monitor managed service for Prometheus (preview) as a data source for self-managed Grafana on an Azure virtual machine. |
| 76 | +### Configure system identify |
| 77 | +Azure virtual machines support both system assigned and user assigned identity. The following steps configure system assigned identity. |
| 78 | + |
| 79 | +**Configure from Azure virtual machine**<br> |
| 80 | +Use the following steps to allow access all Azure Monitor workspaces in a resource group or subscription: |
| 81 | + |
| 82 | +1. Open the **Identity** page for your virtual machine in the Azure portal. |
| 83 | +2. If **Status** is **No**, change it to **Yes**. |
| 84 | +3. Click **Azure role assignments** to review the existing access in your subscription. |
| 85 | +4. If **Monitoring Data Reader** is not listed for your subscription or resource group: |
| 86 | + 1. Click **+ Add role assignment**. |
| 87 | + 2. For **Scope**, select either **Subscription** or **Resource group**. |
| 88 | + 3. For **Role**, select **Monitoring Data Reader**. |
| 89 | + 4. Click **Save**. |
| 90 | + |
| 91 | +**Configure from Azure Monitor workspace**<br> |
| 92 | +Use the following steps to allow access to only a specific Azure Monitor workspace: |
| 93 | + |
| 94 | +1. Open the **Access Control (IAM)** page for your Azure Monitor workspace in the Azure portal. |
| 95 | +2. Click **Add role assignment**. |
| 96 | +3. Select **Monitoring Data Reader** and click **Next**. |
| 97 | +4. For **Assign access to**, select **Managed identity**. |
| 98 | +5. Click **+ Select members**. |
| 99 | +6. For **Managed identity**, select **Virtual machine**. |
| 100 | +7. Select your Grafana workspace and then click **Select**. |
| 101 | +8. Click **Review + assign** to save the configuration. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +### Create Prometheus data source |
| 107 | + |
| 108 | +Versions 9.x and greater of Grafana support Azure Authentication, but it's not enabled by default. To enable this feature, you need to update your Grafana configuration. To determine where your Grafana.ini file is and how to edit your Grafana config, please review this document from Grafana Labs. Once you know where your configuration file lives on your VM, make the following update: |
| 109 | + |
| 110 | + |
| 111 | +1. Locate and open the *Grafana.ini* file on your virtual machine. |
| 112 | +2. Under the `[auth]` section of the configuration file, change the `azure_auth_enabled` setting to `true`. |
| 113 | +3. Open the **Overview** page for your Azure Monitor workspace in the Azure portal. |
| 114 | +4. Copy the **Query endpoint**, which you'll need in a step below. |
| 115 | +5. Open your Azure Managed Grafana workspace in the Azure portal. |
| 116 | +6. Click on the **Endpoint** to view the Grafana workspace. |
| 117 | +7. Select **Configuration** and then **Data source**. |
| 118 | +8. Click **Add data source** and then **Prometheus**. |
| 119 | +9. For **URL**, paste in the query endpoint for your Azure Monitor workspace. |
| 120 | +10. Select **Azure Authentication** to turn it on. |
| 121 | +11. For **Authentication** under **Azure Authentication**, select **Managed Identity**. |
| 122 | +12. Scroll to the bottom of the page and click **Save & test**. |
| 123 | + |
| 124 | +:::image type="content" source="media/prometheus-grafana/prometheus-data-source.png" alt-text="Screenshot of configuration for Prometheus data source." lightbox="media/prometheus-grafana/prometheus-data-source.png"::: |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | +## Next steps |
| 129 | + |
| 130 | +- [Collect Prometheus metrics for your AKS cluster](../containers/container-insights-prometheus-metrics-addon.md). |
| 131 | +- [Configure Prometheus alerting and recording rules groups](prometheus-rule-groups.md). |
| 132 | +- [Customize scraping of Prometheus metrics](prometheus-metrics-scrape-configuration.md). |
0 commit comments