---
title: "Collect Azure Metrics with Grafana Alloy | Grafana Cloud documentation"
description: "How to configure Azure metrics"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Collect Azure Metrics with Grafana Alloy

Complete the following steps to configure Azure Metrics with Grafana Alloy. This Alloy setup uses Azure Resource Graph to identify resources for metric collection. After identifying resources, Grafana Alloy, embedded with the [azure-metrics-exporter](https://github.com/webdevops/azure-metrics-exporter), uses the [Azure Monitor APIs](https://learn.microsoft.com/en-us/rest/api/monitor/) to gather metric data. After the metric data is gathered, that data is written to [Grafana Cloud Metrics](/products/cloud/metrics/).

The following diagram illustrates using Grafana Alloy on your own infrastructure to collect Azure metrics:

[](/media/blog/azure-serverless/prometheus-exporter-azure.png)

## Navigate to Cloud provider Azure configuration

1. Open your [Grafana Cloud Portal](/docs/grafana-cloud/security-and-account-management/cloud-portal/).
2. Expand **Observability &gt; Cloud provider** in the main menu.
3. Select **Azure**.
4. Click the **Configuration** tab.

## Navigate to Azure Metrics with Alloy

1. Click **Manually with Alloy** on the toggle for how you want to configure Azure.
2. Select the **Azure Metrics** tile for what you want to monitor.

## Select your platform

Select the platform and Architecture from the drop-down menus.

## Install Alloy

[Grafana Alloy](/docs/grafana-cloud/send-data/alloy/) includes an [embedded exporter](/docs/agent/latest/static/configuration/integrations/azure-exporter-config/) to gather and send metrics to Grafana Cloud.

1. If you have not already installed Alloy where you intend to run Azure Metrics, click **Run Grafana Alloy**.
2. In the **Alloy configuration** dialog box, select to either create a token or use an existing token.
   
   - To create a token, enter a token name, then click **Create token**. The token displays on the screen and is added to the command for running Alloy. Scroll down and copy the command and paste it into your terminal.
   - To use an existing token, paste it into the Existing token field. The token is added to the command for running Alloy. Scroll down, copy the command, and paste it into your terminal.
3. Click **Proceed with the installation**.

## Configure access for Grafana Alloy to gather Azure Metrics

To export metrics from Azure, Grafana Alloy needs the proper authorization to pull data from your Azure subscriptions.

1. Click **Setup instructions**.
2. Follow the steps to create a service principal with the `Azure Monitoring Reader` role, using the Azure CLI. Creating a service principal using the Azure CLI is just one way to configure authentication to Azure.
   
   Alloy uses the Azure SDK for Go. The SDK has multiple options for configuring authentication to Azure, including, but not limited to:
   
   - A service principal with environment variable
   - A workload identity
   - A managed identity
   
   No matter the option you choose, you must assign the identity to the `Azure Monitoring Reader` role for any Azure subscriptions you want to monitor. Refer to the various options for configuring authentication in [Azure documentation](https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication?tabs=bash#2-authenticate-with-azure).

## Configure Alloy

Set up Grafana Alloy to get metrics from Azure Metrics.

1. Navigate to the configuration file for your Alloy instance. To learn more about where to find the configuration file, refer to [Configure Grafana Alloy](/docs/grafana-cloud/send-data/alloy/configure/)
2. Copy and append the following configuration sample to your Alloy configuration file:
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
    prometheus.exporter.azure "integrations_azure_exporter" {
      subscriptions = ["<subscription_id>"]
      resource_type = "<resource_type>"
      metrics       = ["<metric>"]
      regions       = ["<region>"]
    }
   
    prometheus.scrape "integrations_azure_exporter" {
      targets    = prometheus.exporter.azure.integrations_azure_exporter.targets
      forward_to = [prometheus.remote_write.metrics_service.receiver]
      job_name   = "integrations/azure_exporter"
    }
   ```
3. Update the following property values in your configuration file based on the values for your Azure instance:
   
   Expand table
   
   | Property        | Value (required)                                                                                                                                                                                                                                                                                                                                 |
   |-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
   | `subscriptions` | The Azure subscription you want to scrape metrics from. If you need to scrape multiple Azure services, create one exporter for each service.                                                                                                                                                                                                     |
   | `resource_type` | The Azure Resource Type you want to scrape metrics from. Find valid values as the heading on [Supported Metrics with Azure Monitor](https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported). For example: `Microsoft.Cache/redis` or `Microsoft.ContainerService/managedClusters`.                                   |
   | `metrics`       | The metrics to scrape from resources. Find valid values in the Metric column for the `resource_type` on [Supported Metrics with Azure Monitor](https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported). For example: `node_cpu_usage_millicores` for the `Microsoft.ContainerService/managedClusters` resource type. |
   | `regions`       | A list of Azure region name strings. With this field, metrics can be gathered for all resources in the subscription from each region listed and bypass Resource Graph. Cannot be used when `resource_graph_query_filter` is used.                                                                                                                |
4. (Optional) Add the following **Optional properties** in your configuration file using the values for your Azure instance:
   
   Expand table
   
   | Property                      | Value (optional)                                                                                                                                                                                                                                                                                                                         |
   |-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
   | `included_dimensions`         | Includes Dimensions available to a Metric definition on [Supported Metrics with Azure Monitor](https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported). For example: `node` and `nodepool` in the `node_cpu_usage_millicores` metric, for the resource type of `Microsoft.ContainerService/managedClusters`. |
   | `included_resource_tags`      | A list of resource tags to include on the final metrics For example, `node`.                                                                                                                                                                                                                                                             |
   | `resource_graph_query_filter` | A string containing a Kusto query to further filter data from the resource graph API. Cannot be used when `regions` is used.                                                                                                                                                                                                             |

## Restart Grafana Alloy

Run the command appropriate for your platform to restart Grafana Alloy so your changes can take effect.

## Test connection

Click **Test connection** to test that Grafana Alloy is collecting data and sending it to Grafana Cloud.

## View your dashboards and alerts

You can now view:

- [Preconfigured dashboards](/docs/grafana-cloud/monitor-infrastructure/monitor-cloud-provider/azure/azure-alerts/#preconfigured-dashboards)
- [Preconfigured alerts](/docs/grafana-cloud/monitor-infrastructure/monitor-cloud-provider/azure/azure-alerts/#preconfigured-alerts)
