Bỏ qua để đến nội dung
Monitoring Real metric charts, threshold alert rules, a live snapshot and a log tail for a server.

Monitoring

Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.

The Monitoring section of a server (/servers/:id/monitoring) is the box’s observability surface: historical CPU / RAM / disk / network charts, a live snapshot, the top processes, threshold-based alert rules, and a live Logs tail — all from real agent data. It’s available on all plans. Two tabs live here: Metrics (the default) and Logs.

  1. Scroll to Alert rules and click New rule to open the rule drawer.
  2. Give it a Title (e.g. “CPU above 90%”).
  3. Pick the Metric — CPU %, RAM %, Disk %, Swap %, Load (1m), Network KB/s, a container-health metric (unhealthy / stopped containers), or one of the pressure metrics (agent 0.2.143 or newer; on older agents these rules never fire):
    • Memory pressure % (mem_pressure) — share of time tasks stalled waiting for memory (Linux PSI “some”, 60 s average). Above ~10% the box is short of RAM.
    • Swap-in pages/s (swap_in) — pages read back from swap per second. A busy swap-in rate is what makes a box slow; a full but quiet swap is harmless. Pages are 4 KB and idle sites waking up cause tens to hundreds per second, so start a rule around 500 (about 2 MB/s) rather than a small number.
    • Top client IP share % (top_ip_share) — the share of the last minute’s requests that came from a single IP, counted only when that minute had at least 100 requests. The alert names the IP, the site it hit and its request count, so you can ban it in Security → Fail2ban or the firewall.
  4. Set the Operator (>, <, ==) and a Threshold.
  5. Set the Duration — how long the condition must hold before it fires (e.g. 5m; immediate fires on the first breach). This is the anti-flap window.
  6. Choose a Severity (warning or critical) and tick the Channels to notify. Channels come from your account-wide Chat & Alerts connections. A rule with no channel still notifies you: its alerts and recoveries land in the in-app Notifications inbox.
  7. Leave Active on and Create rule. The rule persists on the control plane and the alert worker starts evaluating it against every heartbeat.
  • Read the charts — four cards (CPU, RAM, Disk, Network rx/tx) plot real history bucketed from agent heartbeats. Hover for a crosshair chip naming the exact time and value; a gap reads “no data” rather than a carried value.
  • Traffic cards — below the charts: Requests (req/s, with peak), Success (2xx/3xx share, with 4xx/5xx errors), Cache hits (page-cache hit ratio), Connections (open connections, including on :443) and Bandwidth. They are fed by the agent’s traffic frame about every 60 seconds — no nginx change is needed — and read GET /v1/servers/:id/traffic/history. On an older agent the cards show “Traffic stats collecting…”.
  • Sites using the most resources — ranks this server’s sites by CPU (average share of one core), Memory (peak), DB time (what MariaDB/MySQL spent on the site’s queries, agent 0.2.161+ — that load is not limited by the site’s CPU cap) or Limit hits (OOM kills, memory-ceiling and process-limit hits) over the selected range. It reads the control plane’s per-site history, so it works while the agent is offline. Only sites that run in their own resource slice (a resource plan, or isolated PHP) are sampled, every 15 minutes.
  • Change the time range — the 1h / 6h / 24h / 7d / 30d / 90d / 1y segmented control re-buckets the history. Longer ranges fill in as history accumulates.
  • Go Live — the Live toggle flips the shared poll cadence to ~3s (vs ~15s) so the headline numbers update in near real time. It drives the right-sidebar gauges in lock-step, so the two can never disagree.
  • Live snapshot — uptime, 1-minute load, memory, swap, process count, top CPU process, kernel and hostname from the current mz metrics reading.
  • Top processes — the live “what’s eating the box” table; toggle By CPU / By RAM to find a runaway process.
  • Manage rules — pause/resume, edit, or delete any rule; a firing rule shows a pulsing Firing pill.
  • Channels — the connected notification destinations are listed with a Send test; add or edit them in Chat & Alerts (one place, reused by rules here and by Uptime).
  • Logs tab — a live-feeling tail of the box’s system and service logs (nginx access/error, php-fpm, mariadb, syslog, auth). Pick a source and Refresh to re-run the tail.

Monitoring stitches together three real data paths:

  • Charts read GET /v1/servers/:id/metrics/history?range=…. The agent appends one metric sample per heartbeat into the server_metrics table; the API buckets and averages that series per range (CPU, RAM, disk, swap, load, net rx/tx). This works even while the box is briefly offline, since it reads stored history. Every 10-second sample is kept for 48 hours; after that the history is kept as 5-minute averages for 31 days, hourly for 90 days and 6-hourly for a year, so the 1h–24h charts show full detail and 7d–1y charts stay fast.
  • Live snapshot, headline numbers and top processes come from the metrics.get job — the agent runs mz metrics --json natively. The same snapshot feeds the right-sidebar gauges and the Servers list cards, so every surface shows one number.
  • Alert rules are persisted per-server on the control plane. A server-side alert worker loads active rules each tick, reads each server’s latest heartbeat metrics, evaluates the threshold against the duration window, and — on transition to firing — delivers to the rule’s channels over real HTTPS (webhook / Slack / Telegram). Email delivery needs SMTP configured on the control plane. Container-health metrics are computed from the agent-pushed Docker inventory cache, not the heartbeat.
  • Logs dispatch a logs.tail job — the agent runs mz logs <target> --json and returns a one-shot snapshot of that log file.

The metric and log reads are plain box-level mz commands — the same engine the dashboard drives:

Terminal window
mz metrics --json # the live snapshot (CPU, RAM, load, top procs)
mz logs sources --json # which log targets the box exposes
mz logs nginx-error --lines 200 --json
mz logs syslog --lines 200 --json

Alert rules are managed on the control plane (dashboard or the API), not through mz. See The mz CLI and the command catalog.

GoalMCP toolREST
Live snapshotmetrics_getjob metrics.get
CPU/RAM/disk historyservers_metrics_historyGET /v1/servers/{id}/metrics/history?range=1h|6h|24h|7d|30d|90d|1y
Request / traffic historyservers_traffic_historyGET /v1/servers/{id}/traffic/history
Container metricscontainers_metrics_history
Sites using the most resourcessites_usage_rankingGET /v1/servers/{id}/site-usage/ranking?range=24h&sort=cpu|mem|faults|db&limit=20
Smart Advice count for the serverservers_advice_summaryGET /v1/servers/{id}/advice/summary
One site’s cap hits over timesites_faultsGET /v1/servers/{id}/sites/{domain}/faults
Tail a loglogs_tailjob logs.tail
Alert rulesserver_alert_rules_list, server_alert_rules_create, server_alert_rules_update
Alert channelsserver_alert_channels_list, server_alert_channels_test
Swap guard state / reclaim nowjobs_createjob system.swap-status (read), system.swap-reclaim {force?} (operate)

Alert rule metric values: cpu, ram, disk, swap, load, net, containers_unhealthy, containers_down, containers_update_available, mem_pressure, swap_in, top_ip_share. All reads need only a read-level token. For “is it reachable” checks use the uptime tools (uptime_monitors_*) — see Uptime.

  • Swap at 100% is not always a problem. After a memory spike the kernel parks idle database/cache memory in swap and does not move it back, so swap can sit at 100% while RAM is free. The agent’s swap guard (releases after 0.2.141) moves it back to RAM automatically once it has been high for 30 minutes and RAM can hold it. Run mz system swap-status --json in the terminal (or the system.swap-status job) to see its decision. Swap filling while available RAM is low is a real shortage.

  • What the Swap colour means. On agent 0.2.143 or newer the Swap gauge in the server sidebar and the Swap tile in the live snapshot are coloured by pressure, not by how full swap is: red when pages are swapped in at 2,500/s (about 10 MB/s) or more or memory pressure is at 10% or more, amber from 500 pages/s or 2%, otherwise green — even at 100%, where it adds “idle · no pressure”. Older agents don’t report pressure, so the colour still follows the percentage.

  • Per-process CPU is an average. The CPU % next to a process in a ps-style list is averaged over the process lifetime; use the live CPU chart for current load.

  • History accumulates from when monitoring began. The charts render only the samples already stored, so a fresh server shows “Collecting metric history…” and the longer ranges (7d / 30d / 90d / 1y) fill in over time — they are not back-filled.

  • A rule only fires while the box is heartbeating. The alert worker evaluates the last heartbeat metrics; if the agent is fully offline there are no new samples to breach a threshold. Use Uptime monitoring for “is the box/site reachable at all” — it probes from the outside and is the right tool for hard-down detection.

  • Email channels can be saved but inert. Webhook / Slack / Telegram deliver with no extra infrastructure; email is only sent if the control plane has SMTP configured, otherwise the channel is skipped with a logged warning.

  • Offline shows last-known data, not examples. When the agent is offline the section shows the last-known cached values (or an “Agent offline” state) instead of live reads. Live reads, the snapshot, and log tails resume when mzagent reconnects.

  • ?tab=logs deep-links the Logs tab. The old /servers/:id/logs route now redirects here, so bookmarks keep working.