MSDN

Azure Documentation

Azure Monitor

Overview

Azure Monitor is a comprehensive solution for collecting, analyzing, and acting on telemetry from your cloud and on‑premises environments. It helps you maximize the performance and availability of your applications and services.

  • Collect metrics and logs from Azure resources, VMs, containers, and custom sources.
  • Analyze data with built‑in workbooks, dashboards, and queries.
  • Set up intelligent alerts and automated remediation.
  • Integrate with Azure Automation, Logic Apps, and third‑party tools.

Metrics

Metrics are numeric values that describe the performance of a resource over time. Azure Monitor automatically collects metrics for most Azure services.

Viewing Metrics in the Portal

  1. Navigate to the resource you want to monitor.
  2. Select Metrics from the left-hand menu.
  3. Choose a metric namespace, metric, aggregation type, and time range.
  4. Pin the chart to your dashboard for continuous monitoring.

Sample Metric Query (Kusto)

Kusto Query
PowerShell
InsightsMetrics
| where Namespace == "Microsoft.Compute/virtualMachines"
| where Name == "Percentage CPU"
| summarize avg(CounterValue) by bin(TimeGenerated, 5m), Computer
| order by TimeGenerated desc
Get-AzMetric -ResourceId $vm.Id `
  -MetricName "Percentage CPU" `
  -TimeGrain "00:05:00" `
  -StartTime (Get-Date).AddHours(-1)

Logs (Azure Log Analytics)

Log Analytics stores and queries structured log data. Use the Kusto Query Language (KQL) to explore logs.

Example Log Query

AzureActivity
| where OperationNameValue == "Microsoft.Compute/virtualMachines/restart/action"
| summarize count() by bin(TimeGenerated, 1h), Caller
| order by TimeGenerated desc

Alerts

Configure alerts to be notified when conditions are met.

Creating a Metric Alert

  1. Open Azure MonitorAlerts+ New alert rule.
  2. Select the target resource and the metric you want to monitor.
  3. Define the condition (e.g., Avg CPU > 80%).
  4. Choose an action group (email, webhook, etc.) and name the alert rule.

Autoscale

Autoscale automatically adjusts compute resources based on demand.

  • Define scale rules using metrics (e.g., CPU > 70%).
  • Set minimum, maximum, and default instance counts.
  • Supported for Virtual Machine Scale Sets, App Service Plans, and Azure Kubernetes Service.

Diagnostic Settings

Diagnostic settings let you route platform logs and metrics to Log Analytics workspaces, Storage accounts, or Event Hubs.

  1. Navigate to the resource → Diagnostic settings.
  2. Click + Add diagnostic setting.
  3. Select the logs and metrics you need and the destination.
  4. Save the configuration.

Pricing

Azure Monitor pricing is based on data ingestion, retention, and alert usage. See the official pricing page for details.

Component Unit Cost (USD)
Metrics (standard) per metric per GB $0.15
Log Data Ingestion per GB $2.30
Alert Rules per rule per month $0.10

Frequently Asked Questions

What is the difference between metrics and logs?

Metrics are numeric time‑series data ideal for monitoring performance trends. Logs are event‑based, semi‑structured data that captures detailed information about operations and diagnostics.

How long are metrics retained by default?

Standard metrics are retained for 93 days. You can archive them to a storage account for longer retention.

Can Azure Monitor monitor on‑premises resources?

Yes. Install the Log Analytics agent on Windows or Linux machines or use Azure Arc to bring on‑premises resources into Azure Monitor.