AlertMonitor class

Watches the fleet against a set of AlertRules, and says so when one is breached — and, just as importantly, when it stops being.

It evaluates on the heartbeats and connection events the Hub already produces, so it costs nothing extra and cannot be more stale than the fleet view itself.

The whole design rests on one distinction: a condition is not an alert. A node at 95% CPU for one heartbeat is a build running; at 95% for five minutes it is a problem. So a breach is observed immediately and raised only once it has held for the rule's duration. Without that, every alert is noise — and an operator who has learned to ignore alerts has no alerting.

Raising and resolving are published on the Hub's event bus, so an alert reaches the dashboard, events --follow and anything else watching by the paths that already exist, rather than needing a delivery mechanism of its own.

Constructors

AlertMonitor({required List<AlertRule> rules, required EventBus eventBus, Clock clock = const SystemClock()})
Creates a monitor.

Properties

active List<Alert>
Every alert currently raised.
no setter
clock Clock
Time source.
final
eventBus EventBus
Where raised and resolved alerts are announced.
final
hashCode int
The hash code for this object.
no setterinherited
rules List<AlertRule>
The rules to watch. Empty means alerting is off, which is the default: a tool that invents its own thresholds is a tool that pages you at 3am about a disk it decided was too full.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

forget(String nodeId) → void
Forgets a node entirely (it was removed from the fleet).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onConnected(String nodeId) → void
A node came back. Everything it was alerting about is over — including its thresholds, which cannot be judged on a node that is reporting nothing.
onDisconnected(String nodeId) → void
A node went away. The clock on any offline rule starts now.
onStatus(String nodeId, MetricPoint point) → void
Judges point — a node's latest reading — against every threshold rule.
tick() → void
Re-checks pending offline breaches. An absence produces no events, so nothing else would ever notice that a node has now been gone long enough.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited