AzL Sonar — design (v0.1)
This is the contract every part of Sonar is built to (plan task S-4). Back end, page and tests follow it exactly; change it here first.
Layout
| Path | What |
|---|---|
Start-AzlSonar.ps1 | Entry point. Live: -ConfigPath <file> (required), -Port (default 8642), -NoBrowser, -Credential <pscredential> (node logs; optional), -Record <file> (optional). Replay: -Replay <file> (required), -Speed (default 60), -StartAt, -Autoplay, -Port, -NoBrowser. Imports the module, starts the server, opens the browser, runs until Ctrl+C. |
src/AzlSonar/AzlSonar.psd1, AzlSonar.psm1 | PowerShell 7 module, Set-StrictMode -Version Latest. Public functions: Start-AzlSonarServer, Get-AzlSonarDeploymentState, ConvertTo-AzlSonarStepTree, Get-AzlSonarPhaseGuidance, Read-AzlSonarConfig. |
src/AzlSonar/Private/*.ps1 | Azure poller, log tailer, node probe (Arc registration status on the nodes, OEM image route), recorder and recording reader (Recording.ps1), HTTP/SSE server, helpers. |
src/AzlSonar/web/index.html, app.js, app.css | The page. Vanilla HTML/CSS/JS, no build step, no CDN, no external fonts. Light and dark theme (prefers-color-scheme + toggle). |
src/AzlSonar/data/phase-guidance.json | Which account reads which logs in which phase (see below). |
examples/sonar.config.example.json | Example config with neutral values (zero GUIDs, RFC 5737 / documentation addresses). |
tests/*.Tests.ps1 | Pester 5. Mocked ARM and node responses; no live calls. WebLogic.Tests.ps1 runs the page's pure log logic under Node (tests/web-logic.cases.js); skipped when Node is not installed. |
Config (sonar.config.json)
{
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"resourceGroup": "rg-example-azl",
"clusterName": "clus01",
"apiVersion": "2026-10-01",
"apiVersionFallback": "2025-10-01",
"edgeApiVersion": "2026-10-01",
"provisioningRoute": "auto",
"identityModel": "LocalIdentity",
"pollSeconds": 20,
"nodes": [
{ "name": "node01", "address": "192.0.2.11", "seed": true },
{ "name": "node02", "address": "192.0.2.12" }
],
"logs": {
"paths": ["C:\\CloudContent\\MASLogs", "C:\\MASLogs", "C:\\CloudDeployment\\Logs", "C:\\Observability", "C:\\Windows\\System32\\Bootstrap\\Logs"],
"include": ["*.log", "*.txt", "*.xml"],
"exclude": ["*.etl"],
"recurseDepth": 3,
"activeWindowMinutes": 30,
"maxLinesPerPoll": 500,
"pollSeconds": 20,
"transport": "auto"
},
"credential": { "source": "prompt" }
}identityModel: LocalIdentity or ActiveDirectory. credential.source: prompt (Get-Credential at start), parameter (-Credential), or keyvault with vault, usernameSecret, passwordSecret (read once at start with Az.KeyVault; never logged, never sent to the page). provisioningRoute: simplified, oem-image or auto (default; see Machine readiness below). nodes[].arcMachineName is optional and overrides the Arc machine Sonar resolves; the normalised config keeps arcMachineName (the node name when not given) and arcMachineNameSet (whether the config gave it). logs.pollSeconds defaults to the top-level pollSeconds. logs.transport: auto (WinRM, then SSH), winrm or ssh. Every field and its default is listed in the README.
Azure poller (read-only)
Uses the signed-in Az PowerShell context (Invoke-AzRestMethod). Every pollSeconds:
GET .../providers/Microsoft.AzureStackHCI/clusters/{cluster}/deploymentSettings/default?api-version={apiVersion}→properties.deploymentMode,properties.provisioningState,properties.reportedProperties.validationStatusand.deploymentStatus. Each status object is{ status, steps[] }; a step is{ name, description, fullStepIndex, startTimeUtc, endTimeUtc, status, steps[]?, exception[]? }(steps nest;exceptionis an array of strings). Either status object can be{}(not started). Learn documentsError,Success,InProgress; a live test also showsNot Started. Normalisation is case-insensitive and tolerant: unknown values becomeunknownwith the raw value kept inrawStatus.- Unless
provisioningRouteisoem-image, best effort (ignore 404/400):GET .../providers/Microsoft.AzureStackHCI/edgeMachines?api-version={edgeApiVersion}(edge machines exist from 2025-12-01-preview) in the resource group, and for eachGET {edge machine id}/jobs/ProvisionOs?api-version={edgeApiVersion}(404 before it is submitted; thenproperties.operationDetails[name=ProvisionOs].statusstands in). - The route and each node's Arc machine (see Machine readiness), then
GET {arc machine resource id}?api-version=2026-07-15per node →properties.status(Connected/Disconnected),properties.lastStatusChange,properties.agentVersion,systemData.createdAt. - OEM image route only, once a validation or deployment has steps, for each Arc machine that exists:
GET {arc machine resource id}/extensions?api-version=2026-07-15→ the four mandatory extensions (they install during Validate, not during Arc registration), intoextensions.
Node probe (OEM image route, Arc registration only). A third worker (Invoke-AzlSonarNodeProbeLoop, not started when provisioningRoute is simplified) runs while provisioning.route is oem-image and activePhase is arc-registration. Every pollSeconds it opens (and keeps) one connection per unfinished node with the log tailer's transport and account (WinRM, then SSH via Posh-SSH; logs.transport) and runs a read-only script: Get-ArcZeroDaySolutionUpdateStatus and Get-ArcBootstrapStatus with -ErrorAction SilentlyContinue (and -JsonResult when the command offers it); a missing command is reported as not available (simplified-route nodes, other images). Objects are flattened on the node (enums as names, dates ISO 8601 UTC; Windows PowerShell 5.1). The result lands in Shared.NodeProbe[node] and the poller merges it into provisioning.nodes[]. A node is finished (no longer read) when its Arc machine is Connected and its bootstrap Succeeded (or the command is not on it). A failed attempt keeps the last data and records unreachableSince (first failure). Messages and errors are masked with Protect-AzlSonarText and the credential.
ConvertTo-AzlSonarStepTree turns a status object into a flat-or-nested normalized tree: { id (fullStepIndex), name, description, status (normalized: notstarted|running|success|error|skipped), start, end, durationSeconds, errors[], children[] }. Durations: end−start; running steps use now−start.
Get-AzlSonarDeploymentState returns { cluster, mode, provisioningState, phase (provisioning|arc-registration|validation|deployment|done|failed), activePhase, provisioning{ route, routeSource, phase, status, readyForValidate, ztpComplete, nextStep{ name, guide } | null, nodes[] }, extensions{ shown, status, nodes[{ name, arcMachineName, status, ready, total, extensions[], errors[], tree[] }] }, validation{ status, tree[] , counts{} }, deployment{ status, tree[], counts{} }, nodes[{ name, arcMachineName, arcMachineResourceId, arcSource, arcStatus, lastStatusChange, agentVersion, registeredAt }], edgeMachines[], current { phase, stepPath[] , stepName }, warnings[], pollError, polledAt }. current = the deepest step with status running (else the last finished step). phase: deployment if deploymentStatus has steps, else validation if validationStatus has steps, else the machine-readiness phase of the route (provisioning or arc-registration). done when the deployment succeeded; failed when the active phase is in error (for the machine-readiness phase: any machine in error). activePhase is the phase without done/failed. In the machine-readiness phase, stepPath starts with the node name (one synthetic parent per machine).
Machine readiness: the two routes (plan task S-8)
Route. provisioningRoute simplified or oem-image as configured (routeSource: config); auto (routeSource: auto) picks simplified when at least one edge machine maps to a configured node, else oem-image (with a warning when edge machines exist but none map). An edge machine maps to a node by its name, its host name (siteDetails.deviceConfiguration.hostName, else the job's provisioningRequest.deviceConfiguration.hostName), or its Arc machine name against an explicit arcMachineName.
Arc machine per node (arcSource): an explicit arcMachineName always wins (config; read in the config's resource group, or at the edge machine's id when the names match). Otherwise, simplified route: the ProvisionOs job's provisioningRequest.onboardingConfiguration.resourceId (edgeMachine.job, the <device-id>-1 target), else the edge machine's properties.arcMachineResourceId (edgeMachine; while the OS installs this is the maintenance environment's ROE1-… machine in a managed resource group). OEM image route or no edge machine: the node name in the config's resource group (nodeName). Ids read from Azure are used only when they match /subscriptions/*/resourceGroups/*/providers/Microsoft.HybridCompute/machines/*.
provisioning.nodes[] (one per configured node): { name, route, exists, edgeMachineName, lifecycle, lifecycleMessage, status (notstarted|running|success|error|unknown), percent, reportedPercent, provisioningState, machineState, connectivityStatus, arcMachineName, arcMachineResourceId, arcSource, arcStatus, job{ status, operationStatus, provisioningState, start, end, error }, extensions[{ name, present, rawStatus, status, message, start, end }], start, end, errors[], previousErrors[], ztp, tree[] }. ztp is null without ztpEventsPath, else { complete, device, network, restore }, each step { status (notstarted|running|success|error|skipped), state (last event state), message }. OEM image nodes add update and bootstrap ({ available, state (read|notAvailable|noData|notRead), status, rawStatus, done, total, current, start, end }, leaf step counts) and probe ({ state (ok|unreachable|pending), reason, transport, lastProbeUtc, lastSuccessUtc, unreachableSince }). Tree nodes have the ConvertTo-AzlSonarStepTree shape, with ids set by Sonar.
Simplified (provisioning) | OEM image (arc-registration) | |
|---|---|---|
lifecycle | lifecycleDetails.lifecycleStatus.status (Creating, AwaitingConnection, Provisioning, ReadyForOs, InstallingOs, Provisioned); NotCreated without an edge machine | NotStarted, UpdatingOsImage (update InProgress), Bootstrapping (bootstrap running or done but the Arc machine not Connected yet, or the update done and the registration not run again), Registered (Arc Connected and bootstrap Succeeded, or the bootstrap status cannot be read on that node), Failed (update or bootstrap Failed, with the node's Errors[] text, or the agent Expired), Unknown (Arc machine unreadable and nothing read on the node); lifecycleMessage adds Rebooting / unreachable since <time> while the node does not answer |
tree | the lifecycle stages with their sub-stages (ids lifecycle.N, lifecycle.N.M), then one ProvisionOs job node (id job; status from the job status, e.g. DeploymentSuccess/DeploymentFailed; errors = properties.error as code: message) whose children are the job's reportedProperties validation and deployment steps (ids job.N) with their exception[]. With ztpEventsPath: Management address (maintenance environment) (id ztp.device, ZTP stage Device) first, shown alone before the edge machine exists; Management address on the management NIC (ztp.network, Network) and BIOS restored (ztp.restore, Restore) last. Each ZTP event of the latest attempt is a child (ztp.<stage>.N). Restore is skipped (not applicable) when the stage is over (its StageCompleted, or a Handoff event) and the node has no Restore events. | three groups: OS image update (update, update.N: the DetailedResponse[] of Get-ArcZeroDaySolutionUpdateStatus), Bootstrap (bootstrap, bootstrap.N, bootstrap.N.M: Get-ArcBootstrapStatus), node step names kept, StartTime dropped on NotStarted entries (it is the time of the call), Errors[] (or Message) as errors; a group the node did not report is NotAvailable, NoData or NotRead with the reason; Azure registration (arc) with Arc machine registered (arc.machine) and Arc agent Connected (arc.connected) |
status | error when the lifecycle, provisioningState or machineState failed, the job failed (its error counts only while the job reports failure; an error kept from an earlier, resubmitted attempt goes to previousErrors), or any tree node is in error (a failed ZTP Device, Network or Restore step included); success when Provisioned and the job succeeded, and, with ztpEventsPath, the Network step succeeded and the Restore step succeeded or is skipped (ztp.complete); notstarted without an edge machine and without Device events; else running | from lifecycle: Registered success, Failed error, NotStarted notstarted, Unknown unknown, else running |
percent | Sonar's estimate: Creating 0, AwaitingConnection 5, Provisioning 15, ReadyForOs 25, InstallingOs 25 + 70 × finished/reported job steps (max 95), Provisioned 100 (95 with ztpEventsPath until ztp.complete). reportedPercent is the job's percentComplete (recorded responses showed 50 both mid-run and after success, so it is not drawn) | finished leaf steps / leaf steps (bootstrap + Azure registration, plus the update once it started), at most 99 until Registered (100) |
extensions | from the edge machine's reportedProperties.extensionProfile.extensions (by the extension resource name), informational | empty: the extensions are in extensions (top level), read once a validation exists; each extension a step ext.<name> (properties.provisioningState, start systemData.createdAt, end systemData.lastModifiedAt or instanceView.status.time, error instanceView.status.message) |
arm (internal to the page; built from the toolkit's ARM event file, Get-AzlSonarArmState): { configured, hasData, status (notstarted|running|success|error), state (waiting|checking|planned|validating|validated|awaitingapproval|deploying|deployed|failed), activePhase (validation|deployment|''), awaitingApproval, run { runId, mode, cluster, started, completed, exitCode, state, template, parameterHash, schemaVersion, lastEventAt, events, message, nextAction, failed, planned, offline, approval { mode, requested, granted } }, validation, deployment, hints[], warnings[] }. A phase is { status (notstarted|checking|planned|blocked|running|passed|failed|timedout|refused), kind, text, started, completed, elapsedSeconds, deploymentName, skipped, resumed, checkCounts, stepCounts, current { step, name }, failing { step, name, message }, knownIssue, hint { id, title, text }, preventiveHint, refused, message, nextAction, pollErrors, tree[] }. tree has the checks group (failures first) and the steps group (nested by the depth the run reports; validation lists steps in error first). The store (Shared.ArmEvents) follows the order of the lines, never a clock; a phase starts on the run state change into it. It never changes validation or deployment (Azure's trees) or phase. verification (internal to the page; built from the pre-cluster verification gate's event file, Get-AzlSonarVerificationState): { configured, hasData, status (notstarted|running|pass|fail|expired), state, verdict (the gate's word: Pass|Fail|empty), run { runId, started, completed, lastEventAt, events, stale, schema, fileHash, expiresUtc, expiresInSeconds }, counts { Passed, Failed, Warning, Skipped, NotApplicable, Fixed, Running }, total, reportedCounts, countsMismatch, blockers, skippedBlocking, categories [ { id, name, status (worst), blocks, counts, checks [ { id, title, category, status, node, message, remedy, source, sourceUrl (http/https only), blocking, blocks, seq, at } ] } ], attention [ blocking checks ], warnings [], guide }. Only the latest run of the file is shown; a Skipped check always blocks; a Pass verdict with a blocking check is shown as fail. See Verification.
osConfiguration (internal to the page; built from the OS configuration event file, Get-AzlSonarOsConfigurationState): { configured, status (notstarted|running|success|error), state (waiting|planning|planned|applying|converged|failed|incomplete), ready, run { started, completed, mode, exitCode, planCompleted, planChanges, cluster, schemaVersion, wrapperVersion, lastEventAt, events }, nodesTotal, nodesConverged, nodesFailed, nodesRetrying, wipe { published, enabled, count, pending, nodes[] }, nodes[], warnings[] }. nodes[]: { name, method (Ztp|Iso), methodSource (resolved|expected), methodNote, declared, declaredMethod, mismatch, transport, evidence { handoff, arc, winrm }, warnings[], versions { hostname, osVersion, build, osCaption, sbePublisher, sbeFamily, sbeVersion, sbePackage, sbeDelivery, schemaVersion, wrapperVersion }, status (notstarted|running|success|error), state (waiting|planning|planned|applying|retrying|reconnecting|awaitingconfirm|verifying|converged|failed|blocked|rolledback|refused), stateText, currentStep, retries, restarts, changes, blocked, errors[], attempt, start, end, lastEventAt, domainJoined, logAccount { kind (local|domain), userName, reason, warning }, guarded, guardedDetail, runCommands[], tree[] }. tree has one item per step (14, in display order) with osc { step, stage (waiting|planned|ok|info|changing|applied|verified|failed|blocked|skipped|rolledback|refused), action, verifyOnly, notApplicable, current, desired, transport, arc, guarded }. OS configuration is ready when every node has NodeConverged; it never changes provisioning.status. A node's attempt restarts on its next NodeStarted and a RunStarted with a nodes array clears exactly those nodes (by line order, not by clock). The account reading a node's logs is local until the node has reported both DomainJoined and DomainAdminsConfigured, then the domain account the operator supplies (identity.active_directory.domain_join_account; Sonar never uses the LCM user); in between logAccount.waitingForAdmins is true. One account-wide circuit breaker (Shared.LogAccount['*breaker'], immutable records replaced under Shared.CredentialLock) stops that account for every node after the first rejection (15 minutes, doubling to 2 hours, one probe at a time, latched after maxRejections, reset by a new secret version); Details shows its state. A password is held as a SecureString and masked by a salted fingerprint, never kept as text in Shared. Never a password in any served field.
provisioning.status rolls the machines up: error if any, success when all, running when any running or done, else notstarted. provisioning.readyForValidate is true on the OEM image route when every machine is registered and no validation exists; it is always false on the simplified route. provisioning.ztpComplete is true on the simplified route with ztpEventsPath when every machine has ztp.complete: ZTP is done, and provisioning.nextStep is { name: 'OS configuration', guide: 'https://azurelocal.cloud' } (else null). Timestamps 0001-01-01T00:00:00Z mean "not set" and the MM/dd/yyyy HH:mm:ss form some job steps use is read as UTC. The response shapes are the recorded live responses of the 10 Oct 2026 simplified provisioning run (tests/fixtures); the OEM image shapes follow the HybridCompute REST reference and are not yet checked live.
Lag, update track and deployment shape (hardening 2610)
Added to the state, all read-only and best effort; see docs/reference/events.schema.json for the shape the page reads.
lag { detected, kind (deploy-not-reported | rerun-pending), message, source (node log | ARM deployment), nodeStep, since }. Inputs: the newest running ARM deployment (GET {resource group}/providers/Microsoft.Resources/deployments/?api-version=2021-04-01&$filter=provisioningState eq 'Running', only whileprovisioningStateis notSucceeded),systemData.lastModifiedAtof deploymentSettings and a log hint (Get-AzlSonarLogHint: the newest[Role:Interface]in the orchestrator logs, and which Environment Checker files wrote). Ondeploy-not-reportedthe role:interface becomescurrent.stepNamewithcurrent.source = "node log".environmentChecker { stage (none | validate | starting | limited | full | cloud-deployment), label, source }for Deploy mode (Learn: a limited, then a full Environment Checker run, then cloud deployment).update { verified: false, status, phase (idle | available | preparing | installing | failed | attention), summary, active, run, tree, counts }fromupdateSummaries/default,updatesandupdates/{name}/updateRuns(api-versionapiVersion, default 2026-10-01); polled once the deployment isdone, or withtrack: update;updateTrack: offnever polls it. While an update installs,phaseandactivePhaseareupdateandcurrentfollows its steps. With an update account (updateAccountor-UpdateCredential)updatealso carrieslocal(what the cluster's own update service says on one node, read-only: state, run, steps, per-machine progress, history, versions, events) andsources(the cluster against Azure, who wins, how many minutes Azure is behind); the cluster's state wins when it differs. Without the accountlocal.enabledis false andlocal.reasonsays why. SeeNodeUpdate.ps1and the update object.track(configtrack):add-nodeorrepairset the phase after deployment; Azure reports no steps for them.- Config
clusterPattern,architectureandinternalDnsdescribe the deployment shape (release 2609). They change no step logic: the public config carriesprofile.notes(what Learn says about the shape) and the poller adds a warning for a combination Learn does not support. apiVersionFallbackis tried once whenapiVersionanswers 400InvalidApiVersionParameterorNoRegisteredProviderFound.
State timeline (change-only, capped)
Every poll replaces the latest state (/api/state, SSE state). The timeline keeps a snapshot only when the state changed: polledAt and the running steps' durationSeconds are ignored, so a long deployment does not store thousands of identical snapshots. At most 5000 snapshots are kept; when the cap is reached the oldest snapshot is dropped and counted (timelineDropped). The latest state is held separately, so it is always in the export even when the timeline is full.
Log tailer (read-only)
PowerShell remoting to the seed node (New-PSSession -ComputerName <address> -Credential), or SSH with Posh-SSH when WinRM is not reachable (logs.transport). Workgroup nodes (Local Identity) need the address in the workstation's WinRM TrustedHosts; Sonar checks and tells the user, never sets it. Arc run command and Arc SSH are not used: both write to Azure (research.md, S-3), which breaks read-only. If no session can be opened, the tailer reports { state: "unavailable", reason } and retries every 60 s; the page shows the reason and the phase guidance.
Each poll runs one read-only script on the node (Windows PowerShell 5.1). The node keeps nothing between polls: the per-file state travels with the call.
- Discovery cadence. Listing the log folders (
Get-ChildItem -Recurse -Depth recurseDepth) is the expensive part, so it runs on the first poll, then on every 3rd poll or when 60 s have passed since the last listing, whichever comes first, and on the next poll after a tracked file vanished or a session was re-opened. A listing keeps the files matchinginclude/excludethat were written withinactiveWindowMinutes, newest first (at most 300). Between listings the script only re-checks the files that were active at the last listing (no enumeration); a new file is picked up at the next listing, and a log path that does not exist yet (C:\CloudDeployment\Logsappears mid-deployment) is reported inmissingPathsand checked again at each listing. - Reading. For each active file: keep a byte offset; read the new bytes since the offset with
FileShare.ReadWrite|Delete(the writer and rotation are never blocked), split complete lines (an incomplete last line waits for the next poll), at mostmaxLinesPerPolllines per poll and 1 MiB per file. UTF-8, UTF-16 LE/BE (BOM or zero-byte pattern) are detected. A file that already existed when Sonar started is read from 16 KiB before its end; a file that appears later is read from 0. - Rotation and re-creation. Truncation (size < offset) or a new creation time resets the offset to 0. Each tracked file also remembers its first 64 bytes (
head): when a known path's first bytes change, the file was re-created under the same name (NTFS tunnelling keeps the old creation time for 15 s) and is read again from 0. When a new path's creation time and first bytes match a file that just disappeared (or was just re-created), it is the same file renamed by rotation (Deploy.log→Deploy.1.log): its offset, encoding and state are carried over, so its lines are not sent twice (reported inrenamed). Best effort: a rename is only recognised at a listing, against files gone since the previous one (a file that vanishes between listings is kept, inactive, until the next listing); a renamed copy of a file whose first bytes were never read, or whose creation time changed, is read from 0 again. - State cap. At most 2000 files are tracked (offsets of files outside the active window are kept so they continue, not restart, if written again). Beyond that the least recently written entries are evicted, inactive before active (
stateEvicted). - Node clock. The script reports the node's current UTC offset (
utcOffsetMinutes, from[TimeZoneInfo]::Local) so node-local timestamps can be converted.
Every line gets a level: error (\b(error|exception|failed|fatal)\b, case-insensitive), else warning (\bwarn(ing)?\b), else info. Zero-count summaries are removed before matching, so error=0, Failed: 0, 0 failed, warning count=0 and errors: 0 are info (another problem word in the same line still counts).
Every line gets an event time (Get-AzlSonarLogEventTime):
- a leading timestamp in the line (optional
[or(first): ISO 8601 with or without fraction andZ/offset (2026-10-10T16:16:42.123Z,2026-10-10T16:16:42+02:00,2026-10-10T16:16:42),yyyy-MM-dd HH:mm:ss(.fff)(also,fff),[yyyy-MM-dd HH:mm:ss],MM/dd/yyyy HH:mm:ss(alsoh:mm:ss AM/PM), and the PowerShell transcript headerStart time: yyyyMMddHHmmss; - else the timestamp in the file name (
Name_20261010-161642.log,Name_20261010-234335Z.log,PowerShell_transcript.NODE.x.20261010161642.txt); - else the receive time.
Times with Z or an offset are exact. Times without one are node-local and converted with the node's UTC offset (when the offset is unknown they are not used). The exception is the deployment orchestrator log CloudDeployment*.log: its name is in node-local time but its lines are UTC without a Z, so they are read as UTC. A time more than a day after the receive time is ignored. The offset is the node's offset now, so a timestamp written on the other side of a daylight-saving change is off by that hour.
Phase guidance (data/phase-guidance.json)
Per phase and identity model: which account reads the node logs, where the logs are, when they exist, and the source. Phases: provisioning, arc-registration, validation, deployment, post-deployment. Documented sources only; anything not confirmed in a live test is marked "verified": false (an observed note may say what was seen live short of confirming the entry).
Page server (localhost only, http://localhost:{port}/)
These routes are Sonar's local HTTP API; the page is built on them. They are read-only and documented route by route, field by field, with live examples and recipes in the API reference; this section is the design summary. (Tools that feed Sonar do it the other way round, through the event feed.)
| Route | Returns |
|---|---|
GET / , /app.js, /app.css | the page |
GET /api/config | config without secrets: cluster, resourceGroup, identityModel, provisioningRoute, nodes (name, seed), log paths, pollSeconds, startedAt, serverId; recording: { file } while recording; in a replay the recorded config plus replay: { cluster, file, recordedFrom, recordedTo, sessions, invalid, speed, startAt, startAtPhase, autoplay } |
GET /api/replay | replay only: { replay, events[] }, every valid event of the recording in file order (404 when live) |
GET /api/state | latest Get-AzlSonarDeploymentState result |
GET /api/guidance | phase guidance for the configured identity model |
GET /api/about | { name, version, summary, links[{ id, label, url }] }: the Sonar version (from the module manifest) and the documentation links the Help box shows. The page's files carry no http(s) URL, so the links come from here |
GET /api/details | what Sonar collected and is using, read-only: { generatedAt, mode, target{ cluster, resourceGroup, subscription, region }, route, identity, nodes[{ name, address, seed }], sources{ azure, ztpEvents, nodeLogs }, config{ readFrom, file, readAt, checkEverySeconds, lastChangeAt, notSet[], version } }. Each target, route and identity value has a source (where it came from). The subscription is its first 8 characters only; a credential is never included (only the tailer's credential word, supplied or current Windows identity). In a replay the facts come from the recording's config |
GET /api/logs?since={seq} | { server, lastSeq, tailer: {state, reason, node, activeFiles[], ...}, files[{path, size, offset, lastWriteUtc}], lines[] } — lines with seq > since (ring buffer of the last 5000) |
GET /api/events | Server-Sent Events, see below |
GET /api/export | one JSON bundle, see below |
A log line is { seq, time, received, timeSource, file, level, text }: seq counts from 1 for each back-end instance; received is when Sonar got the line (UTC); time is the event time (UTC, yyyy-MM-ddTHH:mm:ss.fffZ); timeSource says where it came from: line (the line's own timestamp), file (the file name) or received (no timestamp: time = received, approximate). text has secrets masked.
server is the back end's instance id (a new GUID at every start; also in /api/config as serverId). lastSeq is the last sequence number given out, read together with the lines: after an answer the page has every line up to lastSeq (or it fell out of the ring buffer) and uses it as its catch-up cursor.
Server-Sent Events. A stream starts with retry: 5000 and event: hello (data { server, since }: the instance id and the seq the stream continues after). Then event: state (data = state JSON) on every change, event: tailer (tailer status) on every change, event: log (data = { server, lines[] }, at most 1000 lines per event) and : ping every 15 s. At most maxEventStreams (default 4) streams are served at once; one more gets 429 with Retry-After: 30 (the page polls meanwhile). The dispatch loop never waits for a client: each client has a bounded queue (4 MiB) and at most one asynchronous write in flight. A client whose write is still in flight gets nothing new that turn (state and tailer coalesce to the latest; log lines wait at its cursor). A client is dropped (connection aborted; the page reconnects and catches up through /api/logs) when a write fails or stays in flight longer than 15 s, when its queue would pass the limit, or when the lines it still needs have left the ring buffer.
Export. { export, config, guidance, state, timeline[], logs }. state is the latest state; timeline is the change-only, capped list of state snapshots (see State timeline); logs is the /api/logs?since=0 body (the ring buffer). export describes the bundle and both caps:
| Field | Meaning |
|---|---|
tool, version, server, exportedAt | AzL Sonar, module version, back-end instance id, export time (UTC) |
snapshots | snapshots in timeline |
timelineMode | change-only: a snapshot is kept only when the state changed (polledAt and running durations ignored) |
timelineMax | the snapshot cap (5000) |
timelineDropped | oldest snapshots dropped because of the cap |
latestStateIncluded | true: state holds the latest state whatever the cap did |
logRingSize | the log ring buffer size (5000 lines) |
logLinesKept, logFirstSeq, logLastSeq | lines in logs.lines and their seq range |
logLinesDropped | lines that left the ring buffer before the export (logLastSeq − logLinesKept) |
The server binds http://localhost:{port}/ and http://127.0.0.1:{port}/ only and answers loopback clients only. No route changes Azure or a node. Before any routing: only GET; the Host header must be localhost, 127.0.0.1 or [::1] with the request's port (else 400, no body); an Origin header must be http://localhost:{port} or http://127.0.0.1:{port} (else 403); and, unless started with -NoAccessToken / accessToken: false, the request must carry the cookie sonar_t equal to the per-start token (32 hex characters from the system's cryptographic generator, compared in constant time), else 401 (Open the URL Sonar printed.). A first request with ?t=<token> gets Set-Cookie: sonar_t=<token>; HttpOnly; SameSite=Strict; Path=/ and a 302 to the same address without the token. The token is added to the masked secrets and is in no body, recording or export. Every response carries Cache-Control: no-store, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, X-Frame-Options: DENY and Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'; JSON bodies write <, > and & as \u escapes. Static files come from a fixed table (/ and /index.html, /app.js, /app.css, /azurelocal-sonar-icon.svg), never from the request path. /api/events: at most maxEventStreams (default 4) clients, 429 with Retry-After beyond it. /api/logs?since=: a whole number from 0 (else 400), clamped to the current sequence; one answer holds at most 2000 lines and about 2 MB, and says truncated: true with lastSeq at the last line sent when more remain (the page asks again). The export is not capped.
Record and replay (plan task S-11)
Recording (-Record <file> or config recordPath, relative to the config file): a Recorder runspace (started before the other workers) appends to a JSON Lines file (UTF-8, one event per line, { "t": "<UTC yyyy-MM-ddTHH:mm:ss.fffZ>", "k": "<kind>", ... }, times never go backwards):
k | Fields |
|---|---|
session | format (1), tool, version, server, cluster, config (the /api/config body), guidance |
state | full (keyframe) or ops (delta). Ops: ["s", path, value] set a key or index (index = length appends), ["d", path] delete a key, ["t", path, length] truncate an array; path is a list of keys and indexes. Each session starts with a keyframe; a new keyframe is written when the deltas since the last one would add up to more than its size, or after 200 deltas. A state equal to the last one is not written. |
tailer | tailer (the tailer status), when it changed |
log | lines[] as in /api/logs; lost when lines left the ring buffer before they were recorded |
end | (none) Sonar stopped cleanly |
The recorder polls the shared table every 500 ms (state version, tailer version, log sequence), so it writes exactly what the page was sent. Every string value is masked again with Protect-AzlSonarText, with the log account's password and the Key Vault vault and secret names as exact values. The file is opened for append with shared read; an existing file gets a new session (on a new line if the last one was cut off). The path is checked (folder created, file opened) before the server binds.
Replay (-Replay <file>): no Azure sign-in, credential, poller, tailer or node probe. Read-AzlSonarRecording checks the file (.jsonl or gzip .jsonl.gz): the first event must be a session with format 1; lines that are not JSON objects with t and k, a delta before its session's first keyframe, and malformed log/tailer events are skipped and counted; unknown kinds are ignored; a file without a state is refused. -StartAt is an offset (h:mm[:ss], 90m, 1h30m, 45s), a UTC time inside the recording, or a phase (arc-registration, validation, deployment; resolved by the page from its markers). /api/state is the state at the start position; /api/events and /api/export answer 404.
Page in replay. When /api/config has replay (or with ?demo=1&replay=1, a built-in recording of the demo deployment), the page loads /api/replay and plays it locally: state at time t = the last keyframe at or before the last state event at or before t, plus the deltas after it (cached forward). Log lines are renumbered across sessions; moving forward appends lines as live, moving back or more than 1500 lines ahead rebuilds the log store at t. Timers, durations and Last poll use the replay clock (position = pos + (wall − anchor) × speed, clamped to the recording, paused at the end). Markers: each phase change (activePhase, or done/failed), each main Deploy step when first seen running (top-level steps, or the children of a single top-level step), the first failed step of a run, each session after the first, the end. The readout is the time since the current phase began (Deploy +1:42:10; a phase's start is its earliest step start, or the earliest machine start for provisioning and Arc registration). The page is labelled Replay of <cluster> · recorded <date> with a Replay badge and Replay (not live) connection state; Export is hidden.
Page
Top bar: brand, cluster name, ⓘ Details (the /api/details pop-down), a status chip (Running, Done, Failed, Waiting), elapsed time, "updated N s ago", the connection, Log access (a button with a dot: green live, amber Azure only, red none; it opens the Log access window), Export, ? (the Help box: version and links from /api/about, then the license and copyright text) and the theme toggle. Below it the mode bar: six equal tiles (Discovery, Provisioning (ZTP) or (OS image) by route, OS configuration, Validate, Deployment, Update; Add node and Repair when the run is one of them) each with a status icon and a state line; a waiting tile is grey with a tooltip that says when it starts; the six tiles are always shown (a run with no machine data has a grey Provisioning tile whose tooltip says so). The summary box and the Steps box show the selected mode (the active one by default). The summary has one card per machine (full name, plain-word state, Arc, what it waits on, progress); a card filters the steps and logs to that machine. Notes under the bar explain what the step list alone would hide (Azure lagging behind the node, the Environment Checker stage, the REST-reference-only tracks, and when ZTP is complete a link to the OS configuration guide, whose URL comes from provisioning.nextStep.guide because the web files carry none).
Cluster card. Validate, Deployment, Update, Add node and Repair put a cluster card (state.clusterResource: one read-only GET of clusters/<name>, read once a deployment settings object exists, and not read by the Discovery, Provisioning and OS configuration monitors) above the machine cards. The rest of the card comes from the validation, deployment and update sections and the track. The card is a button: selecting it hides the machine rows (the Validate extensions) and clears the machine filter.
Modes. A mode maps onto the phase the back end reports (phase / activePhase) and the section that holds its data: Provisioning = provisioning (named after the route), Validate = validation (and the OEM route's extensions), Deployment = deployment, Update = update, Discovery = discovery (the toolkit's hardware discovery files), Add node and Repair = their own modes. A finished cluster is Deployment in its Done state; there is no Health mode (every machine card shows its Arc status). A failed run stays on the mode that failed. The tile line is N of M machines ready / Step n of m / Passed / Done; a waiting tile has none. Azure's raw lifecycle values become plain words on the cards (Installing the OS, Waiting to connect to Azure); the raw value is the tooltip.
Steps and what a click does. The Steps box shows the steps of the selected mode only, grouped per machine for provisioning, each with a short description. A step belongs to Azure or to a node. Azure steps (the machine lifecycle and the ProvisionOs job, the OEM route's Azure registration, validation, the extensions) carry an Azure badge; clicking one shows its status, start and end, Azure's message and any error under it and never filters the logs, because a step that runs in Azure writes nothing to a node log. Node steps (the ZTP Device, Network and Restore stages, the OEM route's OS image update and bootstrap, deployment, update): clicking one filters the logs to the machine and to the step's time window or, for a ZTP stage, to the ZTP event lines of that stage. A machine row selects the machine, like its card. A ZTP event line says its machine and state (<time> [ztp] <node> <State>: ...); the page reads the machine and the stage (Device*, Management* / Network*, Bios*) from it. A node-log line names no machine: it belongs to the node Sonar reads (the seed). An empty result says why: a step with no lines yet (This step has produced no lines on this node yet) offers Show all lines for this node and Clear filter; filters that emptied a non-empty scope offer Clear all filters.
Layout. The page fills the window: the top bar, the mode bar and the summary keep their height; the Steps box and the Live logs box share the rest and each scrolls inside. Under 900 px the boxes stack with a fixed height and the page scrolls.
Log access window. The Log access button opens a window with the identity, the status line, a tab per phase ((current phase) on the active one) and per phase Account, Where, When, How, This deployment, Confidence and Source, from /api/guidance and the deployment profile notes in /api/config. Live log pane: auto-scroll with pause, the All / Info / Warnings / Errors filter (each level shows only its own lines; several can be combined), text search (/ focuses it), file filter, error/warning highlight, count badges, filter chips, new lines button and Showing N of M lines. Export button downloads /api/export. Accessible: keyboard navigation (the step tree, the mode tiles, the pop-ups and the window with Esc), focus visible, ARIA live region for status changes. Works at 1280 px and on a narrow window. Demo mode: ?demo=1 (a running deployment), ?demo=1&route=simplified, ?demo=1&route=oem.
Log sequencing. The page keeps lines in seq order and deduplicates by seq for one back-end instance. Catch-up (/api/logs?since=) and live (SSE log) batches are merged in seq order. The catch-up cursor is kept apart from the highest live seq: it moves with /api/logs answers (lastSeq), and with the live stream only once the stream's hello.since is at or before it, so a live line that arrives first never makes the page skip the lines in between. A back-end restart is detected by a new server id (log batches, hello) or a new /api/config serverId/startedAt (checked on every SSE reconnect and every fallback poll): the page drops what it holds and fetches since=0.
Step filter. A step's window is its start −1 s to its end +1 s (open-ended while it runs). A line with its own timestamp (timeSource: line) matches by event time; a line timed by its file name (file) matches by that time or by its receive time; a line with no timestamp (received) is approximate and matches only when Sonar received it inside the window (shown with ~ before its time). When the selected step's window changes (running → finished) the log pane is filtered again; when the step disappears from the state the filter is removed.
File filter. The options are the files the tailer reports now (/api/logs files, tailer activeFiles) plus the files of the lines the page still holds. The selection stays only while its file is still offered.
Approved UI mockups
The page follows these mockups, approved by the owner. They are a static HTML file with sample data (example names only) and four screenshots of it, kept here so the intended design stays next to the code that implements it. Open the HTML in a browser and use the Show state list, the Details, Log access and ? buttons, the mode tiles and the steps; #details, #logaccess and #help after the address open each pop-up at once.
| Mockup | What it fixes in the design |
|---|---|
| sonar-ux-mockup.html | The interactive mockup: every state of the page (ZTP running, deployment, failed, no log access) |
| mockup-1-main.png | Top bar with the status chip, elapsed time and updated N s ago; six equal mode tiles; the summary with a card per machine and full machine names; the Steps box (descriptions, Azure badges) and the Live logs box (All / Warnings+ / Errors, search, file filter), both filling the window and scrolling inside |
| mockup-2-log-access.png | Log access as a window with a tab for every phase (Provisioning, Validation, Deployment, Post-deployment, Update, Add node, Repair) |
| mockup-3-details.png | The Details pop-down: Target, Mode, Nodes, Sources, Config, each value with where it came from |
| mockup-4-help.png | The ? box: version, documentation links, and "Released under the MIT License. Copyright © Hybrid Cloud Solutions & AzureLocal" |

Where the built page differs from the mockup on purpose, it is because the page shows real data: the Steps box draws Azure's own lifecycle stages and the ProvisionOs job as a tree (the mockup condenses them into one line per stage and has a Handoff line that Sonar cannot read from Azure or the event file), and the Details pop-down opens from the left edge of the page instead of under the button so it fits narrow windows.