The pieces / weirdnet-alerts

weirdnet-alerts

Host alerts for nodes: weirdnet-rules over observations, a default rule pack, probes, and SMTP, webhook and push-wake sinks.

v0.2.2 GitHub crates.io docs.rs weirdnet-alerts = "0.2.2"

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; the backends feature maps supervisor events and runs a monitor loop 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) and event (a one-off). Titles are templates over the fields. A failing key repeats at most every repeat_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_product sets the product.
  • Secrets: SMTP passwords and webhook tokens are env:NAME or file:/path references; 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_rules and Thresholds: 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, and PushSink (feature push).
  • config: AlertsConfig builds the alerter and its sinks; secrets are env: or file: references only.
  • engine (feature backends): observation, probes and monitor for 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::probes and engine::monitor for 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 as engine.added and engine.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

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.