Skip to content

Thresholds

pghf.clear_threshold(p_check_id text, p_check_run_id uuid DEFAULT NULL)

Removes a check-level default threshold, or a specific suite override.

Parameter Type Mandatory Default Description
p_check_id text Yes Check to clear a threshold for. Must exist.
p_check_run_id uuid No empty = clear the default Non-empty = clear that specific suite's override instead.

Returns: nothing. Raises an error if the check doesn't exist, or its namespace/category is inactive; simply does nothing (not an error) if there's no matching threshold to clear. Only a role explicitly granted permission can call this.

pghf.get_threshold(p_check_id text, p_check_run_id uuid DEFAULT NULL)

Returns one threshold record for a check — the check-level default, or a specific suite override.

Parameter Type Mandatory Default Description
p_check_id text Yes Check to look up a threshold for. Must exist.
p_check_run_id uuid No empty = the default Non-empty = a specific suite's override.

Returns: the threshold record. Raises an error if the check doesn't exist, or if it exists but has no matching threshold record.

pghf.list_thresholds(p_check_id text DEFAULT NULL)

Lists threshold records.

Parameter Type Mandatory Default Description
p_check_id text No empty = every threshold in the catalog Scope to one check's default plus any suite overrides.

Returns: zero or more threshold records, ordered so a check's default appears before its overrides. Raises an error only if a given check ID doesn't exist — no thresholds configured at all is a legitimate empty result.

pghf.set_threshold(p_check_id text, p_check_run_id uuid DEFAULT NULL, p_info_value jsonb DEFAULT NULL, p_warn_value jsonb DEFAULT NULL, p_crit_value jsonb DEFAULT NULL, p_bool_breach_severity text DEFAULT NULL, p_evaluator_routine regprocedure DEFAULT NULL, p_min_consecutive_breaches integer DEFAULT 1)

The only way to add, override, or update a threshold — one function for every case: seeding a built-in check's default, registering one for a custom check, a per-suite override, or later updating any of the above. It's an upsert: calling it again for the same check and suite combination replaces that record's values in place. Seeded and user-added thresholds are updated identically — there's no protected or built-in state — and this works directly against built-in checks too, since thresholds are explicitly excluded from the update lock described in Catalog: Checks.

Parameter Type Mandatory Default Description
p_check_id text Yes Check this threshold applies to. Must exist and be under an active namespace/category.
p_check_run_id uuid No empty = check-level default Non-empty = a per-suite override.
p_info_value jsonb No empty Softest numeric tier (only for integer/numeric checks).
p_warn_value jsonb No empty Middle numeric tier.
p_crit_value jsonb No empty Hardest numeric tier.
p_bool_breach_severity text No empty Only for boolean checks: 'info', 'warning', or 'critical'.
p_evaluator_routine regprocedure No empty A custom evaluator function, overriding the default comparator entirely.
p_min_consecutive_breaches integer No 1 Debounce: consecutive at-or-above-tier runs required before the breach is confirmed. See How Threshold Evaluation Works.

Returns: bigint — the threshold's internal identifier. Only a role explicitly granted permission — whichever should be trusted to author thresholds in your deployment — can call this.

Continue to Events.