What it brings
Tell an operator when a node needs attention: an engine that keeps crashing, a default route that fell back to Wi-Fi, a filesystem running out of space, a GPU running hot. Rules are data, so an application ships defaults and users add their own.
What it is
An application feeds the alerter observations (an engine crashed, the default route moved to Wi-Fi, a disk is nearly full, a GPU is hot); weirdnet-rules specs turn them into failing, recovered and one-off alerts, deduped per key, and sinks deliver them.
How it works
- Observations: a kind (
engine.crash_loop,net.route,disk,gpu, or anything the application emits) and JSON fields. Probes produce the built-in ones; thebackendsfeature maps supervisor events and runs amonitorloop until told to stop. - Rules: weirdnet-rules specs whose actions are
fail(raise an alert under a key),ok(clear it, sending a recovery notice) andevent(a one-off). Titles are templates over the fields. A failing key repeats at most everyrepeat_secs(an hour by default). - Sinks: SMTP (lettre over rustls), JSON webhooks, the log, memory for tests, and push wakes through
weirdnet-push, which carry only a reason code. Every sink has a dry run that builds the message and
sends nothing. Subjects read
[product host] title;with_productsets the product. - Secrets: SMTP passwords and webhook tokens are
env:NAMEorfile:/pathreferences; inline values are refused.
Key types and modules
Alerter,Observation,Action(fail,ok,event),Alert,AlertStatus: evaluation, per-key dedupe with a repeat interval, and recovery notices.rules:default_rulesandThresholds: engine crash loops, failed loads and crashes; the default route; free disk; GPU temperature with hysteresis.probe:route,disk,gpus(Linux and Unix).sinks:Sink,SmtpSink,WebhookSink,LogSink,MemorySink, andPushSink(featurepush).config:AlertsConfigbuilds the alerter and its sinks; secrets areenv:orfile:references only.engine(featurebackends):observation,probesandmonitorfor weirdnet-backends supervisor events (0.2 to 0.4 since 0.2.2, 0.2 or 0.3 in 0.2.0 and 0.2.1; a model or adapter removed at run time clears its engine alert).
Feature flags
push:PushSink, wakes through weirdnet-push 0.1 (pulls in aws-lc through reqwest).backends:engine::observation,engine::probesandengine::monitorfor weirdnet-backends 0.2 to 0.4 (since 0.2.2; 0.2 or 0.3 in 0.2.0 and 0.2.1, 0.1 before). Adapters added or removed at run time arrive asengine.addedandengine.removed, like models.
Usage
[dependencies]
weirdnet-alerts = "0.2.2"# Cargo.toml
weirdnet-alerts = "0.2"
// main.rs
use weirdnet_alerts::{AlertsConfig, Observation};
let cfg: AlertsConfig = toml::from_str(&std::fs::read_to_string("alerts.toml")?)?;
let alerter = cfg.alerter("gpu-01")?.with_product("my-node");
alerter.observe(&Observation::new("disk", serde_json::json!({"path": "/", "free_pct": 4.0}))).await;Where it fits
- Builds on weirdnet-rules, weirdnet-push, weirdnet-backends.
- Extracted from Ymir.
- License: BSD-3-Clause.
Version 0.2.2 is on crates.io (docs.rs). 0.2.2 lets the
backends feature take weirdnet-backends 0.4 (LoRA adapters) as well as 0.2 and 0.3, with no API changes; adapters added or removed at run time are engine.added and engine.removed observations like models. 0.2.1 changes only package metadata and docs. 0.2.0 is breaking for backends users: the feature takes weirdnet-backends 0.2 or 0.3 (on weirdnet-agent 0.5) instead of 0.1, so apps on agent 0.5 get one copy of each. The default rules clear an engine’s alert when its model is removed at run time (engine.removed). Nothing changes without the backends feature. Extracted from Ymir’s ymir-alerts. Push alerts are wake-ups only: the alert text stays on the node. The push feature pulls in aws-lc through reqwest.