Service-level targets with error budgets, and quarterly and annual reports
Monitoring -> Service levels: a target (99.9 %) on an endpoint check, a server or an integration, measured over calendar months. Shows the figure, downtime used, the error budget left, and how the last six months went. 80 % of the budget used is a warning and an overspent budget a critical alert. Endpoints are measured day by day, servers and integrations to the minute from the audit log. The report page gains Quarter and Year (same figures, with a Service levels section), and two settings send the quarterly and annual report after the month that ends them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
31044b2b64
commit
3b31b16796
31 files changed
+7706
-61
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link, useSearchParams } from "react-router-dom";
|
||||
import { IconPrinter } from "@tabler/icons-react";
|
||||
import { api, type AvailabilityRow, type CurrentUser, type MonthlyReport as Report } from "../api/client";
|
||||
import { api, type AvailabilityRow, type CurrentUser, type MonthlyReport as Report, type ServiceLevelResult } from "../api/client";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import { CATEGORY_NAMES, incidentPath, SEVERITY_BADGE } from "../components/IncidentHistory";
|
||||
@@ -33,6 +33,51 @@ const average = (rows: { percent: number | null }[]) => {
|
||||
|
||||
const percentBadge = (p: number | null) => (p === null ? "text-secondary" : p >= 99.9 ? "text-green" : p >= 99 ? "" : p >= 95 ? "text-yellow" : "text-red");
|
||||
|
||||
/** How each service-level target did over the stretch: its figure against the target, and the downtime against what it allowed. */
|
||||
function ServiceLevelsSection({ rows, partial }: { rows: ServiceLevelResult[]; partial: boolean }) {
|
||||
if (rows.length === 0) return null;
|
||||
const metCount = rows.filter((l) => l.met).length;
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Service levels</h3>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
<p>
|
||||
<strong>{metCount}</strong> of {rows.length} {rows.length === 1 ? "target was" : "targets were"} met{partial ? " so far" : ""}. Each is judged on the downtime it allowed over the whole stretch (the error budget).{" "}
|
||||
<Link to="/service-levels">Set targets</Link>
|
||||
</p>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Target</th>
|
||||
<th className="text-end">Target</th>
|
||||
<th className="text-end">Achieved</th>
|
||||
<th className="text-end">Down for</th>
|
||||
<th className="text-end">Allowed</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((l) => (
|
||||
<tr key={l.id}>
|
||||
<td>{l.name}</td>
|
||||
<td className="text-end">{l.target}%</td>
|
||||
<td className={`text-end ${l.met ? "text-green" : "text-red"}`}>{l.percent}%</td>
|
||||
<td className="text-end text-secondary">{l.downMinutes > 0 ? span(l.downMinutes) : "—"}</td>
|
||||
<td className="text-end text-secondary">{l.allowedMinutes >= 1 ? span(l.allowedMinutes) : "under a minute"}</td>
|
||||
<td>{l.met ? <span className="badge bg-green-lt text-green">met</span> : <span className="badge bg-red-lt text-red">missed</span>}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Availability({ title, rows, hint }: { title: string; rows: AvailabilityRow[]; hint?: string }) {
|
||||
if (rows.length === 0) return null;
|
||||
return (
|
||||
@@ -71,7 +116,7 @@ function Availability({ title, rows, hint }: { title: string; rows: Availability
|
||||
export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
const [params, setParams] = useSearchParams();
|
||||
const month = params.get("month") ?? undefined;
|
||||
const [data, setData] = useState<{ report: Report; months: { id: string; label: string }[] } | null>(null);
|
||||
const [data, setData] = useState<{ report: Report; months: { id: string; label: string }[]; quarters: { id: string; label: string }[]; years: { id: string; label: string }[] } | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -101,6 +146,12 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
|
||||
const r = data?.report;
|
||||
const kind = r?.period ?? (month ? (/Q/.test(month) ? "quarter" : /^\d{4}$/.test(month) ? "year" : "month") : "month");
|
||||
const noun = kind === "year" ? "Annual" : kind === "quarter" ? "Quarterly" : "Monthly";
|
||||
const stretch = kind === "year" ? "year" : kind === "quarter" ? "quarter" : "month";
|
||||
const options = data ? (kind === "year" ? data.years : kind === "quarter" ? data.quarters : data.months) : [];
|
||||
/** The newest finished one of a kind, which is what is shown when nothing is asked for. */
|
||||
const lastWhole = (list: { id: string }[]) => list[1]?.id ?? list[0]?.id;
|
||||
const serverAvg = r ? average(r.servers) : null;
|
||||
const endpointAvg = r ? average(r.endpoints) : null;
|
||||
const cards = r
|
||||
@@ -116,14 +167,23 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<div className="report-page">
|
||||
<div className="d-flex flex-wrap align-items-center gap-2 mb-1">
|
||||
<h2 className="page-title mb-0">Monthly report</h2>
|
||||
<h2 className="page-title mb-0">{noun} report</h2>
|
||||
<div className="ms-auto d-flex flex-wrap gap-2 no-print">
|
||||
{data && (
|
||||
<select className="form-select w-auto" aria-label="Month" value={r?.month ?? ""} onChange={(e) => setParams(e.target.value === data.months[1]?.id ? {} : { month: e.target.value }, { replace: true })}>
|
||||
{data.months.map((m) => (
|
||||
<div className="btn-group" role="group" aria-label="What the report covers">
|
||||
{([["month", "Month", data.months], ["quarter", "Quarter", data.quarters], ["year", "Year", data.years]] as const).map(([k, label, list]) => (
|
||||
<button key={k} type="button" className={`btn ${kind === k ? "btn-primary" : "btn-outline-secondary"}`} aria-pressed={kind === k} onClick={() => setParams(k === "month" ? {} : { month: lastWhole(list) ?? "" }, { replace: true })}>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{data && (
|
||||
<select className="form-select w-auto" aria-label={noun === "Monthly" ? "Month" : noun === "Quarterly" ? "Quarter" : "Year"} value={r?.month ?? ""} onChange={(e) => setParams(e.target.value === lastWhole(options) && kind === "month" ? {} : { month: e.target.value }, { replace: true })}>
|
||||
{options.map((m) => (
|
||||
<option key={m.id} value={m.id}>
|
||||
{m.label}
|
||||
{m.id === data.months[0].id ? " (so far)" : ""}
|
||||
{m.id === options[0].id ? " (so far)" : ""}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -137,11 +197,11 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-secondary no-print">
|
||||
How the month went, in one page: availability, incidents and how long they took, updates applied, restore tests and backups, and what was renewed.
|
||||
How the {stretch} went, in one page: availability, how each service-level target did, incidents and how long they took, updates applied, restore tests and backups, and what was renewed.
|
||||
{user.role === "admin" ? (
|
||||
<>
|
||||
{" "}
|
||||
It can be sent on a day of the month: <Link to="/settings/notifications">Settings → Notifications</Link>.
|
||||
It can be sent on a day of the month, and a quarter's and year's report after the month that ends it: <Link to="/settings/notifications">Settings → Notifications</Link>.
|
||||
</>
|
||||
) : null}
|
||||
</p>
|
||||
@@ -153,7 +213,7 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
<h3 className="mb-1">{r.label}</h3>
|
||||
<div className="text-secondary mb-3">
|
||||
{formatDate(new Date(r.from))} – {formatDate(new Date(r.to))}
|
||||
{r.partial ? " · the month is not over, so this is the month so far" : ""} · time zone {r.timezone}
|
||||
{r.partial ? ` · the ${stretch} is not over, so this is the ${stretch} so far` : ""} · time zone {r.timezone}
|
||||
</div>
|
||||
|
||||
<div className="row row-cards mb-3">
|
||||
@@ -213,6 +273,8 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ServiceLevelsSection rows={r.serviceLevels} partial={r.partial} />
|
||||
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Incidents</h3>
|
||||
|
||||
Reference in new issue
Block a user