Skip to content

Commit 93bd461

Browse files
authored
feat(showcase): Add the Monitoring status page and engineer console (#1343) (#1381)
Stackwatch becomes two sides that share MonitoringFrame: - Public status page: overall status, ongoing published incidents with their updates, components with 90-day uptime bars (text and table alternatives), incident history, public incident pages with published postmortems, and subscribe with a demo outbox in the tab. - Engineer console (ConsoleLayout, sidebar, sign-in): overview, services, incidents (declare, acknowledge, severity, internal notes, status page updates, resolve and reopen with the public message they require, postmortem draft and publish), a live log tail with a trace waterfall, the on-call rotation with overrides, notifications with preferences, and the account. The state is now a per-tab showcase site state with full restore validation. Metrics and log lines are derived from the moving clock's ticks and the incident timelines instead of being stored, and actions that add text refuse before the snapshot outgrows the store's limit.
1 parent 219216c commit 93bd461

52 files changed

Lines changed: 7812 additions & 435 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@page "/showcase/monitoring/console/account"
2+
@layout ConsoleLayout
3+
4+
<PageTitle>Account · @MonitoringSeedData.ProductName</PageTitle>
5+
6+
@* The engineer's profile and password. *@
7+
<div class="container-fluid px-lg-4">
8+
<h1 class="mw-title mb-1">Account</h1>
9+
<p class="mw-lead mb-4">
10+
Your name, email, and password for this demo. Engineers see your name on incident timelines, next to your notes and
11+
the status page updates you post; customers on the status page see the update, not your name.
12+
</p>
13+
<ShowcaseAccountProfile />
14+
</div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@inherits LayoutComponentBase
2+
3+
@* The engineers' console (D-031): its own sidebar with the engineer's modules, separate from the public status page. *@
4+
<ShowcaseSessionHost State="State" SiteBase="@MonitoringLayout.Base" SiteName="@MonitoringSeedData.ProductName">
5+
<MonitoringFrame>
6+
<Header>
7+
<div class="mw-console-bar">
8+
<span class="mw-console-bar-title">Console</span>
9+
<div class="mw-console-bar-actions">
10+
<a class="btn btn-sm btn-outline-secondary" href="@MonitoringLayout.Base">
11+
<Icon Name="IconName.BoxArrowUpRight" class="me-1" aria-hidden="true" />View status page
12+
</a>
13+
<ShowcaseAccountMenu SiteBase="@MonitoringLayout.Base" SignInPath="@MonitoringLayout.SignInPath"
14+
NoticeCount="@State.UnreadCount" NoticesPath="@($"{Base}/notifications")" />
15+
</div>
16+
</div>
17+
</Header>
18+
<Sidebar>
19+
@if (State.IsEngineer)
20+
{
21+
<Sidebar @key="State.Identity.Current?.Id"
22+
Class="mw-sidebar"
23+
Href="@Base"
24+
IconName="IconName.Activity"
25+
Title="@MonitoringSeedData.ProductName"
26+
BadgeText="Engineer"
27+
DataProvider="SidebarDataProvider" />
28+
}
29+
</Sidebar>
30+
<ChildContent>
31+
<ShowcaseRoleGuard Roles="@MonitoringSeedData.EngineerRole" SignInPath="@MonitoringLayout.SignInPath">
32+
@Body
33+
</ShowcaseRoleGuard>
34+
</ChildContent>
35+
</MonitoringFrame>
36+
</ShowcaseSessionHost>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using BlazorBootstrap.Demo.RCL.Services.Showcase.Monitoring;
2+
3+
namespace BlazorBootstrap.Demo.RCL.Components.Pages.Showcase.Monitoring;
4+
5+
/// <summary>
6+
/// Layout of the Stackwatch engineers' console (D-031): a top bar with "View status page" and the account menu (its
7+
/// notice count is the engineer's unread notifications), a sidebar with the engineer's modules, and the page behind an
8+
/// engineer-only guard. The sidebar shows only to a signed-in engineer.
9+
/// </summary>
10+
public partial class ConsoleLayout : LayoutComponentBase, IDisposable
11+
{
12+
#region Fields and Constants
13+
14+
/// <summary>Base route of the console.</summary>
15+
public const string Base = MonitoringLayout.Base + "/console";
16+
17+
#endregion
18+
19+
#region Methods
20+
21+
#region Protected Override Methods
22+
23+
protected override void OnInitialized() => State.Changed += OnStateChanged;
24+
25+
#endregion
26+
27+
#region Public Methods
28+
29+
/// <summary>Stops listening to state changes.</summary>
30+
public void Dispose() => State.Changed -= OnStateChanged;
31+
32+
#endregion
33+
34+
#region Private Methods
35+
36+
private void OnStateChanged() => InvokeAsync(StateHasChanged);
37+
38+
/// <summary>The engineer's modules.</summary>
39+
private Task<SidebarDataProviderResult> SidebarDataProvider(SidebarDataProviderRequest request)
40+
{
41+
var items = new List<NavItem>
42+
{
43+
new() { Id = "overview", Href = Base, IconName = IconName.Speedometer2, Text = "Overview", Match = NavLinkMatch.All },
44+
new() { Id = "services", Href = $"{Base}/services", IconName = IconName.HddStack, Text = "Services" },
45+
new() { Id = "incidents", Href = $"{Base}/incidents", IconName = IconName.ExclamationOctagon, Text = "Incidents" },
46+
new() { Id = "logs", Href = $"{Base}/logs", IconName = IconName.Terminal, Text = "Logs and traces" },
47+
new() { Id = "on-call", Href = $"{Base}/on-call", IconName = IconName.CalendarWeek, Text = "On-call" },
48+
new() { Id = "notifications", Href = $"{Base}/notifications", IconName = IconName.Bell, Text = "Notifications" },
49+
new() { Id = "account", Href = $"{Base}/account", IconName = IconName.PersonGear, Text = "Account" },
50+
};
51+
52+
return Task.FromResult(request.ApplyTo(items));
53+
}
54+
55+
#endregion
56+
57+
#endregion
58+
59+
#region Properties, Indexers
60+
61+
[Inject] private MonitoringState State { get; set; } = default!;
62+
63+
#endregion
64+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@page "/showcase/monitoring/console/{*path}"
2+
@layout ConsoleLayout
3+
4+
<PageTitle>Page not found · @MonitoringSeedData.ProductName</PageTitle>
5+
6+
@* Unknown console pages stay in the console instead of falling to the public status page's not-found page. *@
7+
<div class="container-fluid px-lg-4">
8+
<section class="mw-not-found" aria-labelledby="mw-console-missing-title">
9+
<span class="mw-icon fs-4" aria-hidden="true"><Icon Name="IconName.SignpostSplit" /></span>
10+
<h1 class="mw-title fs-3 mt-3 mb-2" id="mw-console-missing-title">We couldn't find that page</h1>
11+
<p class="text-body-secondary mb-4">The link may be wrong, or the incident, service, or trace may no longer exist.</p>
12+
<div class="d-flex justify-content-center flex-wrap gap-2">
13+
<a class="btn btn-primary" href="@ConsoleLayout.Base">Back to the overview</a>
14+
<a class="btn btn-outline-primary" href="@($"{ConsoleLayout.Base}/incidents")">Incidents</a>
15+
</div>
16+
</section>
17+
</div>
18+
19+
@code {
20+
/// <summary>Gets or sets the unmatched path.</summary>
21+
[Parameter] public string? Path { get; set; }
22+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
@page "/showcase/monitoring/console/services"
2+
@layout ConsoleLayout
3+
4+
<PageTitle>Services · @MonitoringSeedData.ProductName</PageTitle>
5+
6+
@{
7+
var rows = Rows;
8+
}
9+
10+
<div class="container-fluid px-lg-4">
11+
<div class="mw-page-head">
12+
<div>
13+
<h1 class="mw-title">Services</h1>
14+
<p class="mw-lead">Live metrics from @State.Services.Count services, sampled every @MonitoringSeedData.TickSeconds seconds. Last sample <span class="mw-mono">@MonitoringDisplay.Time(State.CurrentTime)</span>.</p>
15+
</div>
16+
<LivePauseButton />
17+
</div>
18+
19+
<div class="mw-filters mb-3">
20+
<div>
21+
<label class="form-label mw-label mb-1" for="mw-services-kind">Kind</label>
22+
<select class="form-select" id="mw-services-kind" value="@(kindFilter?.ToString() ?? string.Empty)" @onchange="OnKindChanged">
23+
<option value="">All kinds</option>
24+
@foreach (var kind in Enum.GetValues<MonitoringServiceKind>())
25+
{
26+
<option value="@kind">@KindLabel(kind)</option>
27+
}
28+
</select>
29+
</div>
30+
<div>
31+
<label class="form-label mw-label mb-1" for="mw-services-status">Live status</label>
32+
<select class="form-select" id="mw-services-status" value="@(statusFilter?.ToString() ?? string.Empty)" @onchange="OnStatusChanged">
33+
<option value="">All statuses</option>
34+
@foreach (var status in Enum.GetValues<MonitoringStatus>())
35+
{
36+
<option value="@status">@status</option>
37+
}
38+
</select>
39+
</div>
40+
@if (kindFilter is not null || statusFilter is not null)
41+
{
42+
<div class="align-self-end">
43+
<button type="button" class="btn btn-outline-secondary" @onclick="ClearFilters">Clear filters</button>
44+
</div>
45+
}
46+
</div>
47+
48+
@* Announces filter changes only, never the live ticks. *@
49+
<p class="visually-hidden" role="status">@filterMessage</p>
50+
51+
<Card Class="mw-card">
52+
<CardBody Class="p-0">
53+
<div class="table-responsive mw-grid">
54+
<table class="table mw-services-table">
55+
<caption class="mw-services-caption">@CaptionText(rows.Count). Metrics are from the last sample.</caption>
56+
<thead>
57+
<tr>
58+
<th scope="col">Service</th>
59+
<th scope="col">Kind</th>
60+
<th scope="col">Region</th>
61+
<th scope="col">Team</th>
62+
<th scope="col">Live status</th>
63+
<th scope="col" class="text-end">p95 latency</th>
64+
<th scope="col" class="text-end">Error rate</th>
65+
<th scope="col" class="text-end">Throughput</th>
66+
<th scope="col">Active incident</th>
67+
<th scope="col">Status page</th>
68+
</tr>
69+
</thead>
70+
<tbody>
71+
@if (rows.Count == 0)
72+
{
73+
<tr>
74+
<td colspan="10" class="text-center text-body-secondary py-4">No services match these filters.</td>
75+
</tr>
76+
}
77+
@foreach (var (service, status) in rows)
78+
{
79+
var latest = State.Latest(service.Id);
80+
var incident = State.ActiveIncident(service.Id);
81+
var publicStatus = State.PublicStatus(service.Id);
82+
<tr @key="service.Id">
83+
<th scope="row">
84+
<a class="mw-row-link text-nowrap" href="@MonitoringDisplay.ServiceUrl(service.Id)">@service.Name</a>
85+
</th>
86+
<td class="text-nowrap"><Icon Name="@MonitoringDisplay.KindIcon(service.Kind)" class="me-1 text-body-secondary" aria-hidden="true" />@KindLabel(service.Kind)</td>
87+
<td class="mw-mono text-nowrap">@service.Region</td>
88+
<td class="text-nowrap">@service.Team</td>
89+
<td>
90+
<Badge Color="@MonitoringDisplay.StatusColor(status)"><Icon Name="@MonitoringDisplay.StatusIcon(status)" class="me-1" aria-hidden="true" />@status</Badge>
91+
</td>
92+
<td class="mw-mono text-end text-nowrap">@MonitoringDisplay.Latency(latest.LatencyMs)</td>
93+
<td class="mw-mono text-end text-nowrap">@MonitoringDisplay.ErrorRate(latest.ErrorRate)</td>
94+
<td class="mw-mono text-end text-nowrap">@MonitoringDisplay.Number(latest.Requests) <span class="text-body-secondary small">@MonitoringDisplay.RequestUnit(service.Kind)</span></td>
95+
<td class="mw-incident-cell">
96+
@if (incident is null)
97+
{
98+
<span class="text-body-secondary">None</span>
99+
}
100+
else
101+
{
102+
<a href="@MonitoringDisplay.IncidentUrl(incident.Id)">#@incident.Id @incident.Title</a>
103+
<span class="d-block small text-body-secondary">
104+
@incident.Severity · @incident.Status.ToString().ToLowerInvariant()@(incident.IsPublished ? null : " · not on the status page")
105+
</span>
106+
}
107+
</td>
108+
<td>
109+
<Badge Color="@MonitoringDisplay.PublicStatusColor(publicStatus)"><Icon Name="@MonitoringDisplay.PublicStatusIcon(publicStatus)" class="me-1" aria-hidden="true" />@MonitoringDisplay.PublicStatusLabel(publicStatus)</Badge>
110+
</td>
111+
</tr>
112+
}
113+
</tbody>
114+
</table>
115+
</div>
116+
</CardBody>
117+
</Card>
118+
119+
<p class="small text-body-secondary mt-3 mb-0">
120+
"Live status" comes from each service's latest metrics. "Status page" is what customers see: it changes only when an engineer posts an update on an incident.
121+
<a href="@MonitoringLayout.Base">View the status page</a>.
122+
</p>
123+
</div>

0 commit comments

Comments
 (0)