morca · API · ui

orca.ui.alerts

Ops › Alerts (/ops/alerts): every alert orca.notify sent or is sending, newest first, from orca.alerts: when, its kind, its title and message as sent, links to what it is about (the run, the pipelines, the watchdog's rules, a worker, Control), whether ntfy took it, and for those that resolve (a watchdog trip, a stalled fill, the disk, memory pressure, an orca notify that was later --resolved) whether it is still open.

?kind= and ?state=open|resolved filter it; ?before=<id> and ?after=<id> page it, 50 to a page (?limit=, at most 500), keyset like the runs list. The newest page refreshes from /ops/alerts/live every 30 s. /api/alerts is the same as JSON.

Structs

AlertsAsk

struct AlertsAsk

What a page of alerts is asked for: its filters and its cursor.

Implements Copyable, Movable

Fields
kind: String
state: String
before: Int
after: Int
size: Int

filters

def filters(self) -> String

The query string of its filters and size, no cursor.

href

def href(self, base: StringSpan[ImmStaticOrigin] = StringSpan("/ops/alerts")) -> String

with_cursor

def with_cursor(self, name: StringSpan[ImmStaticOrigin], id: Int) -> String

first

def first(self) -> Bool

Whether it is the newest page.

AlertRow

struct AlertRow

Implements Copyable, Movable

Fields
id: Int
kind: String
subject: String
event: String
title: String
body: String
priority: String
url: String
pipelines: String
run: Int
created: String
delivery: String
attempts: Int
sent: String
error: String
resolvable: Bool
resolved: String
resolved_by: Int
resolved_by_event: String

state

def state(self) -> String

open, resolved, repeated (raised again before it resolved), or empty for an alert that doesn't resolve and for a 'resolved'.

AlertsPage

struct AlertsPage

Implements Movable

Fields
q: AlertsAsk
rows: List[AlertRow]
total: Int
newer: Int: How many under the filters are newer than the page.
older: Bool
open: Int: Open alerts, whatever the filters.
kinds: List[Tuple[String, Int]]: Each kind's alerts under the state filter.

__init__

def __init__(out self, var q: AlertsAsk)

newer_href

def newer_href(self) -> String

older_href

def older_href(self) -> String

count_of

def count_of(self, kind: String) -> Int

Functions

alerts_ask

def alerts_ask(url: String) -> AlertsAsk

The page url asks for; an unknown state is ignored.

alerts_page

def alerts_page(mut db: State, var q: AlertsAsk) -> AlertsPage

A page of alerts, newest first, with its counts.

kind_label

def kind_label(kind: String, event: String) -> String

A kind as the page names it: run failed, watchdog trip, memory pressure resolved.

alerts_json

def alerts_json(on: Bool, p: AlertsPage) -> String

alerts_table_html

def alerts_table_html(mut h: Html, p: AlertsPage)

The table of a page of alerts and its pager: what /ops/alerts/live answers. An open alert's row is marked (alerts__open).

alerts_html

def alerts_html(mut h: Html, on: Bool, p: AlertsPage)

alerts

def alerts(mut db: State, url: String) -> Page

/ops/alerts: the alerts, a page of them.

alerts_live

def alerts_live(mut db: State, url: String) -> Page

/ops/alerts/live: the newest page's table, as the fragment it refreshes from every IDLE_EVERY seconds; an older page answers 286.

alerts_api

def alerts_api(mut db: State, url: String) -> Page

/api/alerts: the alerts as JSON, whatever is asked for.

Aliases

comptime ALERTS_PAGE = 50
comptime ALERT_KINDS = List(String("run-failed"), String("watchdog"), String("fill-stalled"), String("disk"), String("worker-lost"), String("memory-pressure"), String("backup-failed"), __list_literal__=NoneType(None))

The kinds orca raises (orca.alerts, orca.admission) and the one the Hetzner server's backup sends; the filter adds any others the table has.