Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(monitoring): add the Monitors and Incidents surfaces

Juan Denis0acf2c0a3a47
diff --git a/frontend/src/components/monitoring/MonitorsSummary.jsx b/frontend/src/components/monitoring/MonitorsSummary.jsx
new file mode 100644
index 00000000..b15d3550
--- /dev/null
+++ b/frontend/src/components/monitoring/MonitorsSummary.jsx
@@ -0,0 +1,211 @@
+// The monitor half of the Monitoring overview: availability KPIs, the live
+// check feed and the monitor table.
+//
+// This is what the page was missing — everything else on Overview describes the
+// machines ServerKit runs on, and nothing described the things it is supposed to
+// be watching. Host health stays below; this sits above it because "is the site
+// up" is the question the page is actually for.
+import { useCallback, useEffect, useRef, useState } from 'react';
+import { Link, useNavigate } from 'react-router-dom';
+import { Activity, Plus, Radar, ShieldAlert, Timer, Zap } from 'lucide-react';
+import api from '../../services/api';
+import { AreaChart, KpiBand, MetricCard, Pill } from '@/components/ds';
+import { Button } from '@/components/ui/button';
+import { monitorStateOf } from './monitorShared';
+
+const POLL_MS = 15000;
+const FEED_LIMIT = 9;
+
+function relativeTime(iso) {
+ if (!iso) return 'never';
+ const seconds = Math.round((Date.now() - new Date(iso).getTime()) / 1000);
+ if (Number.isNaN(seconds)) return '—';
+ if (seconds < 5) return 'just now';
+ if (seconds < 60) return `${seconds}s ago`;
+ if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
+ return `${Math.floor(seconds / 3600)}h ago`;
+}
+
+export default function MonitorsSummary({ refreshKey = 0 }) {
+ const navigate = useNavigate();
+ const [monitors, setMonitors] = useState([]);
+ const [stats, setStats] = useState(null);
+ const [feed, setFeed] = useState([]);
+ const [loaded, setLoaded] = useState(false);
+ const pollRef = useRef(null);
+
+ const load = useCallback(async () => {
+ try {
+ const [listRes, statsRes] = await Promise.all([
+ api.getMonitors(),
+ api.getMonitorStats().catch(() => null),
+ ]);
+ const list = listRes?.monitors || [];
+ setMonitors(list);
+ setStats(statsRes?.stats || null);
+
+ // The live feed is the most recently checked monitors, newest first —
+ // derived from what we already fetched rather than a second request
+ // per monitor.
+ setFeed(
+ [...list]
+ .filter((m) => m.last_check_at && !m.is_paused)
+ .sort((a, b) => new Date(b.last_check_at) - new Date(a.last_check_at))
+ .slice(0, FEED_LIMIT),
+ );
+ } catch {
+ // Overview must survive a monitors outage; the rest of the page is fine.
+ } finally {
+ setLoaded(true);
+ }
+ }, []);
+
+ useEffect(() => {
+ load();
+ pollRef.current = setInterval(load, POLL_MS);
+ return () => clearInterval(pollRef.current);
+ }, [load, refreshKey]);
+
+ if (!loaded) return null;
+
+ if (!monitors.length) {
+ return (
+ <section className="monitoring-panel mon-nomonitors">
+ <div className="monitoring-panel__header">
+ <div>
+ <h3>Monitors</h3>
+ <span className="mon-panel-sub">Nothing is being watched yet</span>
+ </div>
+ <Button size="sm" onClick={() => navigate('/monitoring/monitors')}>
+ <Plus size={14} /> Add monitor
+ </Button>
+ </div>
+ <p className="mon-panel-hint">
+ Everything below describes the machines ServerKit runs on. Add a monitor to
+ watch a website, an API endpoint, a database port or a WordPress site and get
+ an incident when it stops answering.
+ </p>
+ </section>
+ );
+ }
+
+ const responseTimes = monitors
+ .filter((m) => m.last_response_time != null && !m.is_paused)
+ .map((m) => m.last_response_time);
+ const avgResponse = responseTimes.length
+ ? Math.round(responseTimes.reduce((a, b) => a + b, 0) / responseTimes.length)
+ : null;
+ // The busiest monitor's recent latency stands in for "how are we doing" —
+ // averaging series of different lengths across monitors would be a lie.
+ const leadSpark = monitors.reduce(
+ (best, m) => ((m.spark?.length || 0) > (best?.spark?.length || 0) ? m : best),
+ null,
+ );
+
+ return (
+ <div className="mon-monitors-summary">
+ <KpiBand max={4}>
+ <MetricCard
+ label="Availability (30d)" tone="green" icon={<Activity size={17} />}
+ value={stats?.overall_uptime_30d != null ? `${stats.overall_uptime_30d}%` : '—'}
+ onClick={() => navigate('/monitoring/monitors')}
+ />
+ <MetricCard
+ label="Avg response" tone="cyan" icon={<Zap size={17} />}
+ value={avgResponse ?? '—'} unit={avgResponse != null ? 'ms' : undefined}
+ spark={leadSpark?.spark?.length > 1 ? (
+ <AreaChart series={[leadSpark.spark]} colors={['var(--cyan)']} height={34} grid={false} />
+ ) : undefined}
+ />
+ <MetricCard
+ label="Monitors down" tone={stats?.down ? 'red' : 'green'} icon={<ShieldAlert size={17} />}
+ value={stats?.down ?? 0}
+ onClick={() => navigate('/monitoring/monitors')}
+ />
+ <MetricCard
+ label="Degraded" tone="amber" icon={<Timer size={17} />}
+ value={stats?.degraded ?? 0}
+ onClick={() => navigate('/monitoring/monitors')}
+ />
+ </KpiBand>
+
+ <div className="mon-grid2">
+ <section className="monitoring-panel">
+ <div className="monitoring-panel__header">
+ <div>
+ <h3>Monitors</h3>
+ <span className="mon-panel-sub">{monitors.length} watched</span>
+ </div>
+ <Button variant="outline" size="sm" asChild>
+ <Link to="/monitoring/monitors"><Radar size={14} /> Manage</Link>
+ </Button>
+ </div>
+ <div className="mon-monitor-list">
+ {monitors.slice(0, 8).map((monitor) => {
+ const state = monitorStateOf(monitor);
+ return (
+ <Link
+ key={monitor.id}
+ className="mon-monitor-row"
+ to={`/monitoring/monitors/${monitor.id}`}
+ >
+ <span className="mon-monitor-row__body">
+ <span className="mon-monitor-row__name">{monitor.name}</span>
+ <span className="mon-monitor-row__sub">
+ {monitor.check_type} · {monitor.check_target || 'bound site'}
+ </span>
+ </span>
+ <span className="mon-monitor-row__ms">
+ {monitor.last_response_time == null ? '—' : `${monitor.last_response_time} ms`}
+ </span>
+ <Pill kind={state.tone}>{state.label}</Pill>
+ </Link>
+ );
+ })}
+ </div>
+ </section>
+
+ <section className="monitoring-panel">
+ <div className="monitoring-panel__header">
+ <div>
+ <h3>Live checks</h3>
+ <span className="mon-panel-sub">Most recent results</span>
+ </div>
+ </div>
+ {feed.length === 0 ? (
+ <p className="mon-panel-hint">
+ No checks recorded yet — the scheduler polls on each monitor&apos;s interval.
+ </p>
+ ) : (
+ <div className="mon-feed">
+ {feed.map((monitor) => {
+ const state = monitorStateOf(monitor);
+ const ok = state.key === 'up';
+ return (
+ <Link
+ key={monitor.id}
+ className="mon-feed-row"
+ to={`/monitoring/monitors/${monitor.id}`}
+ >
+ <span className={`mon-code mon-code--${ok ? 'ok' : 'bad'}`}>
+ {ok ? 'ok' : state.label.toLowerCase()}
+ </span>
+ <span className="mon-feed-row__body">
+ <span className="mon-feed-row__name">{monitor.name}</span>
+ <span className="mon-feed-row__sub">
+ {relativeTime(monitor.last_check_at)}
+ </span>
+ </span>
+ <span className="mon-feed-row__ms">
+ {monitor.last_response_time == null ? 'fail' : `${monitor.last_response_time}ms`}
+ </span>
+ </Link>
+ );
+ })}
+ </div>
+ )}
+ </section>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/components/monitoring/UptimeBars.jsx b/frontend/src/components/monitoring/UptimeBars.jsx
new file mode 100644
index 00000000..468e01e7
--- /dev/null
+++ b/frontend/src/components/monitoring/UptimeBars.jsx
@@ -0,0 +1,40 @@
+// 90-day uptime strip: one bar per day, from the design mock.
+//
+// A day with no samples renders as its own "unwatched" state rather than a full
+// green bar — "we weren't looking" and "it was fine" are different facts, and
+// conflating them is how uptime widgets end up lying about their own history.
+import { cn } from '@/lib/utils';
+
+function tooltipFor(day) {
+ if (day.state === 'none') return `${day.date} — not monitored`;
+ const pct = day.uptime != null ? `${day.uptime.toFixed(3)}%` : '—';
+ return `${day.date} — ${pct} uptime, ${day.checks} check${day.checks === 1 ? '' : 's'}`
+ + (day.down_checks ? `, ${day.down_checks} failed` : '');
+}
+
+export default function UptimeBars({ days = [], selected, onSelect, className }) {
+ if (!days.length) return null;
+ return (
+ <div className={cn('uptime-bars', className)}>
+ {days.map((day) => (
+ // A bar in a chart is not a <Button>: 90 of them, each a bare
+ // 6px sliver with no label or affordance of its own. Semantic
+ // <button> keeps it keyboard-reachable without dragging the
+ // full button styling into a data visualisation.
+ // eslint-disable-next-line no-restricted-syntax
+ <button
+ key={day.date}
+ type="button"
+ className={cn(
+ 'uptime-bars__bar',
+ `uptime-bars__bar--${day.state}`,
+ selected === day.date && 'is-selected',
+ )}
+ title={tooltipFor(day)}
+ aria-label={tooltipFor(day)}
+ onClick={() => onSelect?.(day)}
+ />
+ ))}
+ </div>
+ );
+}
diff --git a/frontend/src/components/monitoring/monitorShared.jsx b/frontend/src/components/monitoring/monitorShared.jsx
new file mode 100644
index 00000000..436b2f68
--- /dev/null
+++ b/frontend/src/components/monitoring/monitorShared.jsx
@@ -0,0 +1,50 @@
+// Shared vocabulary for the monitor surfaces (list, detail, overview, incidents).
+// Keeping the status mapping in one place stops the list and the detail page
+// disagreeing about what "degraded" looks like.
+
+export const CHECK_TYPES = [
+ { value: 'http', label: 'HTTP', hint: 'status code of a URL' },
+ { value: 'keyword', label: 'Keyword', hint: 'URL must contain a phrase' },
+ { value: 'tcp', label: 'Port', hint: 'host:port accepts a connection' },
+ { value: 'ping', label: 'Ping', hint: 'host answers ICMP' },
+ { value: 'dns', label: 'DNS', hint: 'name resolves' },
+ { value: 'smtp', label: 'SMTP', hint: 'mail server greets' },
+];
+
+export const MONITOR_STATUS = [
+ { value: 'operational', label: 'Operational' },
+ { value: 'degraded', label: 'Degraded' },
+ { value: 'major_outage', label: 'Down' },
+ { value: 'maintenance', label: 'Maintenance' },
+ { value: 'paused', label: 'Paused' },
+];
+
+// Paused is deliberately not a `status` on the model — it is its own flag, so a
+// paused monitor keeps the last thing it knew rather than looking like an
+// outage. Resolve it here, once.
+export function monitorStateOf(monitor) {
+ if (!monitor) return { key: 'unknown', label: 'Unknown', tone: 'gray' };
+ if (monitor.is_paused) return { key: 'paused', label: 'Paused', tone: 'gray' };
+ switch (monitor.status) {
+ case 'operational':
+ return { key: 'up', label: 'Operational', tone: 'green' };
+ case 'degraded':
+ case 'partial_outage':
+ return { key: 'degraded', label: 'Degraded', tone: 'amber' };
+ case 'major_outage':
+ return { key: 'down', label: 'Down', tone: 'red' };
+ case 'maintenance':
+ return { key: 'maintenance', label: 'Maintenance', tone: 'cyan' };
+ default:
+ return { key: 'unknown', label: monitor.status || 'Unknown', tone: 'gray' };
+ }
+}
+
+export const INCIDENT_STATES = ['investigating', 'identified', 'monitoring', 'resolved'];
+
+export const IMPACT_TONE = {
+ critical: 'red',
+ major: 'red',
+ minor: 'amber',
+ none: 'gray',
+};
diff --git a/frontend/src/pages/Incidents.jsx b/frontend/src/pages/Incidents.jsx
new file mode 100644
index 00000000..e931fea6
--- /dev/null
+++ b/frontend/src/pages/Incidents.jsx
@@ -0,0 +1,360 @@
+// Incidents — one place for "something is wrong right now".
+//
+// This absorbed the old Alerts tab. A CPU threshold crossing on a host and a
+// monitor going down are the same question asked of two different subjects, and
+// splitting them across two tabs is what made alerting look like it only ever
+// described the panel's own machine. Host threshold alerting is unchanged —
+// same endpoints, same ack/check actions — it just renders in this timeline
+// alongside monitor outages.
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { Link } from 'react-router-dom';
+import {
+ AlertTriangle, CheckCircle2, ChevronRight, Radar, RefreshCw, Siren,
+} from 'lucide-react';
+import api from '../services/api';
+import { useToast } from '../contexts/ToastContext';
+import EmptyState from '../components/EmptyState';
+import FleetAlertsPanel from '../components/monitoring/FleetAlertsPanel';
+import { Drawer, KpiBand, MetricCard, Pill, SegControl } from '@/components/ds';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { useTopbarActions } from '@/hooks/useTopbarActions';
+import { IMPACT_TONE, INCIDENT_STATES } from '../components/monitoring/monitorShared';
+
+const FILTERS = [
+ { value: 'active', label: 'Active' },
+ { value: 'resolved', label: 'Resolved' },
+ { value: 'all', label: 'All' },
+];
+
+const STATE_TONE = {
+ investigating: 'red',
+ identified: 'amber',
+ monitoring: 'cyan',
+ resolved: 'green',
+};
+
+const SEVERITY_TONE = { critical: 'red', warning: 'amber', info: 'cyan' };
+
+function formatWhen(iso) {
+ if (!iso) return 'unknown';
+ const date = new Date(iso);
+ if (Number.isNaN(date.getTime())) return 'unknown';
+ return date.toLocaleString();
+}
+
+function formatValue(value) {
+ if (typeof value !== 'number' || Number.isNaN(value)) return '—';
+ return value.toFixed(1);
+}
+
+export default function Incidents() {
+ const toast = useToast();
+ const [filter, setFilter] = useState('active');
+ const [incidents, setIncidents] = useState([]);
+ const [activeAlerts, setActiveAlerts] = useState([]);
+ const [alertHistory, setAlertHistory] = useState([]);
+ const [monitors, setMonitors] = useState([]);
+ const [loading, setLoading] = useState(true);
+ const [selected, setSelected] = useState(null);
+ const [note, setNote] = useState('');
+ const [checking, setChecking] = useState(false);
+ const [hasFleet, setHasFleet] = useState(false);
+
+ const load = useCallback(async () => {
+ try {
+ const [incidentsRes, statusRes, historyRes, monitorsRes, serversRes] = await Promise.all([
+ api.getIncidents({ state: 'all', limit: 200 }).catch(() => null),
+ api.getMonitoringStatus().catch(() => null),
+ api.getAlertHistory(50).catch(() => null),
+ api.getMonitors().catch(() => null),
+ api.getServers().catch(() => null),
+ ]);
+ setIncidents(incidentsRes?.incidents || []);
+ setActiveAlerts(statusRes?.active_alerts || []);
+ setAlertHistory(historyRes?.alerts || []);
+ setMonitors(monitorsRes?.monitors || []);
+ // The fleet panel is only meaningful once there are paired servers.
+ const servers = Array.isArray(serversRes) ? serversRes : (serversRes?.servers || []);
+ setHasFleet(servers.length > 0);
+ } catch {
+ // Keep the last good list rather than blanking the page.
+ } finally {
+ setLoading(false);
+ }
+ }, []);
+
+ useEffect(() => { load(); }, [load]);
+
+ const onCheckAlerts = async () => {
+ setChecking(true);
+ try {
+ const result = await api.checkAlerts();
+ const count = result.alerts?.length || 0;
+ toast[count > 0 ? 'warning' : 'success'](`${count} host alert${count === 1 ? '' : 's'} firing`);
+ await load();
+ } catch (err) {
+ toast.error(err.message || 'Alert check failed');
+ } finally {
+ setChecking(false);
+ }
+ };
+
+ useTopbarActions(() => (
+ <>
+ <Button variant="outline" size="sm" onClick={onCheckAlerts} disabled={checking}>
+ <Siren size={14} /> {checking ? 'Checking…' : 'Check hosts'}
+ </Button>
+ <Button variant="outline" size="sm" onClick={load}>
+ <RefreshCw size={14} /> Refresh
+ </Button>
+ </>
+ ), [checking, load]);
+
+ const monitorsById = useMemo(
+ () => Object.fromEntries(monitors.map((m) => [m.id, m])),
+ [monitors],
+ );
+
+ // One list, two sources. Host alerts have no lifecycle of their own — they
+ // are either firing or historical — so they map onto the same active/resolved
+ // axis the incidents use.
+ const items = useMemo(() => {
+ const fromIncidents = incidents.map((incident) => ({
+ kind: 'incident',
+ key: `incident-${incident.id}`,
+ id: incident.id,
+ title: incident.title,
+ subject: monitorsById[incident.component_id]?.name || 'Service',
+ state: incident.status,
+ tone: STATE_TONE[incident.status] || 'gray',
+ impact: incident.impact,
+ when: incident.created_at,
+ resolved: incident.status === 'resolved',
+ raw: incident,
+ }));
+
+ const fromActive = activeAlerts.map((alert, index) => ({
+ kind: 'alert',
+ key: `active-${alert.type}-${index}`,
+ title: alert.message,
+ subject: 'This server',
+ state: 'firing',
+ tone: 'red',
+ impact: alert.severity,
+ when: alert.timestamp,
+ resolved: false,
+ raw: alert,
+ }));
+
+ const fromHistory = alertHistory.map((alert, index) => ({
+ kind: 'alert',
+ key: `history-${alert.timestamp || index}-${index}`,
+ title: alert.message,
+ subject: 'This server',
+ state: alert.severity,
+ tone: SEVERITY_TONE[alert.severity] || 'gray',
+ impact: alert.severity,
+ when: alert.timestamp,
+ resolved: true,
+ raw: alert,
+ }));
+
+ return [...fromActive, ...fromIncidents, ...fromHistory]
+ .sort((a, b) => new Date(b.when || 0) - new Date(a.when || 0));
+ }, [incidents, activeAlerts, alertHistory, monitorsById]);
+
+ const shown = items.filter((item) => (
+ filter === 'all' || (filter === 'active' ? !item.resolved : item.resolved)
+ ));
+
+ const activeCount = items.filter((i) => !i.resolved).length;
+ const openIncidents = incidents.filter((i) => i.status !== 'resolved').length;
+
+ const onPostUpdate = async (state) => {
+ if (!selected || selected.kind !== 'incident') return;
+ try {
+ await api.updateIncident(selected.id, {
+ status: state,
+ update_body: note.trim() || `Status moved to ${state}.`,
+ });
+ toast.success(`Incident ${state}`);
+ setNote('');
+ setSelected(null);
+ await load();
+ } catch (err) {
+ toast.error(err.message || 'Could not post the update');
+ }
+ };
+
+ if (loading) {
+ return (
+ <div className="sk-tabgroup__inner incidents-page">
+ <EmptyState loading loadingVariant="feed" title="Loading incidents" />
+ </div>
+ );
+ }
+
+ const selectedMonitor = selected?.kind === 'incident'
+ ? monitorsById[selected.raw.component_id]
+ : null;
+
+ return (
+ <div className="sk-tabgroup__inner incidents-page">
+ <KpiBand>
+ <MetricCard
+ label="Active" value={activeCount} tone={activeCount ? 'red' : 'green'} compact
+ icon={<AlertTriangle size={17} />} onClick={() => setFilter('active')}
+ />
+ <MetricCard
+ label="Open incidents" value={openIncidents} tone="amber" compact
+ icon={<Radar size={17} />}
+ />
+ <MetricCard
+ label="Host alerts firing" value={activeAlerts.length} tone="cyan" compact
+ icon={<Siren size={17} />}
+ />
+ <MetricCard
+ label="Resolved (recent)" value={items.filter((i) => i.resolved).length} tone="green" compact
+ icon={<CheckCircle2 size={17} />} onClick={() => setFilter('resolved')}
+ />
+ </KpiBand>
+
+ <div className="incidents-listhead">
+ <SegControl value={filter} onChange={setFilter} options={FILTERS} />
+ <span className="incidents-listhead__meta">
+ {shown.length} shown · monitor outages and host threshold alerts
+ </span>
+ </div>
+
+ {shown.length === 0 ? (
+ <EmptyState
+ icon={CheckCircle2}
+ title={filter === 'active' ? 'Nothing is wrong right now' : 'Nothing here'}
+ description={filter === 'active'
+ ? 'No monitor is down and no host is over its limit.'
+ : `No ${filter} incidents or alerts recorded.`}
+ />
+ ) : (
+ <div className="incidents-list">
+ {shown.map((item) => (
+ <button
+ key={item.key}
+ type="button"
+ className="incident-row"
+ onClick={() => setSelected(item)}
+ >
+ <span className={`incident-row__sev incident-row__sev--${item.tone}`} />
+ <span className="incident-row__body">
+ <span className="incident-row__title">
+ {item.title}
+ <Pill kind={item.tone}>{item.state}</Pill>
+ </span>
+ <span className="incident-row__sub">
+ {item.subject} · {formatWhen(item.when)}
+ {item.kind === 'alert' && item.raw.type
+ ? ` · ${item.raw.type} ${formatValue(item.raw.value)} / ${item.raw.threshold}`
+ : ''}
+ </span>
+ </span>
+ <ChevronRight size={16} className="incident-row__chev" />
+ </button>
+ ))}
+ </div>
+ )}
+
+ {/* Per-server threshold alerts across the fleet: their own system
+ with its own ack/resolve lifecycle, so they keep their own panel
+ rather than being flattened into the timeline above. */}
+ {hasFleet && <FleetAlertsPanel />}
+
+ <Drawer
+ open={Boolean(selected)}
+ onOpenChange={(open) => { if (!open) { setSelected(null); setNote(''); } }}
+ title={selected?.title || ''}
+ subtitle={selected ? `${selected.subject} · ${formatWhen(selected.when)}` : ''}
+ icon={selected?.kind === 'incident' ? <AlertTriangle size={18} /> : <Siren size={18} />}
+ >
+ {selected?.kind === 'incident' && (
+ <div className="incident-detail">
+ <div className="incident-detail__pills">
+ <Pill kind={STATE_TONE[selected.raw.status] || 'gray'}>{selected.raw.status}</Pill>
+ <Pill kind={IMPACT_TONE[selected.raw.impact] || 'gray'}>{selected.raw.impact} impact</Pill>
+ </div>
+
+ {selected.raw.body && <p className="incident-detail__body">{selected.raw.body}</p>}
+
+ {selectedMonitor && (
+ <Link className="incident-detail__link" to={`/monitoring/monitors/${selectedMonitor.id}`}>
+ <Radar size={14} /> Open {selectedMonitor.name}
+ </Link>
+ )}
+
+ <h4 className="incident-detail__heading">Timeline</h4>
+ {selected.raw.updates?.length ? (
+ <ol className="incident-timeline">
+ {selected.raw.updates.map((update) => (
+ <li key={update.id} className="incident-timeline__item">
+ <span className={`incident-timeline__dot is-${STATE_TONE[update.status] || 'gray'}`} />
+ <div>
+ <div className="incident-timeline__head">
+ <Pill kind={STATE_TONE[update.status] || 'gray'}>{update.status}</Pill>
+ <span>{formatWhen(update.created_at)}</span>
+ </div>
+ <p>{update.body}</p>
+ </div>
+ </li>
+ ))}
+ </ol>
+ ) : (
+ <p className="mon-panel-hint">No updates posted yet.</p>
+ )}
+
+ {selected.raw.status !== 'resolved' && (
+ <div className="incident-detail__post">
+ <h4 className="incident-detail__heading">Post an update</h4>
+ <Input
+ value={note}
+ onChange={(e) => setNote(e.target.value)}
+ placeholder="What changed?"
+ />
+ <div className="incident-detail__states">
+ {INCIDENT_STATES.map((state) => (
+ <Button
+ key={state}
+ variant="outline"
+ size="sm"
+ onClick={() => onPostUpdate(state)}
+ >
+ {state}
+ </Button>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+
+ {selected?.kind === 'alert' && (
+ <div className="incident-detail">
+ <div className="incident-detail__pills">
+ <Pill kind={selected.tone}>{selected.state}</Pill>
+ <Pill kind={SEVERITY_TONE[selected.raw.severity] || 'gray'}>
+ {selected.raw.severity}
+ </Pill>
+ </div>
+ <dl className="mon-inforows">
+ <div><dt>Metric</dt><dd>{selected.raw.type || '—'}</dd></div>
+ <div><dt>Reading</dt><dd>{formatValue(selected.raw.value)}</dd></div>
+ <div><dt>Limit</dt><dd>{selected.raw.threshold ?? '—'}</dd></div>
+ <div><dt>When</dt><dd>{formatWhen(selected.when)}</dd></div>
+ </dl>
+ <p className="mon-panel-hint">
+ Host limits live on the <Link to="/monitoring/rules">Rules</Link> tab.
+ </p>
+ </div>
+ )}
+ </Drawer>
+ </div>
+ );
+}
diff --git a/frontend/src/pages/MonitorDetail.jsx b/frontend/src/pages/MonitorDetail.jsx
new file mode 100644
index 00000000..663d2c05
--- /dev/null
+++ b/frontend/src/pages/MonitorDetail.jsx
@@ -0,0 +1,496 @@
+// MonitorDetail — the drill-down for a single check.
+//
+// Outside the Monitoring tab group (like /queue/:group/:queue) because it is a
+// drill-down, so it carries its own PageTopbar with a breadcrumb back to the
+// list. Its sections are a SegControl, not a tab strip: a nav under the page's
+// own header would be the same two-competing-headers problem the group layout
+// exists to avoid.
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
+import { Link, useNavigate, useParams } from 'react-router-dom';
+import {
+ Activity, ArrowLeft, BarChart3, CheckCircle2, Clock, ExternalLink, Lock,
+ Pause, Play, RefreshCw, Rows3, ShieldAlert, SlidersHorizontal, Trash2, Zap,
+} from 'lucide-react';
+import api from '../services/api';
+import { useToast } from '../contexts/ToastContext';
+import { useConfirm } from '../hooks/useConfirm';
+import EmptyState from '../components/EmptyState';
+import UptimeBars from '../components/monitoring/UptimeBars';
+import { monitorStateOf } from '../components/monitoring/monitorShared';
+import {
+ AreaChart, DataTable, KpiBand, MetricCard, PageTopbar, Pill, SegControl,
+} from '@/components/ds';
+import { Button } from '@/components/ui/button';
+
+const POLL_MS = 15000;
+
+const SECTIONS = [
+ { value: 'performance', label: 'Performance', icon: <Activity size={14} /> },
+ { value: 'uptime', label: 'Uptime', icon: <BarChart3 size={14} /> },
+ { value: 'checks', label: 'Check log', icon: <Rows3 size={14} /> },
+ { value: 'config', label: 'Configuration', icon: <SlidersHorizontal size={14} /> },
+];
+
+const RANGES = [
+ { value: 1, label: '1h' },
+ { value: 24, label: '24h' },
+ { value: 168, label: '7d' },
+ { value: 720, label: '30d' },
+];
+
+function percentile(values, p) {
+ if (!values.length) return null;
+ const sorted = [...values].sort((a, b) => a - b);
+ return sorted[Math.min(sorted.length - 1, Math.floor(sorted.length * p))];
+}
+
+function formatUptime(value) {
+ return value == null ? '—' : `${Number(value).toFixed(2)}%`;
+}
+
+function certDaysLeft(iso) {
+ if (!iso) return null;
+ return Math.round((new Date(iso).getTime() - Date.now()) / 86400000);
+}
+
+export default function MonitorDetail() {
+ const { monitorId } = useParams();
+ const navigate = useNavigate();
+ const toast = useToast();
+ const { confirm } = useConfirm();
+
+ const [monitor, setMonitor] = useState(null);
+ const [checks, setChecks] = useState([]);
+ const [uptime, setUptime] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [notFound, setNotFound] = useState(false);
+ const [section, setSection] = useState('performance');
+ const [rangeHours, setRangeHours] = useState(24);
+ const [selectedDay, setSelectedDay] = useState(null);
+ // Freezing the log is what makes a streaming table readable — without it the
+ // row you are reading slides away on the next poll.
+ const [frozen, setFrozen] = useState(null);
+ const [busy, setBusy] = useState(false);
+ const pollRef = useRef(null);
+
+ const load = useCallback(async () => {
+ try {
+ const [monitorRes, historyRes, uptimeRes] = await Promise.all([
+ api.getMonitor(monitorId),
+ api.getMonitorHistory(monitorId, { hours: rangeHours, limit: 300 }),
+ api.getMonitorUptime(monitorId, 90).catch(() => null),
+ ]);
+ setMonitor(monitorRes);
+ setChecks(historyRes?.checks || []);
+ setUptime(uptimeRes || null);
+ } catch (err) {
+ if (String(err.message || '').toLowerCase().includes('not found')) setNotFound(true);
+ } finally {
+ setLoading(false);
+ }
+ }, [monitorId, rangeHours]);
+
+ useEffect(() => {
+ load();
+ pollRef.current = setInterval(load, POLL_MS);
+ return () => clearInterval(pollRef.current);
+ }, [load]);
+
+ // Oldest-first for the chart; the API returns newest-first for the log.
+ const series = useMemo(() => {
+ const withTiming = checks.filter((c) => c.response_time != null);
+ return [...withTiming].reverse().map((c) => c.response_time);
+ }, [checks]);
+
+ const stats = useMemo(() => {
+ if (!series.length) return { avg: null, min: null, max: null, p95: null };
+ return {
+ avg: Math.round(series.reduce((a, b) => a + b, 0) / series.length),
+ min: Math.min(...series),
+ max: Math.max(...series),
+ p95: percentile(series, 0.95),
+ };
+ }, [series]);
+
+ if (loading && !monitor) {
+ return (
+ <div className="page-container monitor-detail">
+ <EmptyState loading loadingVariant="detail" title="Loading monitor" />
+ </div>
+ );
+ }
+
+ if (notFound || !monitor) {
+ return (
+ <div className="page-container monitor-detail">
+ <EmptyState
+ icon={ShieldAlert}
+ title="Monitor not found"
+ description="It may have been deleted."
+ action={<Button onClick={() => navigate('/monitoring/monitors')}>Back to monitors</Button>}
+ />
+ </div>
+ );
+ }
+
+ const state = monitorStateOf(monitor);
+ const certDays = certDaysLeft(monitor.cert_expires_at);
+ const isHttpish = ['http', 'keyword'].includes(monitor.check_type);
+ const rows = frozen || checks;
+ const newSinceFreeze = frozen
+ ? checks.filter((c) => !frozen.some((f) => f.id === c.id)).length
+ : 0;
+ const downMinutes = uptime?.days
+ ? uptime.days.filter((d) => d.state !== 'none').reduce((total, d) => (
+ total + Math.round(((100 - (d.uptime ?? 100)) / 100) * 1440)
+ ), 0)
+ : null;
+
+ const act = async (fn, successMessage) => {
+ setBusy(true);
+ try {
+ await fn();
+ if (successMessage) toast.success(successMessage);
+ await load();
+ } catch (err) {
+ toast.error(err.message || 'Action failed');
+ } finally {
+ setBusy(false);
+ }
+ };
+
+ const onCheckNow = () => act(async () => {
+ const res = await api.runMonitorCheck(monitor.id);
+ const check = res?.check;
+ if (check?.status === 'up') toast.success(`Up in ${check.response_time ?? '—'} ms`);
+ else toast.warning(`${check?.status || 'failed'}${check?.error ? ` — ${check.error}` : ''}`);
+ });
+
+ const onTogglePause = () => act(
+ () => api.setMonitorPaused(monitor.id, !monitor.is_paused),
+ monitor.is_paused ? 'Monitor resumed' : 'Monitor paused',
+ );
+
+ const onDelete = async () => {
+ const ok = await confirm({
+ title: 'Delete this monitor?',
+ message: `“${monitor.name}” and its check history will be removed. Any open incident is resolved first.`,
+ confirmText: 'Delete',
+ variant: 'danger',
+ });
+ if (!ok) return;
+ try {
+ await api.deleteMonitor(monitor.id);
+ toast.success('Monitor deleted');
+ navigate('/monitoring/monitors');
+ } catch (err) {
+ toast.error(err.message || 'Could not delete the monitor');
+ }
+ };
+
+ return (
+ <div className="page-container monitor-detail">
+ <PageTopbar
+ icon={<ArrowLeft size={18} />}
+ title={monitor.name}
+ meta={`${monitor.check_type} · ${monitor.check_target || 'bound site'} · every ${monitor.check_interval}s`}
+ actions={(
+ <>
+ <Pill kind={state.tone}>{state.label}</Pill>
+ <Button variant="outline" size="sm" onClick={onCheckNow} disabled={busy}>
+ <RefreshCw size={14} /> Check now
+ </Button>
+ <Button variant="outline" size="sm" onClick={onTogglePause} disabled={busy}>
+ {monitor.is_paused ? <><Play size={14} /> Resume</> : <><Pause size={14} /> Pause</>}
+ </Button>
+ {isHttpish && monitor.check_target && (
+ <Button variant="outline" size="sm" asChild>
+ <a href={monitor.check_target} target="_blank" rel="noreferrer">
+ <ExternalLink size={14} />
+ </a>
+ </Button>
+ )}
+ </>
+ )}
+ />
+
+ <nav className="monitor-detail__crumb">
+ <Link to="/monitoring/monitors">Monitors</Link>
+ <span aria-hidden="true">/</span>
+ <span>{monitor.name}</span>
+ </nav>
+
+ <KpiBand>
+ <MetricCard
+ label="Response now" tone="cyan" icon={<Zap size={17} />}
+ value={monitor.last_response_time ?? '—'}
+ unit={monitor.last_response_time != null ? 'ms' : undefined}
+ >
+ <div className="mon-kpi-sub">
+ avg {stats.avg ?? '—'} ms · p95 {stats.p95 ?? '—'} ms
+ </div>
+ </MetricCard>
+ <MetricCard
+ label="Uptime (30d)" tone="accent" icon={<CheckCircle2 size={17} />}
+ value={formatUptime(monitor.uptime_30d)}
+ >
+ <div className="mon-kpi-sub">
+ 24h {formatUptime(monitor.uptime_24h)} · 7d {formatUptime(monitor.uptime_7d)}
+ </div>
+ </MetricCard>
+ <MetricCard
+ label="Downtime (90d)" tone="amber" icon={<Clock size={17} />}
+ value={downMinutes ?? '—'} unit={downMinutes != null ? 'min' : undefined}
+ >
+ <div className="mon-kpi-sub">
+ {uptime?.days ? `${uptime.days.filter((d) => d.state !== 'none' && d.state !== 'up').length} bad days` : 'no history yet'}
+ </div>
+ </MetricCard>
+ <MetricCard
+ label="Certificate"
+ tone={certDays == null ? 'accent' : certDays < 0 ? 'red' : certDays < 21 ? 'amber' : 'green'}
+ icon={<Lock size={17} />}
+ value={certDays == null ? 'n/a' : certDays < 0 ? 'Expired' : certDays}
+ unit={certDays != null && certDays >= 0 ? 'days' : undefined}
+ >
+ <div className="mon-kpi-sub">
+ {monitor.cert_issuer || (isHttpish ? 'not read yet' : 'no TLS on this check')}
+ </div>
+ </MetricCard>
+ </KpiBand>
+
+ <SegControl
+ className="monitor-detail__sections"
+ value={section}
+ onChange={setSection}
+ options={SECTIONS}
+ />
+
+ {section === 'performance' && (
+ <div className="mon-panel">
+ <div className="mon-panel__header">
+ <div>
+ <h3>Response time</h3>
+ <span className="mon-panel-sub">
+ {series.length} sample{series.length === 1 ? '' : 's'} in this window
+ </span>
+ </div>
+ <SegControl
+ value={rangeHours}
+ onChange={setRangeHours}
+ options={RANGES}
+ />
+ </div>
+ {series.length === 0 ? (
+ <p className="mon-panel-hint">
+ No timed samples yet — the first check lands within {monitor.check_interval}s.
+ </p>
+ ) : (
+ <>
+ <AreaChart series={[series]} colors={['var(--cyan)']} height={220} />
+ <div className="mon-statstrip">
+ {[
+ ['Average', stats.avg != null ? `${stats.avg} ms` : '—'],
+ ['Fastest', stats.min != null ? `${stats.min} ms` : '—'],
+ ['Slowest', stats.max != null ? `${stats.max} ms` : '—'],
+ ['p95', stats.p95 != null ? `${stats.p95} ms` : '—'],
+ ['Samples', series.length],
+ ].map(([label, value]) => (
+ <div key={label}>
+ <span className="mon-statstrip__label">{label}</span>
+ <span className="mon-statstrip__value">{value}</span>
+ </div>
+ ))}
+ </div>
+ </>
+ )}
+ </div>
+ )}
+
+ {section === 'uptime' && (
+ <div className="mon-stack">
+ <div className="mon-panel">
+ <div className="mon-panel__header">
+ <div>
+ <h3>Uptime — last 90 days</h3>
+ <span className="mon-panel-sub">Click a day for its detail</span>
+ </div>
+ <div className="mon-uptime-summary">
+ {[['24h', monitor.uptime_24h], ['7d', monitor.uptime_7d],
+ ['30d', monitor.uptime_30d], ['90d', monitor.uptime_90d]].map(([label, value]) => (
+ <div key={label}>
+ <span className="mon-statstrip__label">{label}</span>
+ <span className="mon-statstrip__value">{formatUptime(value)}</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ <UptimeBars
+ days={uptime?.days || []}
+ selected={selectedDay?.date}
+ onSelect={(day) => setSelectedDay(selectedDay?.date === day.date ? null : day)}
+ />
+ <div className="mon-uptime-axis">
+ <span>90 days ago</span>
+ <span>today</span>
+ </div>
+ </div>
+
+ {selectedDay && (
+ <div className="mon-panel">
+ <div className="mon-panel__header">
+ <div>
+ <h3>{selectedDay.date}</h3>
+ <span className="mon-panel-sub">
+ {selectedDay.state === 'none'
+ ? 'Not monitored on this day'
+ : `${selectedDay.checks} checks · ${selectedDay.down_checks} failed · ${formatUptime(selectedDay.uptime)} uptime`}
+ </span>
+ </div>
+ <Button variant="ghost" size="sm" onClick={() => setSelectedDay(null)}>Close</Button>
+ </div>
+ </div>
+ )}
+
+ <div className="mon-panel">
+ <div className="mon-panel__header">
+ <div>
+ <h3>Certificate</h3>
+ <span className="mon-panel-sub">Read from the last https probe</span>
+ </div>
+ {certDays != null && (
+ <Pill kind={certDays < 0 ? 'red' : certDays < 21 ? 'amber' : 'green'}>
+ {certDays < 0 ? 'expired' : 'valid'}
+ </Pill>
+ )}
+ </div>
+ {monitor.cert_expires_at ? (
+ <dl className="mon-inforows">
+ <div><dt>Issuer</dt><dd>{monitor.cert_issuer || '—'}</dd></div>
+ <div><dt>Expires</dt><dd>{new Date(monitor.cert_expires_at).toLocaleDateString()}</dd></div>
+ <div>
+ <dt>Remaining</dt>
+ <dd>{certDays < 0 ? `${-certDays} days ago` : `${certDays} days`}</dd>
+ </div>
+ </dl>
+ ) : (
+ <p className="mon-panel-hint">
+ {isHttpish && monitor.check_target?.startsWith('https://')
+ ? 'Not read yet — it is captured on the next probe.'
+ : 'This check does not negotiate TLS.'}
+ </p>
+ )}
+ </div>
+ </div>
+ )}
+
+ {section === 'checks' && (
+ <div className="mon-panel mon-panel--flush">
+ <div className="mon-panel__header">
+ <div>
+ <h3>Check log</h3>
+ <span className="mon-panel-sub">
+ {rows.length} result{rows.length === 1 ? '' : 's'} · {frozen ? 'frozen' : 'live'}
+ </span>
+ </div>
+ <div className="mon-panel__actions">
+ {frozen && newSinceFreeze > 0 && (
+ <Pill kind="cyan">{newSinceFreeze} new</Pill>
+ )}
+ <Button variant="outline" size="sm" onClick={() => setFrozen(frozen ? null : checks)}>
+ {frozen ? <><Play size={14} /> Resume</> : <><Pause size={14} /> Hold</>}
+ </Button>
+ </div>
+ </div>
+ <DataTable
+ tableClassName="sk-dtable monitor-checks-table"
+ sortable={false}
+ data={rows}
+ keyField="id"
+ rowClassName={(c) => (c.status === 'up' ? undefined : 'is-bad')}
+ emptyState={(
+ <div className="mon-empty">
+ <p>No checks in this window yet.</p>
+ </div>
+ )}
+ columns={[
+ {
+ key: 'checked_at',
+ header: 'Time',
+ render: (c) => new Date(c.checked_at).toLocaleTimeString(),
+ },
+ {
+ key: 'status',
+ header: 'Result',
+ render: (c) => (
+ <span className={`mon-code mon-code--${c.status === 'up' ? 'ok' : 'bad'}`}>
+ {c.status_code ?? c.status}
+ </span>
+ ),
+ },
+ {
+ key: 'response_time',
+ header: 'Latency',
+ render: (c) => (c.response_time == null ? '—' : `${c.response_time} ms`),
+ },
+ {
+ key: 'error',
+ header: 'Detail',
+ cellClassName: 'mon-checkdetail',
+ render: (c) => c.error || `${monitor.check_method || 'GET'} ${monitor.check_target}`,
+ },
+ ]}
+ />
+ </div>
+ )}
+
+ {section === 'config' && (
+ <div className="mon-grid-2">
+ <div className="mon-panel">
+ <div className="mon-panel__header"><div><h3>Check</h3></div></div>
+ <dl className="mon-inforows">
+ <div><dt>Type</dt><dd>{monitor.check_type}</dd></div>
+ <div><dt>Target</dt><dd>{monitor.check_target || 'bound site'}</dd></div>
+ <div><dt>Interval</dt><dd>{monitor.check_interval}s</dd></div>
+ <div><dt>Timeout</dt><dd>{monitor.check_timeout}s</dd></div>
+ {isHttpish && <div><dt>Method</dt><dd>{monitor.check_method}</dd></div>}
+ {isHttpish && <div><dt>Expected</dt><dd>{monitor.expected_status}</dd></div>}
+ {monitor.check_type === 'keyword' && (
+ <div><dt>Keyword</dt><dd>{monitor.keyword || '—'}</dd></div>
+ )}
+ {isHttpish && (
+ <div><dt>Follow redirects</dt><dd>{monitor.follow_redirects ? 'yes' : 'no'}</dd></div>
+ )}
+ {isHttpish && <div><dt>Verify TLS</dt><dd>{monitor.verify_tls ? 'yes' : 'no'}</dd></div>}
+ </dl>
+ </div>
+
+ <div className="mon-panel">
+ <div className="mon-panel__header">
+ <div>
+ <h3>Alerting</h3>
+ <span className="mon-panel-sub">Delivery is configured in Settings → Notifications</span>
+ </div>
+ </div>
+ <dl className="mon-inforows">
+ <div>
+ <dt>Open an incident after</dt>
+ <dd>{(monitor.retries ?? 0) + 1} failed check{(monitor.retries ?? 0) + 1 === 1 ? '' : 's'}</dd>
+ </div>
+ <div><dt>Current failure streak</dt><dd>{monitor.consecutive_failures ?? 0}</dd></div>
+ <div>
+ <dt>Published on a status page</dt>
+ <dd>{monitor.page_id ? 'yes' : 'no'}</dd>
+ </div>
+ </dl>
+ <div className="mon-panel__footer">
+ <Button variant="ghost" size="sm" className="mon-danger" onClick={onDelete}>
+ <Trash2 size={14} /> Delete monitor
+ </Button>
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/frontend/src/pages/Monitors.jsx b/frontend/src/pages/Monitors.jsx
new file mode 100644
index 00000000..cec00037
--- /dev/null
+++ b/frontend/src/pages/Monitors.jsx
@@ -0,0 +1,491 @@
+// Monitors — the synthetic-check list (watch a URL, a service, a WordPress site).
+//
+// Tab-group page (the Domains/Cron/Jobs pattern): the group's shared PageTopbar
+// carries SearchField + FilterDrawer + Refresh + "Add monitor" via
+// useTopbarActions, so there is no second header inside the page. Clickable KPI
+// tiles are the quick status filter; the drawer owns type + status together.
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import {
+ Activity, AlertTriangle, ChevronRight, Globe, Pause, Play, Plus, Radar,
+ RefreshCw, ShieldAlert, Zap,
+} from 'lucide-react';
+import api from '../services/api';
+import { useToast } from '../contexts/ToastContext';
+import EmptyState from '../components/EmptyState';
+import {
+ DataTable, Drawer, FilterButton, FilterDrawer, KpiBand, MetricCard, Pill,
+ SearchField, Sparkline, countActiveFilters,
+} from '@/components/ds';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Switch } from '@/components/ui/switch';
+import { useTopbarActions } from '@/hooks/useTopbarActions';
+import { CHECK_TYPES, MONITOR_STATUS, monitorStateOf } from '../components/monitoring/monitorShared';
+
+const POLL_MS = 15000;
+
+const emptyForm = {
+ name: '',
+ check_type: 'http',
+ check_target: '',
+ check_interval: 60,
+ check_timeout: 10,
+ check_method: 'GET',
+ expected_status: '200-299',
+ keyword: '',
+ follow_redirects: true,
+ verify_tls: true,
+ retries: 2,
+};
+
+const TARGET_PLACEHOLDER = {
+ http: 'https://example.com/health',
+ keyword: 'https://example.com/',
+ tcp: 'db.example.com:5432',
+ dns: 'example.com',
+ smtp: 'mail.example.com:25',
+ ping: 'example.com',
+};
+
+function relativeTime(iso) {
+ if (!iso) return 'never';
+ const then = new Date(iso).getTime();
+ if (Number.isNaN(then)) return '—';
+ const seconds = Math.round((Date.now() - then) / 1000);
+ if (seconds < 0) return 'in a moment';
+ if (seconds < 5) return 'just now';
+ if (seconds < 60) return `${seconds}s ago`;
+ if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
+ if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
+ return `${Math.floor(seconds / 86400)}d ago`;
+}
+
+function countdown(iso) {
+ if (!iso) return '—';
+ const seconds = Math.round((new Date(iso).getTime() - Date.now()) / 1000);
+ if (Number.isNaN(seconds)) return '—';
+ if (seconds <= 0) return 'due';
+ if (seconds < 60) return `${seconds}s`;
+ return `${Math.floor(seconds / 60)}m`;
+}
+
+function formatUptime(value) {
+ if (value == null) return '—';
+ return `${Number(value).toFixed(2)}%`;
+}
+
+export default function Monitors() {
+ const navigate = useNavigate();
+ const toast = useToast();
+
+ const [monitors, setMonitors] = useState([]);
+ const [stats, setStats] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [q, setQ] = useState('');
+ const [filters, setFilters] = useState({ status: '', type: '' });
+ const [filtersOpen, setFiltersOpen] = useState(false);
+ const [formOpen, setFormOpen] = useState(false);
+ const [form, setForm] = useState(emptyForm);
+ const [saving, setSaving] = useState(false);
+ // Bumps once a second so "next check in 42s" actually counts down between
+ // polls instead of sitting still for 15 seconds at a time.
+ const [, setTick] = useState(0);
+ const pollRef = useRef(null);
+
+ const load = useCallback(async () => {
+ try {
+ const [listRes, statsRes] = await Promise.all([
+ api.getMonitors({ q: q || undefined, status: filters.status || undefined, type: filters.type || undefined }),
+ api.getMonitorStats().catch(() => null),
+ ]);
+ setMonitors(listRes?.monitors || []);
+ setStats(statsRes?.stats || null);
+ } catch {
+ // Keep the last good list on screen rather than blanking the page.
+ } finally {
+ setLoading(false);
+ }
+ }, [q, filters.status, filters.type]);
+
+ useEffect(() => {
+ load();
+ pollRef.current = setInterval(load, POLL_MS);
+ return () => clearInterval(pollRef.current);
+ }, [load]);
+
+ useEffect(() => {
+ const timer = setInterval(() => setTick((n) => n + 1), 1000);
+ return () => clearInterval(timer);
+ }, []);
+
+ const activeFilterCount = countActiveFilters(filters);
+ const setStatusQuick = (value) => setFilters((f) => ({ ...f, status: f.status === value ? '' : value }));
+
+ const openCreate = () => { setForm(emptyForm); setFormOpen(true); };
+
+ useTopbarActions(() => (
+ <>
+ <SearchField value={q} onSearch={(value) => setQ(value.trim())} placeholder="Search monitors or targets…" />
+ <FilterButton count={activeFilterCount} onClick={() => setFiltersOpen(true)} />
+ <Button variant="outline" size="sm" onClick={load}>
+ <RefreshCw size={14} /> Refresh
+ </Button>
+ <Button size="sm" onClick={openCreate}>
+ <Plus size={14} /> Add monitor
+ </Button>
+ </>
+ ), [q, activeFilterCount, load]);
+
+ const onSave = async (e) => {
+ e.preventDefault();
+ setSaving(true);
+ try {
+ const payload = { ...form };
+ if (payload.check_type !== 'keyword') delete payload.keyword;
+ if (!['http', 'keyword'].includes(payload.check_type)) {
+ delete payload.check_method;
+ delete payload.expected_status;
+ delete payload.follow_redirects;
+ }
+ await api.createMonitor(payload);
+ toast.success(`Monitoring ${form.name}`);
+ setFormOpen(false);
+ load();
+ } catch (err) {
+ toast.error(err.message || 'Could not create the monitor');
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ const onTogglePause = async (monitor) => {
+ try {
+ await api.setMonitorPaused(monitor.id, !monitor.is_paused);
+ toast.success(monitor.is_paused ? `Resumed ${monitor.name}` : `Paused ${monitor.name}`);
+ load();
+ } catch (err) {
+ toast.error(err.message || 'Could not change the monitor');
+ }
+ };
+
+ const onCheckNow = async (monitor) => {
+ try {
+ const res = await api.runMonitorCheck(monitor.id);
+ const check = res?.check;
+ if (check?.status === 'up') toast.success(`${monitor.name}: up in ${check.response_time ?? '—'} ms`);
+ else toast.warning(`${monitor.name}: ${check?.status || 'failed'}${check?.error ? ` — ${check.error}` : ''}`);
+ load();
+ } catch (err) {
+ toast.error(err.message || 'Check failed');
+ }
+ };
+
+ const filterGroups = useMemo(() => ([
+ {
+ key: 'status',
+ label: 'Status',
+ type: 'single',
+ options: MONITOR_STATUS.map((s) => ({ value: s.value, label: s.label })),
+ },
+ {
+ key: 'type',
+ label: 'Check type',
+ type: 'single',
+ options: CHECK_TYPES.map((t) => ({ value: t.value, label: t.label })),
+ },
+ ]), []);
+
+ const columns = [
+ {
+ key: 'name',
+ header: 'Monitor',
+ render: (m) => (
+ <div className="sk-cell-name">
+ <span className="mon-ico"><Globe size={15} /></span>
+ <div className="mon-namecell">
+ <div className="mon-namecell__name">{m.name}</div>
+ <div className="mon-namecell__target">{m.check_target || 'bound site'}</div>
+ </div>
+ </div>
+ ),
+ },
+ {
+ key: 'check_type',
+ header: 'Type',
+ render: (m) => <span className="mon-type">{m.check_type}</span>,
+ },
+ {
+ key: 'status',
+ header: 'Status',
+ render: (m) => {
+ const state = monitorStateOf(m);
+ return <Pill kind={state.tone}>{state.label}</Pill>;
+ },
+ },
+ {
+ key: 'response',
+ header: 'Response',
+ render: (m) => {
+ if (m.last_response_time == null) return <span className="mon-muted">—</span>;
+ const slow = m.last_response_time > 300;
+ return (
+ <div className="mon-response">
+ {m.spark?.length > 1 && (
+ <Sparkline
+ data={m.spark}
+ width={44}
+ height={18}
+ color={slow ? 'var(--amber)' : 'var(--green)'}
+ />
+ )}
+ <span className={slow ? 'mon-response__ms is-slow' : 'mon-response__ms'}>
+ {m.last_response_time} ms
+ </span>
+ </div>
+ );
+ },
+ },
+ {
+ key: 'uptime_30d',
+ header: 'Uptime (30d)',
+ render: (m) => <span className="mon-uptime">{formatUptime(m.uptime_30d)}</span>,
+ },
+ {
+ key: 'last_check_at',
+ header: 'Last check',
+ render: (m) => (
+ <span className="mon-muted">{m.is_paused ? 'paused' : relativeTime(m.last_check_at)}</span>
+ ),
+ },
+ {
+ key: 'next_check_at',
+ header: 'Next check',
+ render: (m) => <span className="mon-muted">{m.is_paused ? '—' : countdown(m.next_check_at)}</span>,
+ },
+ {
+ key: 'actions',
+ header: '',
+ className: 'mon-actions-col',
+ cellClassName: 'mon-actions-cell',
+ render: (m) => (
+ <div className="mon-actions" onClick={(e) => e.stopPropagation()}>
+ <Button variant="ghost" size="sm" onClick={() => onCheckNow(m)} title="Check now">
+ <RefreshCw size={14} />
+ </Button>
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => onTogglePause(m)}
+ title={m.is_paused ? 'Resume' : 'Pause'}
+ >
+ {m.is_paused ? <Play size={14} /> : <Pause size={14} />}
+ </Button>
+ <Button variant="ghost" size="sm" onClick={() => navigate(`/monitoring/monitors/${m.id}`)} title="Open">
+ <ChevronRight size={14} />
+ </Button>
+ </div>
+ ),
+ },
+ ];
+
+ const hasFilters = Boolean(q || filters.status || filters.type);
+ const isHttpish = ['http', 'keyword'].includes(form.check_type);
+
+ return (
+ <div className="sk-tabgroup__inner monitors-page">
+ <KpiBand>
+ <MetricCard
+ label="Operational" value={stats?.operational ?? 0} tone="green" compact
+ icon={<Activity size={17} />}
+ onClick={() => setStatusQuick('operational')}
+ />
+ <MetricCard
+ label="Degraded" value={stats?.degraded ?? 0} tone="amber" compact
+ icon={<AlertTriangle size={17} />}
+ onClick={() => setStatusQuick('degraded')}
+ />
+ <MetricCard
+ label="Down" value={stats?.down ?? 0} tone="red" compact
+ icon={<ShieldAlert size={17} />}
+ onClick={() => setStatusQuick('major_outage')}
+ />
+ <MetricCard
+ label="Uptime (30d)"
+ value={stats?.overall_uptime_30d != null ? `${stats.overall_uptime_30d}%` : '—'}
+ tone="accent" icon={<Zap size={17} />}
+ />
+ </KpiBand>
+
+ {loading && monitors.length === 0 ? (
+ <EmptyState loading loadingVariant="table" title="Loading monitors" />
+ ) : monitors.length === 0 ? (
+ <EmptyState
+ icon={Radar}
+ title={hasFilters ? 'No monitors match' : 'Nothing is being watched yet'}
+ description={hasFilters
+ ? 'Try a different search or clear the filters.'
+ : 'Add a monitor to watch a website, an API endpoint, a database port or a WordPress site — and get an incident when it stops answering.'}
+ action={hasFilters
+ ? <Button variant="outline" onClick={() => { setQ(''); setFilters({ status: '', type: '' }); }}>Clear filters</Button>
+ : <Button onClick={openCreate}><Plus size={16} /> Add monitor</Button>}
+ />
+ ) : (
+ <div className="mon-card">
+ <DataTable
+ tableClassName="sk-dtable monitors-table"
+ sortable={false}
+ data={monitors}
+ keyField="id"
+ columns={columns}
+ onRowClick={(m) => navigate(`/monitoring/monitors/${m.id}`)}
+ rowClassName={(m) => (m.is_paused ? 'is-disabled' : undefined)}
+ />
+ </div>
+ )}
+
+ <FilterDrawer
+ open={filtersOpen}
+ onOpenChange={setFiltersOpen}
+ groups={filterGroups}
+ value={filters}
+ onChange={setFilters}
+ title="Filter monitors"
+ />
+
+ <Drawer
+ open={formOpen}
+ onOpenChange={setFormOpen}
+ title="Add monitor"
+ subtitle="Probe a URL, host or port on a schedule"
+ icon={<Radar size={18} />}
+ >
+ <form className="mon-form" onSubmit={onSave}>
+ <div className="form-group">
+ <Label htmlFor="mon-name">Name</Label>
+ <Input
+ id="mon-name" required value={form.name}
+ onChange={(e) => setForm({ ...form, name: e.target.value })}
+ placeholder="Marketing site"
+ />
+ </div>
+
+ <div className="form-group">
+ <Label htmlFor="mon-type">Check type</Label>
+ <select
+ id="mon-type" className="mon-select" value={form.check_type}
+ onChange={(e) => setForm({ ...form, check_type: e.target.value })}
+ >
+ {CHECK_TYPES.map((t) => (
+ <option key={t.value} value={t.value}>{t.label} — {t.hint}</option>
+ ))}
+ </select>
+ </div>
+
+ <div className="form-group">
+ <Label htmlFor="mon-target">Target</Label>
+ <Input
+ id="mon-target" required value={form.check_target}
+ onChange={(e) => setForm({ ...form, check_target: e.target.value })}
+ placeholder={TARGET_PLACEHOLDER[form.check_type]}
+ />
+ </div>
+
+ {form.check_type === 'keyword' && (
+ <div className="form-group">
+ <Label htmlFor="mon-keyword">Keyword</Label>
+ <Input
+ id="mon-keyword" required value={form.keyword}
+ onChange={(e) => setForm({ ...form, keyword: e.target.value })}
+ placeholder="Proceed to checkout"
+ />
+ <span className="form-help">
+ A 200 response without this text counts as an outage.
+ </span>
+ </div>
+ )}
+
+ <div className="mon-form__row">
+ <div className="form-group">
+ <Label htmlFor="mon-interval">Interval (s)</Label>
+ <Input
+ id="mon-interval" type="number" min="30" max="86400" value={form.check_interval}
+ onChange={(e) => setForm({ ...form, check_interval: Number(e.target.value) })}
+ />
+ </div>
+ <div className="form-group">
+ <Label htmlFor="mon-timeout">Timeout (s)</Label>
+ <Input
+ id="mon-timeout" type="number" min="1" max="120" value={form.check_timeout}
+ onChange={(e) => setForm({ ...form, check_timeout: Number(e.target.value) })}
+ />
+ </div>
+ <div className="form-group">
+ <Label htmlFor="mon-retries">Retries</Label>
+ <Input
+ id="mon-retries" type="number" min="0" max="10" value={form.retries}
+ onChange={(e) => setForm({ ...form, retries: Number(e.target.value) })}
+ />
+ <span className="form-help">Failed checks tolerated before an incident opens.</span>
+ </div>
+ </div>
+
+ {isHttpish && (
+ <>
+ <div className="mon-form__row">
+ <div className="form-group">
+ <Label htmlFor="mon-method">Method</Label>
+ <select
+ id="mon-method" className="mon-select" value={form.check_method}
+ onChange={(e) => setForm({ ...form, check_method: e.target.value })}
+ >
+ {['GET', 'HEAD', 'POST', 'PUT', 'OPTIONS'].map((m) => (
+ <option key={m} value={m}>{m}</option>
+ ))}
+ </select>
+ </div>
+ <div className="form-group">
+ <Label htmlFor="mon-expected">Expected status</Label>
+ <Input
+ id="mon-expected" value={form.expected_status}
+ onChange={(e) => setForm({ ...form, expected_status: e.target.value })}
+ placeholder="200-299"
+ />
+ </div>
+ </div>
+
+ <div className="mon-switch-row">
+ <div>
+ <strong>Follow redirects</strong>
+ <span>A 30x lands on its destination before grading.</span>
+ </div>
+ <Switch
+ checked={form.follow_redirects}
+ onCheckedChange={(v) => setForm({ ...form, follow_redirects: v })}
+ />
+ </div>
+ <div className="mon-switch-row">
+ <div>
+ <strong>Verify TLS</strong>
+ <span>Off for self-signed certificates on internal hosts.</span>
+ </div>
+ <Switch
+ checked={form.verify_tls}
+ onCheckedChange={(v) => setForm({ ...form, verify_tls: v })}
+ />
+ </div>
+ </>
+ )}
+
+ <div className="mon-form__actions">
+ <Button type="button" variant="ghost" onClick={() => setFormOpen(false)}>Cancel</Button>
+ <Button type="submit" disabled={saving}>
+ {saving ? 'Adding…' : 'Add monitor'}
+ </Button>
+ </div>
+ </form>
+ </Drawer>
+ </div>
+ );
+}
diff --git a/frontend/src/services/api/monitors.js b/frontend/src/services/api/monitors.js
new file mode 100644
index 00000000..40d970a8
--- /dev/null
+++ b/frontend/src/services/api/monitors.js
@@ -0,0 +1,89 @@
+// Monitors — synthetic uptime checks (http / keyword / tcp / dns / smtp / ping)
+// and the incidents they raise. Core API: /api/v1/monitors.
+
+export async function getMonitors(params = {}) {
+ const query = new URLSearchParams();
+ if (params.status) query.append('status', params.status);
+ if (params.type) query.append('type', params.type);
+ if (params.q) query.append('q', params.q);
+ if (params.page_id != null) query.append('page_id', params.page_id);
+ const suffix = query.toString() ? `?${query}` : '';
+ return this.request(`/monitors${suffix}`);
+}
+
+export async function getMonitorStats() {
+ return this.request('/monitors/stats');
+}
+
+export async function getMonitor(monitorId) {
+ return this.request(`/monitors/${monitorId}`);
+}
+
+export async function createMonitor(data) {
+ return this.request('/monitors', {
+ method: 'POST',
+ body: JSON.stringify(data),
+ });
+}
+
+export async function updateMonitor(monitorId, data) {
+ return this.request(`/monitors/${monitorId}`, {
+ method: 'PATCH',
+ body: JSON.stringify(data),
+ });
+}
+
+export async function deleteMonitor(monitorId) {
+ return this.request(`/monitors/${monitorId}`, { method: 'DELETE' });
+}
+
+export async function runMonitorCheck(monitorId) {
+ return this.request(`/monitors/${monitorId}/check`, { method: 'POST' });
+}
+
+export async function setMonitorPaused(monitorId, paused) {
+ return this.request(`/monitors/${monitorId}/pause`, {
+ method: 'POST',
+ body: JSON.stringify({ paused }),
+ });
+}
+
+export async function getMonitorHistory(monitorId, params = {}) {
+ const query = new URLSearchParams();
+ if (params.hours) query.append('hours', params.hours);
+ if (params.limit) query.append('limit', params.limit);
+ const suffix = query.toString() ? `?${query}` : '';
+ return this.request(`/monitors/${monitorId}/history${suffix}`);
+}
+
+export async function getMonitorUptime(monitorId, days = 90) {
+ return this.request(`/monitors/${monitorId}/uptime?days=${days}`);
+}
+
+// --- Incidents ---
+
+export async function getIncidents(params = {}) {
+ const query = new URLSearchParams();
+ if (params.state) query.append('state', params.state);
+ if (params.limit) query.append('limit', params.limit);
+ const suffix = query.toString() ? `?${query}` : '';
+ return this.request(`/monitors/incidents${suffix}`);
+}
+
+export async function createIncident(data) {
+ return this.request('/monitors/incidents', {
+ method: 'POST',
+ body: JSON.stringify(data),
+ });
+}
+
+export async function updateIncident(incidentId, data) {
+ return this.request(`/monitors/incidents/${incidentId}`, {
+ method: 'PATCH',
+ body: JSON.stringify(data),
+ });
+}
+
+export async function deleteIncident(incidentId) {
+ return this.request(`/monitors/incidents/${incidentId}`, { method: 'DELETE' });
+}
diff --git a/frontend/src/styles/pages/_monitors.scss b/frontend/src/styles/pages/_monitors.scss
new file mode 100644
index 00000000..c9ffa19b
--- /dev/null
+++ b/frontend/src/styles/pages/_monitors.scss
@@ -0,0 +1,578 @@
+// ============================================
+// MONITORS — list, detail, incidents, uptime strip
+// ============================================
+// Shared `mon-*` panel/section/hint rules come from _monitoring.scss, whose
+// root selector list includes these pages. Only what is new lives here.
+
+// ── panels ──────────────────────────────────────────────────
+.monitors-page,
+.incidents-page,
+.monitor-detail {
+
+ .mon-stack { display: flex; flex-direction: column; gap: 16px; }
+
+ .mon-grid-2 {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
+ gap: 16px;
+ }
+
+ .mon-panel {
+ background: var(--bg-card, var(--surface-1));
+ border: 1px solid var(--border-soft);
+ border-radius: 12px;
+ padding: 18px;
+
+ &--flush { padding: 18px 0 0; }
+ &--flush .mon-panel__header { padding: 0 18px; }
+ }
+
+ .mon-panel__header {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+ margin-bottom: 14px;
+
+ h3 {
+ margin: 0;
+ font-family: var(--mono);
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ color: var(--text-faint);
+ }
+ }
+
+ .mon-panel__actions { display: flex; align-items: center; gap: 8px; }
+
+ .mon-panel__footer {
+ margin-top: 14px;
+ padding-top: 12px;
+ border-top: 1px solid var(--border-soft);
+ }
+
+ .mon-danger { color: var(--red); }
+
+ // Definition rows: key on the left, value right-aligned in mono.
+ .mon-inforows {
+ margin: 0;
+ display: flex;
+ flex-direction: column;
+
+ > div {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 9px 0;
+ border-bottom: 1px solid var(--border-soft);
+
+ &:last-child { border-bottom: none; }
+ }
+
+ dt {
+ font-size: 12.5px;
+ color: var(--text-faint);
+ }
+
+ dd {
+ margin: 0;
+ font-family: var(--mono);
+ font-size: 12.5px;
+ color: var(--text-dim);
+ text-align: right;
+ word-break: break-word;
+ }
+ }
+
+ .mon-empty {
+ padding: 26px 18px;
+ font-size: 13px;
+ color: var(--text-faint);
+ }
+
+ // Check result code chip (200 / down / ok).
+ .mon-code {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 7px;
+ border-radius: 5px;
+ font-family: var(--mono);
+ font-size: 11px;
+ font-weight: 600;
+
+ &--ok { background: var(--green-bg, rgba(63, 185, 80, 0.14)); color: var(--green); }
+ &--bad { background: var(--red-bg, rgba(248, 81, 73, 0.14)); color: var(--red); }
+ }
+}
+
+// ── list ────────────────────────────────────────────────────
+.monitors-page {
+
+ .mon-card {
+ background: var(--bg-card, var(--surface-1));
+ border: 1px solid var(--border-soft);
+ border-radius: 12px;
+ overflow: hidden;
+ }
+
+ .mon-namecell__name { font-weight: 550; }
+
+ .mon-namecell__target {
+ display: block;
+ max-width: 260px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--text-faint);
+ }
+
+ .mon-type {
+ display: inline-flex;
+ padding: 2px 8px;
+ border-radius: 999px;
+ border: 1px solid var(--border);
+ font-family: var(--mono);
+ font-size: 10.5px;
+ text-transform: uppercase;
+ letter-spacing: 0.03em;
+ color: var(--text-dim);
+ }
+
+ .mon-response {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ }
+
+ .mon-response__ms {
+ font-family: var(--mono);
+ font-size: 12px;
+ color: var(--text-dim);
+
+ &.is-slow { color: var(--amber); }
+ }
+
+ .mon-uptime,
+ .mon-muted {
+ font-family: var(--mono);
+ font-size: 12px;
+ color: var(--text-dim);
+ }
+
+ .mon-muted { color: var(--text-faint); }
+
+ .mon-actions-col { width: 118px; }
+ .mon-actions-cell { text-align: right; }
+ .mon-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
+
+ tr.is-disabled { opacity: 0.55; }
+
+ // Create-monitor drawer
+ .mon-form {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ padding: 18px;
+ }
+
+ .mon-form__row {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
+ gap: 12px;
+ }
+
+ .mon-form__actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ padding-top: 6px;
+ border-top: 1px solid var(--border-soft);
+ }
+
+ .mon-select {
+ width: 100%;
+ height: 36px;
+ padding: 0 10px;
+ border-radius: 8px;
+ border: 1px solid var(--border);
+ background: var(--surface-2);
+ color: var(--text);
+ font-family: inherit;
+ font-size: 13px;
+ }
+
+ .mon-switch-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ padding: 12px 0;
+ border-top: 1px solid var(--border-soft);
+
+ strong { display: block; font-size: 13px; font-weight: 550; }
+ span { font-size: 12px; color: var(--text-faint); }
+ }
+}
+
+// ── detail ──────────────────────────────────────────────────
+.monitor-detail {
+
+ .monitor-detail__crumb {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 14px;
+ font-size: 12.5px;
+ color: var(--text-faint);
+
+ a { color: var(--accent-bright); text-decoration: none; }
+ a:hover { text-decoration: underline; }
+ }
+
+ .monitor-detail__sections { margin: 18px 0 16px; }
+
+ .mon-kpi-sub {
+ margin-top: 4px;
+ font-family: var(--mono);
+ font-size: 10.5px;
+ color: var(--text-faint);
+ }
+
+ .mon-statstrip {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
+ gap: 12px;
+ margin-top: 14px;
+ padding-top: 14px;
+ border-top: 1px solid var(--border-soft);
+ }
+
+ .mon-statstrip__label {
+ display: block;
+ font-family: var(--mono);
+ font-size: 10px;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ color: var(--text-faint);
+ }
+
+ .mon-statstrip__value {
+ display: block;
+ margin-top: 3px;
+ font-family: var(--mono);
+ font-size: 15px;
+ font-weight: 600;
+ }
+
+ .mon-uptime-summary { display: flex; gap: 18px; text-align: right; }
+
+ .mon-uptime-axis {
+ display: flex;
+ justify-content: space-between;
+ margin-top: 8px;
+ font-family: var(--mono);
+ font-size: 10.5px;
+ color: var(--text-faint);
+ }
+
+ .mon-checkdetail {
+ max-width: 380px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ font-family: var(--mono);
+ font-size: 11.5px;
+ color: var(--text-faint);
+ }
+
+ tr.is-bad .mon-checkdetail { color: var(--red); }
+}
+
+// ── 90-day uptime strip ─────────────────────────────────────
+.uptime-bars {
+ display: flex;
+ align-items: stretch;
+ gap: 2px;
+ height: 52px;
+ width: 100%;
+
+ &__bar {
+ flex: 1 1 0;
+ min-width: 3px;
+ padding: 0;
+ border: none;
+ border-radius: 2px;
+ background: var(--green);
+ cursor: pointer;
+ transition: opacity 0.12s, transform 0.12s;
+
+ &:hover { opacity: 0.75; }
+ &.is-selected { transform: scaleY(1.06); outline: 1px solid var(--text-dim); }
+
+ // "We weren't watching" is not the same fact as "it was fine".
+ &--none { background: var(--border-soft); cursor: default; }
+ &--partial { background: var(--amber); }
+ &--down { background: var(--red); }
+ }
+}
+
+// ── overview: monitors summary ──────────────────────────────
+.monitoring-page {
+
+ .mon-monitors-summary {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ margin-bottom: 22px;
+ }
+
+ .mon-nomonitors { margin-bottom: 22px; }
+
+ .mon-monitor-list,
+ .mon-feed { display: flex; flex-direction: column; }
+
+ .mon-monitor-row,
+ .mon-feed-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 10px 0;
+ border-bottom: 1px solid var(--border-soft);
+ color: inherit;
+ text-decoration: none;
+
+ &:last-child { border-bottom: none; }
+ &:hover { background: var(--surface-2); }
+ }
+
+ .mon-monitor-row__body,
+ .mon-feed-row__body { flex: 1; min-width: 0; }
+
+ .mon-monitor-row__name,
+ .mon-feed-row__name {
+ display: block;
+ font-size: 13px;
+ font-weight: 550;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .mon-monitor-row__sub,
+ .mon-feed-row__sub {
+ display: block;
+ font-family: var(--mono);
+ font-size: 10.5px;
+ color: var(--text-faint);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .mon-monitor-row__ms,
+ .mon-feed-row__ms {
+ font-family: var(--mono);
+ font-size: 12px;
+ color: var(--text-dim);
+ }
+}
+
+// ── incidents ───────────────────────────────────────────────
+.incidents-page {
+
+ .incidents-listhead {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 16px;
+ flex-wrap: wrap;
+ margin: 18px 0 14px;
+ }
+
+ .incidents-listhead__meta {
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--text-faint);
+ }
+
+ .incidents-list {
+ background: var(--bg-card, var(--surface-1));
+ border: 1px solid var(--border-soft);
+ border-radius: 12px;
+ overflow: hidden;
+ }
+
+ .incident-row {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ width: 100%;
+ padding: 14px 18px;
+ border: none;
+ border-top: 1px solid var(--border-soft);
+ background: transparent;
+ color: inherit;
+ text-align: left;
+ font: inherit;
+ cursor: pointer;
+
+ &:first-child { border-top: none; }
+ &:hover { background: var(--surface-2); }
+ }
+
+ .incident-row__sev {
+ flex-shrink: 0;
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: var(--text-ghost);
+
+ &--red { background: var(--red); box-shadow: 0 0 6px var(--red); }
+ &--amber { background: var(--amber); }
+ &--cyan { background: var(--cyan); }
+ &--green { background: var(--green); }
+ }
+
+ .incident-row__body { flex: 1; min-width: 0; }
+
+ .incident-row__title {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ flex-wrap: wrap;
+ font-size: 13.5px;
+ font-weight: 550;
+ }
+
+ .incident-row__sub {
+ display: block;
+ margin-top: 3px;
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--text-faint);
+ }
+
+ .incident-row__chev { flex-shrink: 0; color: var(--text-faint); }
+}
+
+// Incident drawer body
+.incident-detail {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ padding: 18px;
+
+ &__pills { display: flex; gap: 8px; flex-wrap: wrap; }
+
+ &__body { margin: 0; font-size: 13px; color: var(--text-dim); }
+
+ &__heading {
+ margin: 0;
+ font-family: var(--mono);
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ color: var(--text-faint);
+ }
+
+ &__link {
+ display: inline-flex;
+ align-items: center;
+ gap: 7px;
+ font-size: 13px;
+ color: var(--accent-bright);
+ text-decoration: none;
+
+ &:hover { text-decoration: underline; }
+ }
+
+ &__post { display: flex; flex-direction: column; gap: 10px; }
+
+ &__states { display: flex; gap: 6px; flex-wrap: wrap; }
+}
+
+.incident-timeline {
+ list-style: none;
+ margin: 0;
+ padding: 0 0 0 6px;
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+
+ &__item {
+ display: flex;
+ gap: 12px;
+ position: relative;
+ padding-left: 14px;
+ border-left: 1px solid var(--border-soft);
+
+ p { margin: 5px 0 0; font-size: 13px; }
+ }
+
+ &__dot {
+ position: absolute;
+ left: -5px;
+ top: 4px;
+ width: 9px;
+ height: 9px;
+ border-radius: 50%;
+ background: var(--text-ghost);
+
+ &.is-red { background: var(--red); }
+ &.is-amber { background: var(--amber); }
+ &.is-cyan { background: var(--cyan); }
+ &.is-green { background: var(--green); }
+ }
+
+ &__head {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--text-faint);
+ }
+}
+
+// ── status pages: attach an existing monitor ────────────────
+.status-attach-list {
+ display: flex;
+ flex-direction: column;
+ margin-top: 12px;
+
+ .status-attach-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ width: 100%;
+ padding: 11px 4px;
+ border: none;
+ border-bottom: 1px solid var(--border-soft);
+ background: transparent;
+ color: inherit;
+ text-align: left;
+ font: inherit;
+ cursor: pointer;
+
+ &:last-child { border-bottom: none; }
+ &:hover { background: var(--surface-2); }
+
+ &__body { min-width: 0; }
+
+ strong { display: block; font-size: 13px; font-weight: 550; }
+
+ span span,
+ &__body > span {
+ display: block;
+ margin-top: 2px;
+ font-family: var(--mono);
+ font-size: 11px;
+ color: var(--text-faint);
+ }
+ }
+}