Tutorials Logic, IN info@tutorialslogic.com

Azure Monitor: Metrics, Logs, Application Insights, and Alerts

Collect the Right Data

Azure Monitor brings together platform metrics, logs, traces, alerts, workbooks, and application telemetry.

Metrics provide efficient numeric time series, Log Analytics stores queryable records, and Application Insights follows application requests, dependencies, exceptions, and traces.

A useful monitoring design starts with user-visible health and service objectives, then links those outcomes to resource saturation, dependencies, deployments, and configuration changes.

Use diagnostic settings to route supported resource logs and metrics to suitable destinations. Configure agents or data collection rules when guest operating-system telemetry is required.

  • Collect data that supports a decision or investigation.
  • Separate platform, application, security, and audit retention needs.
  • Avoid sending secrets or sensitive payloads into logs.

Investigate With KQL and Traces

Kusto Query Language filters, joins, summarizes, and charts records in Log Analytics. Correlation IDs and distributed tracing connect a front-end request to dependencies and background processing.

  • Save queries for recurring incident questions.
  • Use percentiles for latency analysis.
  • Add deployment annotations or version fields to telemetry.

Create Actionable Alerts

Metric, log-search, activity-log, and service-health alerts serve different purposes. Each alert should identify impact, owner, notification route, and response.

  • Choose evaluation windows that avoid noise without hiding fast failures.
  • Use action groups and test every notification channel.
  • Suppress or tune recurring false alarms with a documented reason.

Control Retention and Monitoring Cost

Workspace ingestion, retention, high-cardinality telemetry, and duplicate collection can become significant costs. Review tables, sampling, daily caps, archive needs, and query usage.

  • Set retention by table or data purpose where supported.
  • Remove duplicate diagnostic paths.
  • Keep enough evidence to investigate and meet compliance requirements.

Azure Monitor Data Flow

Azure Monitor receives platform metrics, resource logs, Activity Log records, application telemetry, guest data, Prometheus metrics, and other sources through different collection paths. Metrics enter a time-series store optimized for fast aggregation and alerting; logs enter Log Analytics workspaces for Kusto Query Language analysis. Do not assume enabling one automatically captures the other.

Start from a critical user flow and define availability, latency, correctness, throughput, and freshness indicators. Then map resource and dependency signals that explain those outcomes. Platform CPU or request count is supporting evidence, not a substitute for measuring whether users completed the operation successfully.

Record subscription, resource ID, Region, application, environment, release, and correlation context consistently. Use resource-centric and workspace-centric views deliberately. A central workspace improves cross-resource investigation but also creates access, retention, residency, ingestion, and query-cost decisions.

  • Choose metrics and logs for different questions.
  • Define user-focused service indicators first.
  • Carry correlation identity through asynchronous work.
  • Design workspace boundaries for access and residency.

Diagnostic Settings and Collection Rules

Resource diagnostic settings route supported log categories and metrics to destinations such as Log Analytics, Storage, Event Hubs, or partners. Category support differs by resource provider and can evolve. Select categories from audit and operational needs, verify delivery, and deploy settings through Policy or infrastructure code where broad consistency is required.

Data collection rules define selected collection, transformation, and destinations for agents and modern telemetry paths. Scope them carefully so one rule does not duplicate or drop data unexpectedly. Track which resource association owns each stream and test a known record after every change.

The Activity Log records control-plane events at subscription scope and needs export for longer or centralized retention. Data-plane access needs service-specific logs. Store immutable or long-retention evidence outside the same administrator boundary when the threat model requires it, and protect workspace query access because logs can contain sensitive business context.

  • Enable only categories tied to an evidence requirement.
  • Verify destination delivery with a known event.
  • Use Policy carefully for broad diagnostic rollout.
  • Separate control-plane and data-plane audit sources.

Application Insights and Traces

Application Insights provides application performance monitoring over requests, dependencies, exceptions, traces, availability tests, and application metrics. Instrument with the supported Azure Monitor OpenTelemetry distribution or current SDK path for the application stack, and preserve W3C trace context across HTTP, queues, and background processing.

Sampling controls volume and cost but changes analysis. Keep head or tail strategy, error preservation, and metric accuracy explicit. Standard preaggregated metrics and log-based metrics behave differently under sampling. Do not place secrets, full tokens, sensitive query strings, or unrestricted payloads in span attributes and custom dimensions.

Name operations and dependencies consistently, publish deployment markers, and keep release identity visible. Test one request across edge, application, database, queue, and worker so an operator can follow it without searching by human prose. Use live diagnostics only as a supplement to retained evidence.

  • Propagate trace context through queues and services.
  • Document how sampling changes analysis.
  • Redact telemetry before ingestion.
  • Connect every trace to a deployed release.

Metric and Log Alerts

Metric alerts evaluate numeric time series with aggregation, dimensions, frequency, and window. Log search alerts evaluate a KQL result and inherit query, ingestion, and scheduling behavior. Activity Log alerts respond to control-plane event categories. Choose the alert type whose data arrives quickly and reliably enough for the response objective.

Define missing-data, low-traffic, and dimension behavior. Dynamic thresholds can model established patterns, while static thresholds are often clearer for hard capacity or correctness limits. Processing rules can suppress or route alerts during planned conditions, but suppression needs scope, reason, owner, and expiry.

Action groups deliver notifications and automation. Test every receiver, authentication path, escalation, and fallback. Include impact, resource, environment, release, dashboard, and runbook in the alert context. An alert is actionable only when the recipient has authority and evidence to respond.

  • Match alert type to the source and response deadline.
  • Define no-data behavior explicitly.
  • Expire planned suppression rules.
  • Exercise action-group delivery end to end.

Health and Change Signals

Azure Service Health communicates incidents, planned maintenance, health advisories, and selected service events relevant to subscriptions. Resource Health describes the state of individual supported resources. Neither replaces application telemetry: a service can be healthy while configuration or code breaks users, and a broad incident can explain several application alarms at once.

Activity Log and change analysis help identify resource configuration changes. Correlate deployment IDs, Policy remediation, role assignments, network changes, feature flags, and platform health with the first failing request. Record timestamps in UTC and preserve correlation IDs from Azure error responses.

Create dashboards for user flow, dependency health, capacity, recent changes, and recovery state rather than one crowded inventory. During an incident, move from impact to changed dependency and exact request. Afterward, convert the failure into a query, test, alert, or runbook improvement.

  • Correlate platform health with workload symptoms.
  • Mark deployments and Policy remediation on timelines.
  • Preserve Azure correlation IDs.
  • Turn incidents into monitored failure conditions.

Telemetry Cost and Failure Drill

Azure Monitor cost can come from ingestion, retention, archive, search, export, custom metrics, managed Prometheus, availability tests, alert rules, and network movement. Attribute volume to tables and resources, remove low-value verbose data, control high-cardinality dimensions, and choose retention by operational and legal need. Do not cut audit evidence blindly.

Inject a controlled application exception, slow dependency, denied Resource Manager request, failed queue message, and broken telemetry destination. Confirm alerts, traces, KQL queries, Activity Log evidence, redaction, escalation, and retention. Test that an operator can identify the principal, release, resource, and customer impact without subscription Owner access.

After changing collection or sampling, repeat the drill. Observability is complete only when useful evidence survives the failure modes it is meant to diagnose and the team can afford to retain and query it at expected scale.

  • Attribute ingestion and retention by source.
  • Preserve security and recovery evidence.
  • Test the monitoring path as a production dependency.
  • Revalidate diagnosis after reducing telemetry.

SLO and Error Budget Alerts

A service-level objective should use an indicator calculated from user-relevant events, such as successful eligible requests within a latency threshold. Define which requests count, which exclusions are justified, the rolling window, target, and data source. Keep the query or metric in version control and validate it against known successful and failed transactions.

An error budget is the amount of unsuccessful service allowed by the objective. Multi-window burn-rate alerts can detect both rapid exhaustion and slow sustained degradation more reliably than one static error threshold. Route a fast burn to immediate response and a slower burn to planned corrective work, with enough traffic safeguards to avoid misleading tiny samples.

Use the budget to guide release and reliability decisions rather than to punish teams or hide outages through exclusions. Review every objective after architecture, traffic, or telemetry changes, and keep a fallback signal when the primary measurement pipeline fails.

  • Define eligible events and success precisely.
  • Alert on fast and slow budget consumption.
  • Protect low-volume services from noisy ratios.
  • Version and test the objective calculation.

Azure Monitor Examples

List Metric Definitions for a Resource

List Metric Definitions for a Resource
az monitor metrics list-definitions \
  --resource /subscriptions/<sub-id>/resourceGroups/rg-app/providers/Microsoft.Web/sites/orders-api \
  --output table

Correlate One Request Across Services

An API intermittently times out while downstream services appear healthy in aggregate.

Correlate One Request Across Services
Constraints: Telemetry must share trace context and avoid recording secrets or request bodies.
Decision: Follow one operation ID through Application Insights dependencies, exceptions, logs, and the responsible resource metrics.
Verification: The trace identifies the slow dependency and a focused alert reproduces during a controlled delay.
Failure test: Remove trace propagation in a test deployment and confirm the observability test detects the broken chain.
Output
Expected evidence: The trace identifies the slow dependency and a focused alert reproduces during a controlled delay.
  • This is a worked engineering decision, so the result is operational evidence rather than terminal output.
Before you move on

Azure Monitor: Metrics, Logs, Application Insights, and Alerts Mastery Check

5 checks
  • Telemetry covers traffic, errors, latency, and saturation.
  • Diagnostic settings send required data to known destinations.
  • KQL and trace correlation support common investigations.
  • Every alert has an owner and tested action group.
  • Ingestion and retention costs are reviewed.
Browse Free Tutorials

Explore 500+ free tutorials across 20+ languages and frameworks.