Events¶
pghf.create_event(p_check_id text, p_event_type text, p_min_severity text, p_channel_name text DEFAULT NULL, p_routine regprocedure DEFAULT NULL, p_function_args jsonb DEFAULT NULL, p_is_active boolean DEFAULT true)¶
The only way to add a new event — a notification fired when a check's confirmed severity newly crosses into, or above, the given floor. There's no restriction to the built-in namespace here: attaching an event doesn't add a new check record, so this works on any existing check, built-in or your own.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_check_id |
text |
Yes | — | Check to attach the event to. Must exist and be under an active namespace/category. |
p_event_type |
text |
Yes | — | 'notify' or 'function'. |
p_min_severity |
text |
Yes | — | Firing floor: 'info', 'warning', or 'critical'. |
p_channel_name |
text |
No | empty | Required when p_event_type is 'notify': the channel name the notification is sent on. |
p_routine |
regprocedure |
No | empty | Required when p_event_type is 'function': a function with the signature described in the Events book. |
p_function_args |
jsonb |
No | empty | Passed through verbatim as the routine's second argument — your own free-form configuration. |
p_is_active |
boolean |
No | true |
false registers the event dormant until you turn it on later. |
Returns: bigint — the new event's identifier. Only a role explicitly granted permission — whichever should be trusted to author events in your deployment — can call this.
pghf.delete_event(p_event_id bigint)¶
Permanently deletes an event record. There's no soft-retire state for events — use pghf.update_event(..., p_is_active => false) instead to inactivate one without losing its configuration.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_event_id |
bigint |
Yes | — | Event to delete. Must exist. |
Returns: nothing. Only a role explicitly granted permission can call this.
pghf.get_event(p_event_id bigint)¶
Returns one event record by identifier.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_event_id |
bigint |
Yes | — | Event to look up. |
Returns: the event record. Raises an error if not found.
pghf.list_events(p_check_id text DEFAULT NULL, p_only_active boolean DEFAULT NULL)¶
Lists event records.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_check_id |
text |
No | empty = every event | Scope to one check's events. |
p_only_active |
boolean |
No | empty = no filter | true = active only, false = inactive only. |
Returns: zero or more event records, ordered by event identifier. Raises an error only if a given check ID doesn't exist.
pghf.update_event(p_event_id bigint, p_event_type text, p_min_severity text, p_is_active boolean, p_channel_name text DEFAULT NULL, p_routine regprocedure DEFAULT NULL, p_function_args jsonb DEFAULT NULL)¶
The only way to modify an existing event. The check it's attached to is immutable — delete and re-create it under the right check if you need to re-point it. This is a full replace of every other field, including whether it's active — this is how you activate or inactivate an event; there's no separate toggle function.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
p_event_id |
bigint |
Yes | — | Event to modify. Must already exist. |
p_event_type |
text |
Yes | — | 'notify' or 'function' (full replace). |
p_min_severity |
text |
Yes | — | Firing floor (full replace). |
p_is_active |
boolean |
Yes | — | Activates or inactivates. |
p_channel_name |
text |
No | empty | Per the event type's shape rule. |
p_routine |
regprocedure |
No | empty | Per the event type's shape rule. |
p_function_args |
jsonb |
No | empty | Passed through verbatim to a 'function' event's routine. |
Returns: bigint — the event's identifier. Only a role explicitly granted permission can call this.
Continue to Evaluation Engine.