Close an alert: dealt with or accepted, hidden until it gets worse
Close... on the Alerts page hides an alert with no end, with an optional reason that is also written on its incident. It opens again only if it gets more serious than when it was closed (said once) or the problem has been gone for half an hour; Open again brings it back at once. Built on the snooze table (kind, severity and note columns), so everything that holds back snoozed alerts holds back closed ones. Audit log, change log and /api/v1 alerts carry it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ff0b44943
commit
a94899865e
24 files changed
+7982
-24
No files matched your search
@@ -1914,6 +1914,8 @@ export interface AlertItem {
|
||||
flapping?: boolean;
|
||||
/** Snoozed until then: hidden like one under maintenance, and announced again if it is still there. */
|
||||
snoozed?: { until: string; by: string };
|
||||
/** Closed by somebody: hidden with no end, until it gets worse or has been gone for half an hour. */
|
||||
closed?: { by: string; at: string; note: string | null };
|
||||
}
|
||||
|
||||
export type AlertRuleMetric = "cpu" | "mem" | "disk" | "disk_temp";
|
||||
@@ -3185,6 +3187,8 @@ export const api = {
|
||||
ack: (data: AckInput) => request<{ ack: AlertAck }>("/api/alerts/ack", { method: "PUT", body: JSON.stringify(data) }),
|
||||
unack: (alertId: string) => request<void>(`/api/alerts/ack?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }),
|
||||
snooze: (alertId: string, until: string) => request<{ snooze: { until: string; snoozedBy: string } }>("/api/alerts/snooze", { method: "PUT", body: JSON.stringify({ alertId, until }) }),
|
||||
close: (alertId: string, note: string | null) => request<{ closed: { by: string; at: string; note: string | null } }>("/api/alerts/close", { method: "PUT", body: JSON.stringify({ alertId, note }) }),
|
||||
reopen: (alertId: string) => request<void>(`/api/alerts/close?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }),
|
||||
unsnooze: (alertId: string) => request<void>(`/api/alerts/snooze?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }),
|
||||
noise: (days: number) => request<NoiseReport>(`/api/alerts/noise?days=${days}`),
|
||||
},
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { useState } from "react";
|
||||
import { api, type AlertItem } from "../api/client";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { toast } from "../utils/toast";
|
||||
import DetailDrawer from "./DetailDrawer";
|
||||
import { ErrorNotice } from "./Notice";
|
||||
|
||||
/**
|
||||
* "Close" an alert: it has been dealt with, or it is accepted. It is hidden — held back like one under maintenance, so not counted in the badges, the dashboard or the digest, and its
|
||||
* messages are not sent — with no end. It comes back only if it **gets worse** (a more serious severity than it has now), or if the problem goes away for half an hour and returns
|
||||
* (then it is a new one). The reason is written on its incident, so the history says why. Nothing about the thing itself is promised: that is what maintenance is for.
|
||||
*/
|
||||
export default function CloseDrawer({ alert, onClose, onSaved }: { alert: AlertItem; onClose: () => void; onSaved: () => void }) {
|
||||
const [note, setNote] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
async function close() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
await api.alerts.close(alert.id, note.trim() === "" ? null : note.trim());
|
||||
toast.success("Closed.");
|
||||
onSaved();
|
||||
onClose();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<DetailDrawer title="Close this alert" subtitle={alert.message} onClose={onClose}>
|
||||
<div className="text-secondary mb-3">
|
||||
Hide it, with no end. It comes back only if it <strong>gets worse</strong> than {alert.severity}, or if the problem goes away for half an hour and then returns. Until then it is not counted and nothing is sent about it. The reason you give goes on its
|
||||
incident. Nothing about the thing itself is promised — use <em>Silence</em> for planned work.
|
||||
</div>
|
||||
<ErrorNotice error={error} />
|
||||
<label className="form-label" htmlFor="close-note">
|
||||
Why? (optional)
|
||||
</label>
|
||||
<textarea id="close-note" className="form-control mb-3" rows={3} maxLength={500} value={note} onChange={(e) => setNote(e.target.value)} placeholder="Fixed outside the app · accepted · the disk is being replaced on Friday…" autoFocus />
|
||||
<div className="d-flex gap-2">
|
||||
<button type="button" className="btn btn-primary" disabled={busy} onClick={() => void close()}>
|
||||
{busy ? "Closing…" : "Close the alert"}
|
||||
</button>
|
||||
<button type="button" className="btn" disabled={busy} onClick={onClose}>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</DetailDrawer>
|
||||
);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import SilenceButton from "../components/SilenceButton";
|
||||
import RunPlaybookButton from "../components/RunPlaybookButton";
|
||||
import RunbookEntry from "../components/RunbookEntry";
|
||||
import AckDrawer, { ackWords } from "../components/AckDrawer";
|
||||
import CloseDrawer from "../components/CloseDrawer";
|
||||
import SnoozeDrawer, { SnoozeBulkDrawer, snoozeWords } from "../components/SnoozeDrawer";
|
||||
import { useAlertsReport } from "../hooks/useAlertsReport";
|
||||
import { summariseAlerts } from "../utils/alertSummary";
|
||||
@@ -97,6 +98,7 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
const [attention, setAttention] = useState<"all" | "unacknowledged" | "acknowledged" | "mine">("all");
|
||||
const [acking, setAcking] = useState<AlertItem | null>(null);
|
||||
const [snoozing, setSnoozing] = useState<AlertItem | null>(null);
|
||||
const [closing, setClosing] = useState<AlertItem | null>(null);
|
||||
// Alerts ticked for a bulk action, and which bulk form is open.
|
||||
const [picked, setPicked] = useState<Set<string>>(new Set());
|
||||
const [bulkForm, setBulkForm] = useState<"ack" | "silence" | "snooze" | null>(null);
|
||||
@@ -198,6 +200,16 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
void load(true);
|
||||
reloadBadge();
|
||||
}
|
||||
async function reopen(a: AlertItem) {
|
||||
try {
|
||||
await api.alerts.reopen(a.id);
|
||||
toast.success("Opened again.");
|
||||
await load(true);
|
||||
reloadBadge();
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
}
|
||||
}
|
||||
async function wake(a: AlertItem) {
|
||||
try {
|
||||
await api.alerts.unsnooze(a.id);
|
||||
@@ -466,6 +478,10 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
<span className="badge bg-secondary-lt text-secondary ms-2" title={`${a.causedBy.name} is down too, which explains this — notifications for this are held back. If ${a.causedBy.name} comes back and this stays down, it alerts then.`}>
|
||||
caused by {a.causedBy.name}
|
||||
</span>
|
||||
) : a.closed ? (
|
||||
<span className="badge bg-secondary-lt text-secondary ms-2" title={`Closed by ${a.closed.by}${a.closed.note ? `: ${a.closed.note}` : ""} — hidden until it gets worse, or the problem has gone for half an hour and returns`}>
|
||||
closed by {a.closed.by}
|
||||
</span>
|
||||
) : a.snoozed ? (
|
||||
<span className="badge bg-azure-lt text-azure ms-2" title={`Snoozed by ${a.snoozed.by} — hidden until then, and announced again if it is still there`}>
|
||||
{snoozeWords(a.snoozed)}
|
||||
@@ -548,12 +564,22 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
Snooze…
|
||||
</button>
|
||||
)}
|
||||
{!a.silenced && (
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => setClosing(a)} title="Dealt with, or accepted: hide it until it gets worse">
|
||||
Close…
|
||||
</button>
|
||||
)}
|
||||
{a.closed && (
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => void reopen(a)}>
|
||||
Open again
|
||||
</button>
|
||||
)}
|
||||
{a.snoozed && (
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => void wake(a)}>
|
||||
Wake now
|
||||
</button>
|
||||
)}
|
||||
{!a.snoozed && <SilenceButton alert={a} onDone={() => void load(true)} />}
|
||||
{!a.snoozed && !a.closed && <SilenceButton alert={a} onDone={() => void load(true)} />}
|
||||
{a.target?.type === "server" && !a.silenced && <RunPlaybookButton serverName={a.target.name} />}
|
||||
</div>
|
||||
</td>
|
||||
@@ -613,6 +639,7 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
{bulkForm === "snooze" && <SnoozeBulkDrawer count={pickedIds.length} onSubmit={bulkSnooze} onClose={() => setBulkForm(null)} />}
|
||||
{bulkForm === "silence" && <SilenceBulkDrawer noun={pickedIds.length === 1 ? "alert" : "alerts"} count={pickedIds.length} canSilenceDependents={false} onSubmit={bulkSilence} onClose={() => setBulkForm(null)} />}
|
||||
|
||||
{closing && <CloseDrawer alert={closing} onClose={() => setClosing(null)} onSaved={() => { void load(true); reloadBadge(); }} />}
|
||||
{snoozing && <SnoozeDrawer alert={snoozing} onClose={() => setSnoozing(null)} onSaved={() => { void load(true); reloadBadge(); }} />}
|
||||
{acking && <AckDrawer alert={acking} me={user} onClose={() => setAcking(null)} onSaved={() => {
|
||||
void load(true);
|
||||
|
||||
Reference in new issue
Block a user