Skip to content

feat: live monitoring, minute averages and peaks, editable alert rules with email, log search - #24

Merged
AmrMsCLL merged 1 commit into
mainfrom
feat/live-monitoring-on-main
Nov 5, 2026
Merged

AmrMsCLL merged 1 commit into
mainfrom
feat/live-monitoring-on-main

Conversation

@AmrMsCLL

@AmrMsCLL AmrMsCLL commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Real-time monitoring, alerts and log search inside the console, instead of a Grafana, Prometheus and Loki stack: no new services, one sign-in behind Cloudflare Access, a few tens of MB.

This is #21's change on current main. #21 was merged into fix/redeploy-images-accuracy (its base) instead of main, and #23 conflicts because that branch holds #20's original commit while main holds its squash. This branch is main plus #21's one commit; its tree is identical to what #21 merged.

Live data

  • Containers: one Docker stats stream per running container (opened and closed as containers come and go) gives CPU, memory and the container's limits, and network and disk byte rates every second. This replaces the separate stats?stream=false call per container every 5 seconds.
  • Host: every second from /proc: CPU, memory, swap, load, and network (physical interfaces of the host's namespace, /proc/1/net/dev) and disk (/proc/diskstats, whole disks) rates. Disk space every 30 seconds.
  • Stream: GET /api/live is Server-Sent Events: the last three minutes on connect, then a frame each second. It re-checks the viewer's membership every minute and closes when it is gone. One EventSource per tab, shared by every component.
  • Pages: the Overview's host cards, a traffic line and each project's CPU and memory tick live; every usage chart gains a live range (three minutes at one second), network and disk charts, and an average / peak switch for the history ranges.

History

Each minute is now the average and peak of its seconds, with average network and disk rates, written to the existing samples table through added columns (cpu_peak, memory_peak, net, io). The 30 days already stored stay readable; their average stands in for the missing peak. Before, each minute stored one instantaneous 5-second sample.

Alerts

  • Checked every 10 seconds. A fixed set of rules, each with a threshold, a duration and a switch that owners edit on the Alerts page and that are kept in alerts.db: host CPU, memory, swap and disk; a container's CPU and memory against its own limits (new); stopped, unhealthy and restarting containers; a project without a backup.
  • An alert opens once its condition has held for the rule's duration (its start time is when it began) and resolves after a clear minute, instead of two checks a minute apart.
  • Email: each alert and its recovery go to ALERTS_EMAIL through SMTP_URL (from ALERTS_FROM, or ALERTS_EMAIL), with a Send a test email button for owners. GitHub issues continue when ALERTS_TOKEN is set; one channel failing does not stop the other.
  • The two alert lifecycle tests are rewritten for the new rule (held for the rule's duration, cleared for a minute); the host and container rule tests keep their expectations under the default rules. A test fixture whose container used 100 % of its memory limit now uses 1 %, since the new memory rule would rightly flag it.

Logs

A Logs page searches every container's logs, or one project's, over the last 15 minutes to 7 days, case-insensitively, newest first, up to 500 lines.

Dependency

nodemailer 10.3.1 (approved), server only; @types/nodemailer 8.0.2 for development.

Settings

SMTP_URL (for example smtps://user:password@smtp.example.com:465), ALERTS_EMAIL, ALERTS_FROM, all optional, in the console's env file; platform passes them through (Project-Graphite/platform#45).

Checks

tsc (server and web), oxlint, npm run build, and test/alerts.spec.ts, test/live.spec.ts, test/host.spec.ts, test/history.spec.ts, test/backups.spec.ts, test/inventory.spec.ts, test/docker.spec.ts, test/secrets.spec.ts, test/access.spec.ts, test/terminal.spec.ts. Not run: the stats streams and /proc readers against a real Docker host, the live stream through Cloudflare, an email send, and the pages in a browser.

…le alert rules with email, and log search (#21)

A stats stream per running container and /proc on the host feed a 1 second
frame: CPU, memory, network and disk rates. GET /api/live streams it to every
tab over Server-Sent Events with the last three minutes, and closes when the
viewer stops being a member. History keeps each minute's average and peak, with
network and disk, in the existing table. Charts gain a live range, network and
disk, and a peak view. Alerts are checked every 10 seconds against rules owners
edit (threshold, duration, on or off), open once a condition holds for its
duration, resolve after a clear minute, and are emailed through SMTP_URL to
ALERTS_EMAIL with a test button. Logs adds a search across containers.
@github-actions github-actions Bot added the size/xl Over 600 changed lines, excluding lockfiles label Nov 5, 2026
@AmrMsCLL
AmrMsCLL merged commit 9154716 into main Nov 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl Over 600 changed lines, excluding lockfiles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant