Lesson 1 of 4 Logging and Monitoring Solutions

Understanding Telemetry in Azure Monitor

This lesson explains the types, sources and stores of monitoring data.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe metrics, logs, traces and change data.
  • Distinguish the activity log from resource logs.
  • Distinguish a Log Analytics workspace from an Azure Monitor workspace.
  • Explain the roles of diagnostic settings and data collection rules.

What Azure Monitor is

Azure Monitor is not a single dashboard but a platform with three stages. It collects telemetry from applications, operating systems, Azure resources, subscriptions and the tenant. It stores that telemetry in data stores that suit each type of data. It then lets people and automation consume the data through queries, visualizations, alerts and integrations. Many Azure features that appear to be separate products, such as VM insights and Application Insights, are built on this platform and store their data in it.

Azure Monitor collects some data automatically and at no charge, whereas other data must be configured. This distinction is important for design, because a learner who assumes that everything is logged by default will produce a design with no evidence available after an incident.

Types of telemetry

Monitoring data falls into a small number of types, each of which answers a different question.

Metrics

Metrics are numeric values measured at regular intervals, such as CPU percentage or request count. They are lightweight and near real time, so they are well suited to fast alerting and to autoscale rules. Platform metrics are collected automatically for Azure resources and retained for 93 days. Metrics show that something changed, but they rarely explain why.

Logs

Logs are records with varying structure, such as an error message or a sign-in event. They contain detail that metrics cannot carry, and they are queried with Kusto Query Language (KQL). Logs answer questions such as which user performed an action, or which error preceded a failure.

Traces

Distributed traces follow a single request across components, recording how long each dependency took. They answer the question of where a slow transaction spent its time, which is difficult to determine from separate logs when a request passes through several services.

Changes

Change data records what was altered on resources and when. Azure Resource Graph holds resource change history, and comparing the time of a change with the start of a problem is often the fastest way to find the cause of an incident.

Sort into groups

Which telemetry answers it?

Exam skills 1.1.3

Decide which type of telemetry best answers each operational question.

Log in to try this activity Interactive activities are free with an account.

Sources of monitoring data

It helps to think of telemetry sources as layers, from the tenant at the top to the application code at the bottom. The layers differ in what they contain and in whether collection is automatic.

  • Microsoft Entra logs record tenant activity, including sign-ins and directory changes.
  • The activity log records control plane operations in a subscription, such as who deleted a resource or changed a setting. It is collected automatically and kept for 90 days.
  • Resource logs record operations inside a resource, such as reads from a storage account or queries against a database. They are not collected until a diagnostic setting is created.
  • Guest operating system data includes performance counters, Windows events and syslog inside a virtual machine. Azure cannot see inside a guest without an agent, so the Azure Monitor Agent is required.
  • Application telemetry includes requests, dependencies, exceptions and traces, collected by instrumenting the application with OpenTelemetry through Application Insights.

A common design trap is to confuse the activity log with resource logs. A question asking who changed a key vault's firewall is answered by the activity log, because that is a control plane action. A question asking who read a particular secret is answered by resource logs, because that is a data plane action, and those logs exist only if a diagnostic setting was configured beforehand.

The following diagram shows which log answers each of two audit questions about a production key vault: who changed its network rules, and who read its secrets.

Which log answers each audit question for a production key vault. Changes to the network rules are control plane actions that the activity log records automatically, but only for 90 days, so it must be exported to reach a year. Reads of secrets are data plane operations that appear only in resource logs, which a diagnostic setting must enable.
The scenario is illustrative.

Data stores

Azure Monitor keeps different data in different stores, and a design often needs more than one of them.

Log Analytics workspace

A Log Analytics workspace is the store for log data, and it is queried with KQL. It holds resource logs, guest logs, Application Insights telemetry and security data, organized into tables. Most logging decisions in AZ-305 concern how many workspaces to create and how their tables are configured.

Azure Monitor Metrics

The metrics store is a time-series database for platform metrics and is viewed in Metrics Explorer. Resources write to it automatically, so it needs no configuration.

Azure Monitor workspace

An Azure Monitor workspace stores Prometheus metrics and OpenTelemetry metrics, and is queried with PromQL. Despite the similar name, it is not a Log Analytics workspace. It is the normal store for container metrics collected from Azure Kubernetes Service clusters.

The following comparison summarizes the two workspace types, whose names are easily confused.

Log Analytics workspace
Data heldLogs and log-based telemetry
Query languageKusto Query Language (KQL)
Typical visualizationLog Analytics, workbooks
Typical sourceDiagnostic settings, Azure Monitor Agent
Choose when Investigating events and detailed records
Azure Monitor workspace
Data heldPrometheus and OpenTelemetry metrics
Query languagePromQL
Typical visualizationAzure Managed Grafana
Typical sourceManaged Prometheus on Kubernetes clusters
Choose when Metrics for containerized workloads
Sort into groups

Which workspace?

Exam skills 1.1.1

Decide which Azure Monitor store holds each kind of data.

Log in to try this activity Interactive activities are free with an account.

How data is collected

Two mechanisms account for most configured collection. A diagnostic setting is attached to an Azure resource and sends its resource logs and metrics to one or more destinations. A data collection rule (DCR) defines what to collect, how to transform it and where to send it, and is used by the Azure Monitor Agent and by the Logs ingestion API.

The Azure Monitor Agent is the supported agent for collecting guest operating system data, and it replaces the legacy Log Analytics agent. It runs on Azure virtual machines and, through Azure Arc, on servers outside Azure. Because a DCR is a separate resource associated with machines, one rule can apply a consistent collection policy to many servers, and one server can use different rules to send different data to different workspaces.

Azure Policy is often used to apply these settings at scale. Built-in policy initiatives can deploy the agent, associate data collection rules and create diagnostic settings on new resources, so monitoring coverage does not depend on each team remembering to configure it. The sequence below shows the path of a typical log record from its source to an alert.

True or false

Collection mechanisms

Exam skills 1.1.1

Check how diagnostic settings, data collection rules and the agent work.

Log in to try this activity Interactive activities are free with an account.

The path of a log record

The stages below show how a resource log travels through the platform, using a Key Vault audit event as the example.

  1. A resource emits an event

    An application reads a secret from Key Vault, and the service produces an audit event.

  2. A diagnostic setting selects it

    The diagnostic setting on the vault includes the audit log category and names a destination.

  3. The workspace stores it

    The record arrives in a table in the Log Analytics workspace.

  4. A query or alert consumes it

    A log search alert runs a KQL query on a schedule and notifies an action group when its condition is met.

Worked example

Identifying the correct data source

An auditor requires a record of each person who read secrets from a production key vault over the last year, and a record of each change to the vault's network rules. No monitoring has been configured beyond the defaults. Which data sources are required, and what must be configured?

The two requirements fall on different planes. Changing network rules is a control plane action, which the activity log records automatically; however, the activity log keeps data for only 90 days, so it must be sent to a Log Analytics workspace or a storage account to reach one year. Reading a secret is a data plane action, recorded only in resource logs.

The design therefore creates a subscription-level diagnostic setting that exports the activity log, and a diagnostic setting on the key vault that sends the audit category to the same destination, with retention configured for at least a year. Neither metrics nor the Azure Monitor Agent help here, because metrics do not identify individuals and the agent collects from inside virtual machines, not from a platform service such as Key Vault.

Check yourself

Which log shows who deleted a virtual machine yesterday, and must anything be configured first?

Show answer

The activity log, which records control plane operations automatically for 90 days. No configuration is needed unless retention beyond 90 days is required.

Exam Tips

Remember for the exam

  • Activity log: control plane, automatic, 90 days. Resource logs: data plane, require a diagnostic setting.
  • Guest operating system data requires the Azure Monitor Agent and a data collection rule.
  • Log Analytics workspace uses KQL; Azure Monitor workspace uses PromQL for Prometheus metrics.
  • Platform metrics are automatic and retained for 93 days.