docs/sources/datasources/azure-monitor/alerting/index.md
The Azure Monitor data source supports Grafana Alerting and Grafana-managed recording rules, allowing you to create alert rules based on Azure metrics, logs, traces, and resource data. You can monitor your Azure environment and receive notifications when specific conditions are met.
All Azure Monitor query types support alerting and recording rules:
| Query type | Use case | Notes |
|---|---|---|
| Metrics | Threshold-based alerts on Azure resource metrics | Best suited for alerting; returns time-series data |
| Logs | Alert on log patterns, error counts, or thresholds | Use KQL to aggregate data into numeric values |
| Azure Resource Graph | Alert on resource state or configuration changes | Use count aggregations to return numeric data |
| Traces | Alert on trace data and application performance | Use aggregations to return numeric values for evaluation |
{{< admonition type="note" >}} Alert queries must return numeric data that Grafana can evaluate against a threshold. Queries that return only text or non-numeric data cannot be used directly for alerting. {{< /admonition >}}
Alerting and recording rules run as background processes without a user context. This means they require service-level authentication and don't work with all authentication methods.
| Authentication method | Supported |
|---|---|
| App Registration (client secret) | ✓ |
| Managed Identity | ✓ |
| Workload Identity | ✓ |
| Current User | ✓ (with fallback service credentials) |
{{< admonition type="note" >}} If you use Current User authentication, you must configure fallback service credentials for alerting and recording rules to function. User credentials aren't available for background operations, so Grafana uses the fallback credentials instead. Refer to configure the data source for details on setting up fallback credentials. {{< /admonition >}}
To create an alert rule using Azure Monitor data:
For detailed instructions, refer to Create a Grafana-managed alert rule.
This example creates an alert that fires when virtual machine CPU usage exceeds 80%:
Microsoft.Compute/virtualMachinesPercentage CPUAverageThis example alerts when error logs exceed a threshold using a KQL query:
AppExceptions
| where TimeGenerated > ago(5m)
| summarize ErrorCount = count() by bin(TimeGenerated, 1m)
This example alerts when the number of running virtual machines drops below a threshold using Azure Resource Graph:
Create a new alert rule.
Configure the query:
Service: Azure Resource Graph
Subscriptions: Select your subscriptions
Query:
resources
| where type == "microsoft.compute/virtualmachines"
| where properties.extended.instanceView.powerState.displayStatus == "VM running"
| summarize RunningVMs = count()
Add expressions:
Set evaluation to run every 5 minutes.
Save the rule.
Follow these recommendations to create reliable and efficient alerts with Azure Monitor data.
When your Azure Monitor query returns multiple time series (for example, CPU usage across multiple VMs), use the Reduce expression to aggregate them:
For Logs queries used in alerting:
summarize to aggregate data into numeric values.ago() or TimeGenerated.Configure what happens when no data is returned:
Always verify your query returns expected data before creating an alert:
If your Azure Monitor alerts aren't working as expected, use the following sections to diagnose and resolve common issues.
If you see authentication errors when alerts evaluate:
For additional troubleshooting help, refer to Troubleshoot Azure Monitor.