Skip to content

Lab 24: Collect telemetry and configure actionable alerts

Previous: Lab 23 · Catalog · Next: Lab 25

Scenario, role, and outcome

The team can deploy an app but has no owned telemetry store or actionable latency rule. Connect workspace-based telemetry and create a silent training alert.

Learner role: Observability engineer. Outcome: Collect telemetry and configure actionable alerts.

Item Value
Time 120 minutes
Domain instrumentation
Platforms local, azure
Cost billable; explicit acknowledgement — review current pricing and cleanup before cloud execution
Exam blueprint July 27, 2026; sources reviewed October 16, 2026
Verification status offline-tested
Verification scope All five checkpoint commands, final validators and named fault/repair passed in CourseScanMonitorSequences.Tests.ps1. Local .NET package inventory/advisory queries and Gitleaks scans are real. GitHub/Azure APIs and Docker/Trivy reports are explicit fixtures; live security integration and alert delivery have not run. Repository CI separately runs the actual application container.

Completion requires all five checkpoints, the break/fix repair, successful independent validation, and a passing residual-resource audit. An unavailable external prerequisite is a visible gate; it does not become a passing result.

Architecture and service topology

Lab 24 service architecture: Workspace-based telemetry and a silent metric alert

The Application Insights component is actually linked to the owned Log Analytics workspace. Provider metric definitions supply the latency name/unit before the alert rule is created. The rule has no external action group and sends no messages. Emitting sample telemetry and proving a firing transition are separate integration gates; configured resources alone do not establish live ingestion.

The editable Mermaid source and accessible SVG render the same authored components and relationships. Dashed connections show separately gated integrations. Read every boundary before executing commands. Cloud changes stay inside the exact disposable GitHub repository, Azure DevOps project, and Azure resource group recorded for this run. Child objects inherit that cleanup boundary. Account creation, external integrations, and privileged organization settings belong to one-time bootstrap.

Objectives and checkpoints

Coverage levels describe the intended learning evidence: explained means reasoned understanding, practiced means an observable isolated skill, and integrated means skills connected across a delivery boundary. These labels are curriculum claims, not execution status. Verification above records what authors actually ran.

Official objective topic IDs: D1.2.7, D5.1.1, D5.1.2, D5.1.3, D5.1.4

Checkpoint Measurable behavior
CP1 Create the owned Log Analytics workspace
CP2 Connect a workspace-based Application Insights component
CP3 Inspect supported metric names before selecting alerts
CP4 Create a silent sandbox response-time alert
CP5 Evaluate owned telemetry response decisions

The objective map traces every official topic to labs. The Microsoft study guide controls authoritative objective wording and domain weighting.

Inputs, permissions, and read-only preflight

Use PowerShell 7.4+, .NET 10, Git, GitHub CLI, Azure CLI with the Azure DevOps extension, and the pinned repository validation dependencies. Read the permissions matrix and evidence policy. Supply only the accounts needed by this lab. Never put a token, connection string, or private key into a command log, committed YAML, or progress export.

The examples run from the repository root. Choose a fresh lowercase run ID; demo01 is an example, not a reusable shared sandbox. Set bootstrap environment variables for the approved GitHub owner, DevOps organization, subscription, and region. Do not run both guided and automated lanes with the same run ID.

$lab = './labs/24-monitoring-alerts/scripts/cli'
& "$lab/Preflight.ps1" -RunId 'demo01'
& "$lab/Setup.ps1" -RunId 'demo01' -ProvisionOnly
# After reviewing context, permissions, cost, and cleanup:
& "$lab/Setup.ps1" -RunId 'demo01' -ProvisionOnly -Execute -AcknowledgeCost -AcknowledgeTenantChange
. "$lab/Context.ps1" -RunId 'demo01'

Preflight performs reads only. Provisioning creates fresh run-owned top-level sandboxes and records their exact IDs. Context establishes $RepoRoot, $LabRoot, $WorkRoot, $RunId, $GhRepo, $AdoOrganization, $AdoProject, $SubscriptionId, $Location, and $ResourceGroup. A missing prerequisite or ownership mismatch must stop execution. Local build commands may restore packages and write ignored build output.

Concept primer and design decisions

A workspace, instrumentation, ingestion, query, and alert action are separate links. A configured rule without telemetry proves configuration only; no external notifications are sent here.

Telemetry requires a chain from instrumentation to ingestion, workspace, query and response. Creating a workspace and Application Insights component proves configuration only. A silent metric alert avoids sending external messages while making its threshold, scope and enabled state inspectable.

Choose response actions around an owner and measurable service objective. Pipeline events, runner consumption and application request latency belong to different signals; GitHub insights or a delivery-failure notification needs its own explicit configuration. The capstone generates tagged requests and requires observed request/error/latency data, so missing telemetry cannot pass as a healthy release.

Task 1 — Create the owned Log Analytics workspace

Checkpoint: CP1

Foundation/supporting task; no additional exam-objective coverage is claimed.

$name="logs-$RunId"
 $w=az monitor log-analytics workspace create --subscription $SubscriptionId --resource-group $ResourceGroup --workspace-name $name --location $Location --retention-time 30 --sku PerGB2018 -o json|ConvertFrom-Json
 $w|ConvertTo-Json -Depth 8|Set-Content (Join-Path $WorkRoot 'workspace.json')

Expected state: A30-day workspace exists in the owned group; ingestion pricing still applies.

Positive validation:

$w=az monitor log-analytics workspace show --subscription $SubscriptionId --resource-group $ResourceGroup --workspace-name "logs-$RunId" -o json|ConvertFrom-Json
 if($w.retentionInDays -ne 30){throw 'Workspace retention mismatch.'}

Negative validation:

$w=Get-Content (Join-Path $WorkRoot 'workspace.json') -Raw|ConvertFrom-Json
 if($w.id -notlike "*/resourceGroups/$ResourceGroup/*"){throw 'Workspace escaped owned group.'}

Evidence to retain: Workspace ID locally, retention, pricing tier, and ingestion budget.

Common failure and safe retry: Review current workspace billing and approved region; avoid ingesting production/private payloads.

Cleanup dependency: retain this checkpoint's evidence until final validation; remove run-owned children before their recorded parent boundary.

Task 2 — Connect a workspace-based Application Insights component

Checkpoint: CP2

Objective Evidence level Observation and limits
D5.1.1 integrated Create and query the run-owned Azure Monitor/Application Insights resources.
D5.1.2 practiced Inspect the actual telemetry component/workspace linkage.
$w=Get-Content (Join-Path $WorkRoot 'workspace.json') -Raw|ConvertFrom-Json
 az monitor app-insights component create --subscription $SubscriptionId --resource-group $ResourceGroup --app "insights-$RunId" --location $Location --workspace $w.id --kind web --application-type web -o json|Set-Content (Join-Path $WorkRoot 'insights.json')

Expected state: Application Insights is explicitly connected to the owned workspace.

Positive validation:

$i=az monitor app-insights component show --subscription $SubscriptionId --resource-group $ResourceGroup --app "insights-$RunId" -o json|ConvertFrom-Json
 $w=Get-Content (Join-Path $WorkRoot 'workspace.json') -Raw|ConvertFrom-Json
 if($i.workspaceResourceId -ne $w.id){throw 'Insights workspace linkage mismatch.'}

Negative validation:

$i=Get-Content (Join-Path $WorkRoot 'insights.json') -Raw|ConvertFrom-Json
 if($i.id -notlike "*/resourceGroups/$ResourceGroup/*"){throw 'Insights escaped owned group.'}

Evidence to retain: Component/workspace linkage; redact instrumentation/connection values.

Common failure and safe retry: Install the pinned application-insights extension during bootstrap; do not auto-install inside read-only preflight.

Cleanup dependency: retain this checkpoint's evidence until final validation; remove run-owned children before their recorded parent boundary.

Task 3 — Inspect supported metric names before selecting alerts

Checkpoint: CP3

Foundation/supporting task; no additional exam-objective coverage is claimed.

$i=Get-Content (Join-Path $WorkRoot 'insights.json') -Raw|ConvertFrom-Json
 az monitor metrics list-definitions --subscription $SubscriptionId --resource $i.id --query '[].{name:name.value,unit:unit,aggregation:primaryAggregationType}' -o json|Set-Content (Join-Path $WorkRoot 'metric-definitions.json')

Expected state: The resource provider defines actual available metric names and units.

Positive validation:

$m=@(Get-Content (Join-Path $WorkRoot 'metric-definitions.json') -Raw|ConvertFrom-Json)
 if('requests/duration' -notin $m.name){throw 'Expected request-duration metric unavailable; stop before creating alert.'}

Negative validation:

$m=@(Get-Content (Join-Path $WorkRoot 'metric-definitions.json') -Raw|ConvertFrom-Json)
 if(@($m|Where-Object { -not $_.name }).Count){throw 'Metric definition missing canonical name.'}

Evidence to retain: Metric name/unit/aggregation; no inference of live application traffic.

Common failure and safe retry: Use the metric definition unit; avoid applying a millisecond threshold to a count or percent.

Cleanup dependency: retain this checkpoint's evidence until final validation; remove run-owned children before their recorded parent boundary.

Task 4 — Create a silent sandbox response-time alert

Checkpoint: CP4

Foundation/supporting task; no additional exam-objective coverage is claimed.

$i=Get-Content (Join-Path $WorkRoot 'insights.json') -Raw|ConvertFrom-Json
 az monitor metrics alert create --subscription $SubscriptionId --resource-group $ResourceGroup --name "slow-requests-$RunId" --scopes $i.id --condition 'avg requests/duration > 1000' --window-size 5m --evaluation-frequency 1m --severity 3 --description "Run $RunId training alert; no external notification action" -o json|Set-Content (Join-Path $WorkRoot 'alert.json')

Expected state: A5-minute latency rule exists without action groups or messages to external recipients.

Positive validation:

$a=az monitor metrics alert show --subscription $SubscriptionId --resource-group $ResourceGroup --name "slow-requests-$RunId" -o json|ConvertFrom-Json
 if(-not $a.enabled -or $a.windowSize -ne 'PT5M'){throw 'Latency alert disabled or wrong window.'}

Negative validation:

$a=Get-Content (Join-Path $WorkRoot 'alert.json') -Raw|ConvertFrom-Json
 if(@($a.actions).Count -gt 0){throw 'This training alert must not notify external recipients.'}

Evidence to retain: Alert condition/window/severity and empty action list.

Common failure and safe retry: No telemetry means no proof of firing behavior; use an approved synthetic workload for the optional integration test.

Cleanup dependency: retain this checkpoint's evidence until final validation; remove run-owned children before their recorded parent boundary.

Task 5 — Evaluate owned telemetry response decisions

Checkpoint: CP5

Objective Evidence level Observation and limits
D1.2.7 explained Interpret the operations dashboard and service objective; synthetic workload verification is distinct from live traffic.
D5.1.3 explained Compare GitHub usage/runner insights with service telemetry; no organization insight dashboard is configured.
D5.1.4 explained Design a delivery-event alert separately from the actual latency metric alert configured in CP4.
$map=[ordered]@{application='request duration/error rate';infrastructure=@('CPU','memory','disk','network');github='workflow_run completion and repository insights';azurePipelines='build/release result';notificationMode='reviewed owner only';externalMessagesSent=0;liveTrafficVerified=$false}
 $map|ConvertTo-Json|Set-Content (Join-Path $WorkRoot 'telemetry-response-map.json')
$events=@(@{id='owned-slow';resourceGroup=$ResourceGroup;requests=12;averageMs=1200},@{id='owned-fast';resourceGroup=$ResourceGroup;requests=20;averageMs=200},@{id='foreign-slow';resourceGroup='another-group';requests=100;averageMs=2000})
$decisions=@($events|ForEach-Object {@{id=$_.id;action=$(if($_.resourceGroup -ne $ResourceGroup){'exclude-unowned'}elseif($_.requests -gt 0 -and $_.averageMs -gt 1000){'investigate-latency'}else{'observe'});sent=$false}})
$decisions|ConvertTo-Json|Set-Content (Join-Path $WorkRoot 'response-decisions.json')

Expected state: Three synthetic observations yield investigate-latency, observe, and exclude-unowned decisions. No notification is sent; external alert delivery remains unverified.

Positive validation:

$m=Get-Content (Join-Path $WorkRoot 'telemetry-response-map.json') -Raw|ConvertFrom-Json
 if($m.infrastructure.Count -ne 4 -or $m.github -notmatch 'workflow_run'){throw 'Telemetry signal map incomplete.'}

$d=@(Get-Content (Join-Path $WorkRoot 'response-decisions.json') -Raw|ConvertFrom-Json)
if(@($d|Where-Object action -eq 'investigate-latency').Count -ne 1 -or @($d|Where-Object action -eq 'exclude-unowned').Count -ne 1){throw 'Owned response routing did not distinguish slow, healthy and unowned events.'}

Negative validation:

$m=Get-Content (Join-Path $WorkRoot 'telemetry-response-map.json') -Raw|ConvertFrom-Json
 if($m.externalMessagesSent -ne 0 -or $m.liveTrafficVerified){throw 'Design review cannot claim traffic/notification verification.'}

if(@(Get-Content (Join-Path $WorkRoot 'response-decisions.json') -Raw|ConvertFrom-Json|Where-Object sent).Count){throw 'Offline routing must not send notifications.'}

Evidence to retain: Response map and computed response-decisions.json for slow, healthy and foreign resource observations.

Common failure and safe retry: Configure VM/Container/Storage/Network Insights only for approved owned resources; avoid collecting credentials or personal request bodies.

Cleanup dependency: retain this checkpoint's evidence until final validation; remove run-owned children before their recorded parent boundary.

Deterministic break/fix

Run the journaled operation after all five checkpoints. It proves the healthy assertion, injects the named fault, requires its rejection, repairs it, and proves health again. Provider doubles used in author tests are not live enforcement evidence.

& './labs/24-monitoring-alerts/scripts/cli/BreakFix.ps1' -RunId 'demo01' -Execute

Expected rejection marker: AZ400-L24-FAULT. The assertion must catch the changed behavior, not merely an exception from an unavailable CLI.

Inspect the independent assertion:

$a=az monitor metrics alert show --subscription $SubscriptionId --resource-group $ResourceGroup --name "slow-requests-$RunId" -o json|ConvertFrom-Json
if(-not $a.enabled){throw 'AZ400-L24-FAULT'}

Fault trigger (executed by BreakFix):

az monitor metrics alert update --subscription $SubscriptionId --resource-group $ResourceGroup --name "slow-requests-$RunId" --enabled false -o none

Diagnose the precise difference:

az monitor metrics alert show --subscription $SubscriptionId --resource-group $ResourceGroup --name "slow-requests-$RunId" --query '{enabled:enabled,window:windowSize}' -o json

Repair (executed by BreakFix):

az monitor metrics alert update --subscription $SubscriptionId --resource-group $ResourceGroup --name "slow-requests-$RunId" --enabled true -o none

Optional job-style challenge

Emit an approved synthetic trace/request through the sample and demonstrate the alert changing state without sending unsolicited Teams/email notifications.

Final validation and result interpretation

& './labs/24-monitoring-alerts/scripts/cli/Validate.ps1' -RunId 'demo01'

A complete result requires five passing read-only checkpoint assertions, a journaled repaired fault, and any required integration evidence. Pending hosted runs, missing licensed features, and unexecuted integration lanes remain visible. Review validation.json; successful command exit alone does not establish the asserted behavior.

Troubleshooting

  • 401/403: inspect the explicit account/project/repository scope and required role; do not broaden a token reflexively.
  • Resource or artifact missing: confirm the exact run ID and prerequisite checkpoint; retry reads after eventual consistency.
  • Unsupported SKU/runtime/tool: consult the specific current source, record the gate, and obtain approval before changing cost or architecture.
  • Validation mismatch: inspect the positive and negative assertions separately, repair the named fault, and rerun validation.
  • Ownership refusal: stop; never edit a manifest to claim an unrelated resource.

Cleanup and residual checks

& './labs/24-monitoring-alerts/scripts/cli/Cleanup.ps1' -RunId 'demo01'
# Review the exact owned-object deletion plan first.
& './labs/24-monitoring-alerts/scripts/cli/Cleanup.ps1' -RunId 'demo01' -Execute

Cleanup must verify ownership, delete only recorded sandbox objects in dependency order, and prove parent/child absence. Retain run.json, validation.json, and cleanup.json locally until the audit passes. Soft-deleted or deliberately retained items must remain reported. Never purge a shared vault or delete an account, organization, or pre-existing service connection to finish a lab.

Exam debrief and assessment

Explain why each checkpoint's denied path matters, which scope authorizes it, what evidence proves it, and how it is reversed. Complete the 50-question assessment, then review rationales and repeat weak checkpoints.

Microsoft and platform sources

Lifecycle scripts and worked solution

Use scripts/cli/Preflight.ps1, Setup.ps1, BreakFix.ps1, Integration.ps1 (capstones), Validate.ps1, Cleanup.ps1, and Context.ps1 from this lab folder. Setup and cleanup preview until -Execute; -ProvisionOnly creates only fresh ownership-tracked containers. The worked solution lists expected results and repair reasoning.