Skip to content

Alert Status

The truth-layer projection: pghf.alert_status holds one continuously-maintained row per evaluated check — its current confirmed status (the literal truth of the latest applied run, skipped/not_evaluable included) with contiguous-stretch bounds and repeat count, last-run provenance, and a last-achieved watermark per severity level. No open/resolved lifecycle by design — see Alert Status in the User Guide for the narrative and worked consumer queries.

The table is openly SELECT-able (it carries no observed data — only names, severities, counts, and timestamps), which is the entire monitoring-agent integration: SELECT * FROM pghf.alert_status, zero grants. It is maintained exclusively by the evaluation engine (rows created lazily at first evaluation, updated per evaluation, identity refreshed by the check-update functions on rename/renumber/retire) and rows are never deleted — they survive retention purges, so last_run_id deliberately has no foreign key and may reference a purged run. Updates apply only forward in run time: a late evaluation of an older run writes its history row but never rewinds this table.

The two behavioural rules worth knowing when reading it: current_status mirrors confirmed severity, so a hysteresis hold correctly keeps the row at the breached level while current_raw_severity shows the clean observations underneath; and blackouts act by their layer — a 'run'-mode window refreshes only last_run_* and last_skipped_at (it can never erase a real stretch), while an 'alerting'-mode window updates everything normally (a real observation whose reporting was silenced).

pghf.get_alert_status(p_check_id text)

Returns one alert-status record by check ID.

Parameter Type Mandatory Default Description
p_check_id text Yes Must exist.

Returns: the alert-status record. Raises an error if the check doesn't exist, or exists but has never been evaluated (rows are created lazily at first evaluation). Callable by anyone.

pghf.list_alert_status(p_min_status text DEFAULT NULL, p_include_retired boolean DEFAULT true)

Lists alert-status records, worst current status first.

Parameter Type Mandatory Default Description
p_min_status text No empty = all A severity floor, using the same rank comparison as everything else — 'warning' returns warning and above, which per the ladder includes invalid, critical, and error_in_performing_check.
p_include_retired boolean No true false hides retired checks' rows.

Returns: zero or more alert-status records, ordered worst-first then by check ID. Raises on an invalid floor value; an empty result is a legitimate answer, not an error. Callable by anyone.