Probes log locally only while the hub is unreachable; the hub confirms silences with that log

Probe: no access log, nothing written while reports get through. When the hub
can't be reached, failed reports go to data/outage.jsonl and unsent results to
data/backlog.jsonl (survives restarts). The first report that gets through
uploads both and they are deleted.

Hub: a probe that misses reports gets a "Not reporting" incident. When it
reports again, the runs from its outage log become confirmed "Hub unreachable"
incidents; the rest of the silence (probe off or restarting) is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-04 20:50:30 -08:00
parent 462525b1e2
commit be727949c1
13 changed files with 449 additions and 32 deletions

View file

@ -1,5 +1,6 @@
// Shared bits for the views.
import { el } from './ui.js';
import { ms } from './fmt.js';
/** The screen frame: toolbar, scrolling pane, status bar. Returns the parts. */
export function screen(root, toolbarItems) {
@ -73,3 +74,30 @@ export function every(ms, fn) {
const t = setInterval(() => { if (!document.hidden) fn(); }, ms);
return () => clearInterval(t);
}
// Incident cells, shared by Network health and a probe's page. kind "report" rows are stretches
// when a probe didn't report; the probe's local outage log confirms them when it reports again.
const METHOD_NAMES = { icmp: 'Ping', http: 'HTTP', dns: 'DNS' };
export function incidentTarget(i) {
if (i.kind === 'report') return el('span', {}, i.label);
return el('span', {}, i.label, el('span.muted.small', {}, ` ${i.methods.map((m) => METHOD_NAMES[m] || m).join(', ')}`));
}
export function incidentTypeText(i) {
if (i.kind !== 'report') return undefined;
return i.confirmed ? 'Hub unreachable' : 'Not reporting';
}
export function incidentChecks(i) {
if (i.kind === 'report') return i.confirmed ? `${i.failed} failed reports` : 'No reports';
return i.failed ? `${i.failed}/${i.samples} failed` : `${i.samples} slow`;
}
export function incidentDetail(i) {
if (i.kind === 'report') {
if (i.confirmed) return `The probe logged that it couldn’t reach the hub${i.error ? `: ${i.error}` : ''}`;
return 'Kept if the probe’s log shows it couldn’t reach the hub, removed if it was off';
}
return i.error || (i.max_latency ? `peak ${ms(i.max_latency)}` : '');
}

View file

@ -3,7 +3,7 @@ import { el, segmented, store } from '../ui.js';
import { get } from '../api.js';
import { STATUS, statusChip, statusLegend, strip, tipRow, tipTitle, hideTip, showTip } from '../charts.js';
import { axisTime, dur, ms, pct, when } from '../fmt.js';
import { RANGES, SPANS, every, errorBox, screen, section, table, fill } from '../common.js';
import { RANGES, SPANS, every, errorBox, screen, section, table, fill, incidentChecks, incidentDetail, incidentTarget, incidentTypeText } from '../common.js';
const METHOD = { icmp: 'Ping', http: 'HTTP', dns: 'DNS' };
@ -53,7 +53,7 @@ export function mount(root, ctx) {
section('Timeline', `${range} in ${st.buckets} slices of ${dur(st.width)}. A slice is down when half its checks fail, degraded when a fifth are slow or failing.`),
statusLegend(),
strips(st),
section('Incidents', `Slow means over ${inc.thresholds.lan_ms} ms on the LAN, ${inc.thresholds.wan_ms} ms to the internet, ${inc.thresholds.dns_ms} ms for DNS, or ${pct(inc.thresholds.loss)}+ ping loss.`),
section('Incidents', `Slow means over ${inc.thresholds.lan_ms} ms on the LAN, ${inc.thresholds.wan_ms} ms to the internet, ${inc.thresholds.dns_ms} ms for DNS, or ${pct(inc.thresholds.loss)}+ ping loss. A probe that stops reporting is kept as an incident only if its own log shows it couldn’t reach the hub.`),
incidents(inc.incidents),
);
}
@ -132,10 +132,10 @@ export function mount(root, ctx) {
el('td.nowrap', { title: when(i.start) }, when(i.start)),
el('td.nowrap', {}, i.ongoing ? el('span.chip.danger', {}, `Ongoing · ${dur(i.duration)}`) : dur(i.duration)),
el('td', {}, el('a', { href: `/probes/${i.probe_id}` }, i.probe)),
el('td', {}, i.label, el('span.muted.small', {}, ` ${i.methods.map((m) => METHOD[m] || m).join(', ')}`)),
el('td', {}, statusChip(i.type)),
el('td.num', {}, i.failed ? `${i.failed}/${i.samples} failed` : `${i.samples} slow`),
el('td.small', {}, i.error || (i.max_latency ? `peak ${ms(i.max_latency)}` : '')),
el('td', {}, incidentTarget(i)),
el('td', {}, statusChip(i.type, incidentTypeText(i))),
el('td.num', {}, incidentChecks(i)),
el('td.small', {}, incidentDetail(i)),
)), { empty: `No incidents in the last ${range}.` });
}

View file

@ -3,7 +3,7 @@ import { confirmDialog, copyText, el, modal, segmented, store, toast } from '../
import { del, get, patch, post } from '../api.js';
import { lineChart, seriesLegend, statusChip, statusLegend, strip, tipRow, tipTitle, hideTip, STATUS } from '../charts.js';
import { ago, axisTime, dur, mbps, ms, pct, when } from '../fmt.js';
import { RANGES, SPANS, every, errorBox, screen, section, table, fill } from '../common.js';
import { RANGES, SPANS, every, errorBox, screen, section, table, fill, incidentChecks, incidentDetail, incidentTarget, incidentTypeText } from '../common.js';
const METHOD = { icmp: 'Ping', http: 'HTTP', dns: 'DNS', throughput: 'Throughput' };
@ -173,10 +173,10 @@ function detail(root, ctx, id) {
table(['Started', 'Lasted', 'Target', 'Type', 'Checks', 'Detail'], inc.incidents.map((i) => el('tr', {},
el('td.nowrap', {}, when(i.start)),
el('td.nowrap', {}, i.ongoing ? el('span.chip.danger', {}, `Ongoing · ${dur(i.duration)}`) : dur(i.duration)),
el('td', {}, i.label, el('span.muted.small', {}, ` ${i.methods.map((m) => METHOD[m] || m).join(', ')}`)),
el('td', {}, statusChip(i.type)),
el('td.num', {}, i.failed ? `${i.failed}/${i.samples} failed` : `${i.samples} slow`),
el('td.small', {}, i.error || (i.max_latency ? `peak ${ms(i.max_latency)}` : '')))), { empty: `No incidents in the last ${range}.` }),
el('td', {}, incidentTarget(i)),
el('td', {}, statusChip(i.type, incidentTypeText(i))),
el('td.num', {}, incidentChecks(i)),
el('td.small', {}, incidentDetail(i)))), { empty: `No incidents in the last ${range}.` }),
);
}