Monitor your Azure services in Grafana
You can monitor Azure services and applications by using Grafana and the included Azure Monitor data source plug-in. The plug-in retrieves data from these Azure services:
Azure Monitor Metrics for numeric time series data from Azure resources.
Azure Monitor Logs for log and performance data from Azure resources that enables you to query by using the powerful Kusto Query Language (KQL). You can use Application Insights log queries to retrieve Application Insights log-based metrics.
- Application Insights log-based metrics to let you analyze the health of your monitored apps. You can use Application Insights log queries in Grafana to use the Application Insights log metrics data.
Azure Monitor Traces to query and visualize distributed tracing data from Application Insights.
Azure Resource Graph to quickly query and identify Azure resources across subscriptions.
You can then display this performance and availability data on your Grafana dashboard.
Use the following steps to set up a Grafana server and build dashboards for metrics and logs from Azure Monitor.
Set up Grafana
To set up Grafana, follow these steps.
Set up Azure Managed Grafana
Azure Managed Grafana is optimized for the Azure environment and works seamlessly with Azure Monitor. You can:
- Manage user authentication and access control by using Microsoft Entra identities.
- Pin charts from the Azure portal directly to Azure Managed Grafana dashboards.
Use this quickstart guide to create an Azure Managed Grafana workspace by using the Azure portal.
Set up Grafana locally
To set up a local Grafana server, download and install Grafana in your local environment.
Sign in to Grafana
Important
Internet Explorer and the older Microsoft Edge browsers aren't compatible with Grafana. You must use a chromium-based browser including Microsoft Edge. For more information, see Supported web browsers for Grafana.
Sign in to Grafana by using the endpoint URL of your Azure Managed Grafana workspace or your server's IP address.
Configure an Azure Monitor data source plug-in
Azure Managed Grafana includes an Azure Monitor data source plug-in. By default, the plug-in is preconfigured with a managed identity that can query and visualize monitoring data from all resources in the subscription in which the Grafana workspace was deployed. Skip ahead to the section "Build a Grafana dashboard."
You can expand the resources that can be viewed by your Azure Managed Grafana workspace by configuring additional permissions to assign the included managed identity the Monitoring Reader role on other subscriptions or resources.
If you're using an instance that isn't Azure Managed Grafana, you have to set up an Azure Monitor data source.
Select Add data source, filter by the name Azure, and select the Azure Monitor data source.
Pick a name for the data source and choose between managed identity or app registration for authentication.
If you're hosting Grafana on your own Azure Virtual Machines or Azure App Service instance with managed identity enabled, you can use this approach for authentication. However, if your Grafana instance isn't hosted on Azure or doesn't have managed identity enabled, you need to use app registration with an Azure service principal to set up authentication.
Use managed identity
Enable managed identity on your VM or App Service instance and change the Grafana server managed identity support setting to true.
The managed identity of your hosting VM or App Service instance needs to have the Monitoring Reader role assigned for the subscription, resource group, or resources of interest.
You also need to update the setting
managed_identity_enabled = true
in the Grafana server config. For more information, see Grafana configuration. After both steps are finished, you can then save and test access.
Select Save & test and for Grafana to test the credentials. You should see a message similar to the following one.
Use app registration
Create a service principal. Grafana uses a Microsoft Entra service principal to connect to Azure Monitor APIs and collect data. You must create, or use an existing service principal, to manage access to your Azure resources:
See Create a Microsoft Entra app and service principal in the portal to create a service principal. Copy and save your tenant ID (Directory ID), client ID (Application ID), and client secret (Application key value).
View Assign application to role to assign the Monitoring Reader role to the Microsoft Entra application on the subscription, resource group, or resource you want to monitor.
Provide the connection details you want to use:
- When you configure the plug-in, you can indicate which Azure Cloud you want the plug-in to monitor: Public, Azure US Government, Azure Germany, or Microsoft Azure operated by 21Vianet.
Note
Some data source fields are named differently than their correlated Azure settings:
- Tenant ID is the Azure Directory ID.
- Client ID is the Microsoft Entra Application ID.
- Client Secret is the Microsoft Entra Application key value.
- When you configure the plug-in, you can indicate which Azure Cloud you want the plug-in to monitor: Public, Azure US Government, Azure Germany, or Microsoft Azure operated by 21Vianet.
Select Save & test and for Grafana to test the credentials. You should see a message similar to the following one.
Use out-of-the-box dashboards
Azure Monitor contains out-of-the-box dashboards to use with Azure Managed Grafana and the Azure Monitor plugin. You can find a list of all available dashboards on Grafana Labs.
Azure Monitor also supports out-of-the-box dashboards for seamless integration with Azure Monitor managed service for Prometheus. These dashboards are automatically deployed to Azure Managed Grafana when linked to Azure Monitor managed service for Prometheus.
Build a Grafana dashboard
Go to the Grafana home page and select New Dashboard.
In the new dashboard, select Add visualization and choose the Azure Monitor data source. You can try other charting options, but this article uses Time series as an example.
An empty Time series panel shows up on your dashboard.
Edit the panel to configure your query.
Visualize Azure Monitor metric data: A list of selectors shows up where you can select the service and resource to monitor in this chart. To view metrics from a VM, leave the default Metrics selection, select Resource to choose a VM, use the dropdowns provided to choose the namespace, metric, and aggregation. After you select VM and metrics, you can start viewing the data in the dashboard.
Visualize Azure Monitor log data: Select Logs in the service dropdown list. Select the resource or workspace you want to query, toggle the Time Range to Dashboard and set the query text. You can copy here any log query you already have or create a new one. As you enter your query, IntelliSense suggests autocomplete options. Select the visualization type, Time series > Table, and run the query.
Note
The plugin can also use time macros such as
$__timeFilter()
and$__interval
. These macros allow Grafana to dynamically calculate the time range and time grain, when you zoom in on part of a chart. You can remove these macros and use a standard time filter, such asTimeGenerated > ago(1h)
, but that means the graph wouldn't support the zoom-in feature.The following dashboard has two charts. The one on the left shows the CPU percentage of two VMs. The chart on the right shows the transactions in an Azure Storage account broken down by the Transaction API type.
Pin charts from the Azure portal to Azure Managed Grafana
In addition to building your panels in Grafana, you can also quickly pin Azure Monitor visualizations from the Azure portal to new or existing Grafana dashboards by adding panels to your Grafana dashboard directly from Azure Monitor. Go to Metrics for your resource. Create a chart and select Save to dashboard, followed by Pin to Grafana. Choose the workspace and dashboard and select Pin to complete the operation.
Features supported with Grafana 11
Azure Managed Grafana includes support for Grafana 11 (preview), which introduces capabilities for basic logs and using exemplars with Azure.
Prerequisites
- An Azure Managed Grafana resource running Grafana version 11.
Basic logs
Basic Logs provide a cost-effective way to manage data storage by allowing you to switch between different table plans based on data usage, see Select a table plan based on data usage in a Log Analytics workspace.
Enable basic logs
- In Grafana, go to Connections > Data sources > Azure Monitor.
- On the Settings tab, toggle the Enable Basic Logs switch to the right (blue is On).
Use basic logs
- Create a new dashboard.
- Below the empty graph, under (Azure Monitor), switch Service to Logs.
- For Resource, select a Log Analytics workspace.
- You can now switch Logs from Analytics to Basic.
Note
Switching to Basic Logs comes with limitations:
- Time range will be Dashboard time. Switching Time range back to Query is not available.
- Basic logs incur per-query costs, see Select a table plan based on data usage in a Log Analytics workspace.
Use exemplars with Azure
In Grafana 11, exemplars can link directly to trace data in Application Insights. This integration allows you to connect Prometheus metric data with detailed traces, providing a more comprehensive view of system performance and behavior. For more information about the trace view in Grafana, see Traces in Explore.
Configure exemplars to point to Azure
- In Grafana, go to Connections > Data sources > Prometheus.
- On the Settings tab under Exemplars, select + Add.
- Toggle the Internal link switch to the right (blue is On).
- Select Azure from the dropdown list.
- Optional: Add a URL Label.
- Save & test your changes.
Note
You can + Add additional exemplars, for example for open source tracing platforms like ZIPKIN or Jaeger.
View exemplars with Azure
- In Grafana, go to Explore.
- Under Metric, select a Prometheus data source.
- Run query to populate the graph.
- In the Options bar, toggle the Exemplars switch to the right (blue is On). This adds data points shown as yellow squares on the x-axis of the graph.
- Hover over a data point to see the context menu showing details like traceID, Value, etc.
- In the context menu, select Azure or the URL Label you gave the exemplar. This opens an Azure panel next to your current Prometheus panel with trace information in the Grafana viewer.
Advanced Grafana features
Grafana offers advanced features:
- Azure Monitor plugin variables - Azure Monitor template variables | Grafana documentation
- Dashboard playlists - Manage playlists | Grafana Cloud documentation
Optional: Monitor other datasources in the same Grafana dashboards
There are many data source plug-ins that you can use to bring these metrics together in a dashboard.
Here are good reference articles on how to use Telegraf, InfluxDB, Azure Monitor managed service for Prometheus, and Docker:
- How to configure data sources for Azure Managed Grafana
- Use Azure Monitor managed service for Prometheus as data source for Grafana using managed system identity
- How to monitor system Metrics with the TICK Stack on Ubuntu 16.04
- A monitoring solution for Docker hosts, containers, and containerized services
Here's an image of a full Grafana dashboard that has metrics from Azure Monitor metrics, logs, and traces combined.
Clean up resources
If you set up a Grafana environment on Azure, you're charged when resources are running whether you're using them or not. To avoid incurring additional charges, clean up the resource group created in this article.
- On the left menu in the Azure portal, select Resource groups > Grafana.
- On your resource group page, select Delete, enter Grafana in the text box, and then select Delete.