Monitoring with the watcher
What raftdb-watch checks, how it opens incidents, fixes basic problems and reports, every single-node setting with its default, the status page and how to set it up under systemd.
raftdb-watch is a small separate program (no dependency beyond the standard library and raftdb-client) that looks after a raftdb-server: it checks the server every few seconds, fixes basic problems by itself (restarts the server, runs your cleanup command) and tells people about everything it sees and does. It is separate so that a bug in the server cannot take it down. Decision D41.
In a cluster the same program also runs the control plane (failover quorum, resource control); those settings are in the replication chapter.
Syntax#
raftdb-watch --config watch.conf run until stopped
raftdb-watch --config watch.conf --once one round; exit 0 healthy, 1 warning, 2 critical
raftdb-watch --config watch.conf --test-notify send a test report through every channel
raftdb-watch --config watch.conf --check-config print the settings it understoodAny key can be given as --key=value (a dash is read as an underscore) and overrides the file. An unknown key is an error.
What it checks#
Every interval_seconds:
| Check | How | Bad means | Fix |
|---|---|---|---|
reachable | TCP connect, login and ping, each within timeout_ms | Down, hung or out of connections: critical | restart |
login | The watcher's own account is accepted | Wrong user, password or token: critical | none (a person must fix the configuration) |
latency | The ping round trip | Slower than slow_ms: warning | none |
write_probe | Writes, reads back and deletes one canary row (__rdb_watch_canary__) | The server answers but cannot store data (log failure, disk full, read-only): critical | restart |
server | GET /v1/server: role, uptime, replication, degraded commits | Status silent, a replicated table not connected to its primary, replication error, commits acknowledged without every replica: warning | none |
disk | Free space where disk_path lives | Below disk_min_free_percent: warning; below half of it: critical | cleanup command |
replica:<addr> | Other nodes in replicas answer ping | warning | none |
The canary is skipped on a replica. When the server cannot be reached, the checks that need it are skipped, so one outage is one incident. A restart the watcher did not cause (the server's uptime goes down between two rounds) is reported as information.
Incidents and fixes#
- A bad round is not an incident. A check must be bad
fail_afterrounds in a row (default 3) before anything happens. - The incident opens and a report goes out (
opened). - A fix is tried if one applies and its command is configured:
reachableandwrite_proberunrestart_command;diskrunscleanup_command. Each step is reported (fix_started, thenfix_succeededorfix_failed). After a restart the watcher waits up torestart_timeout_secondsfor the server to answer a login and a ping. - Limits on fixing. At most
max_restartsperrestart_window_minutes(default 3 in 30). When the budget is used up, the watcher stops restarting, reportsgave_up("a person is needed") and keeps reminding. A server that crashes in a loop is never restarted in a loop. - Reminders every
reminder_minuteswhile the incident lasts; a worse incident isescalated. - After two good rounds in a row a
resolvedreport says how long it lasted.
What it will never do#
It runs only the commands in its configuration. It never deletes or edits data, never changes the server's configuration, never restarts for a warning or for a rejected login, never restarts more than the budget allows, and kills a command that runs too long. Your cleanup_command must free space (rotate logs, remove temporary files) and never touch the data directory.
The optional assistant (assist_mode, off by default) is held to the same rule: it identifies known issues by built-in rules (no language model is shipped) and can only run these two commands, within the same budget. See Notifications, log shipping and the watcher assistant.
Options (single node)#
| Key | Meaning | Default |
|---|---|---|
name | Node name in reports. | raftdb |
address | host:port of the server (binary protocol and HTTP share the port). | 127.0.0.1:7480 |
user, password, password_file | The watcher's account. It needs readwrite for the canary (a read-only account works if probe_write = false). | none |
token | A token instead of user and password. | none |
interval_seconds | Seconds between rounds. | 10 |
timeout_ms | How long one connection or request may take (at least 100). | 3000 |
fail_after | Bad rounds before an incident opens (1 to 1000). | 3 |
slow_ms | A ping slower than this is "slow". | 500 |
probe_write | Run the canary write check. | true |
disk_path | Directory whose disk is checked; empty means no disk check. | empty |
disk_min_free_percent | Warn below this free percentage. | 10 |
restart_command | Command that restarts the server; empty means report only. | empty |
restart_timeout_seconds | Wait for the server to come back. | 60 |
max_restarts, restart_window_minutes | Restart budget. | 3, 30 |
cleanup_command | Command run when the disk is low. | empty |
notify_file | Append one JSON line per event. | empty |
notify_command | Run with the event as JSON on standard input and in RAFTDB_WATCH_NODE, _EVENT, _CHECK, _SEVERITY, _DETAIL, _HEADLINE; 30 s limit. | empty |
notify_webhook | POST the message to an http:// or https:// URL (HTTPS is verified against tls_ca_file; see the notifications page). | empty |
reminder_minutes | Repeat the report while an incident stays open. | 30 |
replicas | Other nodes (host:port, comma separated) pinged every round. | empty |
status_port | Serve GET /status on 127.0.0.1 at this port; 0 is off. | 0 |
Reports#
Event JSON:
{"time":"2026-11-09T14:03:07Z","unix":1794146587,"node":"prod-db-1","event":"fix_succeeded","check":"reachable","severity":"critical",
"detail":"restarted; the server answers again after 4 s","incidentSince":1794146560}event is one of opened, escalated, reminder, fix_started, fix_succeeded, fix_failed, gave_up, resolved, info.
Status page#
status_port = 7481 serves GET http://127.0.0.1:7481/status (loopback only): node, last round, healthy, open incidents, every check's latest result, restarts in the window and, as assist, the assistant's mode, last issue, pending actions and fixes in the last hour. --once is the form for cron, Nagios and load balancers.
Updates (off by default)#
The watcher can download, check and stage a new release next to the running one, and, only in update_mode = apply, switch to it and put the old one back if anything fails, one node or a whole cluster one node at a time (decision D175; the steps are on Upgrades). In stage it never switches: the running version, the data, the settings and the ports stay as they are.
| Key | Meaning | Default |
|---|---|---|
update_mode | off: no request at all, no folder created. stage: download, check and stage. apply: also switch (needs the next three keys). | off |
update_window | When a switch may start: any or HH:MM-HH:MM (UTC). | none |
update_stop_command, update_start_command | How the server is stopped and started (systemctl stop raftdb-server, the Windows service). | none |
update_feed | The release feed. | https://www.raftdb.com/api/release |
update_root | The program folder holding versions/ and current (needed for stage). | none |
update_interval_seconds | Time between checks (60 s to 30 days). | 21600 |
update_os, update_arch | Which archive to take: linux or windows, x64 or arm64. | this machine |
update_max_mb | Largest archive accepted. | 1024 |
update_timeout_seconds | Limit of every network wait. | 60 |
update_check_config, update_check_data | The live settings file and data folder that the new server checks, read-only, before the release is staged. | none |
update_ca_file | PEM roots for an https:// feed; the certificate and host name are always verified. | tls_ca_file |
update_public_key_file | A file holding the release's Ed25519 public key (one line of 64 hex digits; # comment lines allowed). Empty: no key, and every release is refused. | empty |
update_authenticode | Windows only (no effect on Linux): the Authenticode check of every .exe and .dll of the new version, in addition to the signed manifest. off; check (a signature that does not hold, such as a file changed after signing or a certificate Windows does not trust, refuses the version; an unsigned file is a warning); require (an unsigned file refuses it too). | check |
update_authenticode_publisher | The signer every signed program must have: a name such as Fowlguard, Inc (the certificate's common name), or a whole subject such as CN="Fowlguard, Inc", O=.... Empty: any signer Windows trusts. | empty |
update_verify_seconds | Time the new version has to answer, report its version and (on a primary) take a test write. | 120 (Windows 300) |
update_settle_seconds | How long it must keep passing. | 10 |
update_drain_seconds | Longest wait for a running backup to end; still busy: the switch is skipped this round. | 300 |
update_command_timeout_seconds | Limit of the stop and start commands. | 300 |
update_pre_command | Run before the stop (a backup); a failure stops the switch. | none |
update_data_hash | Hash the data folder at the stop and compare it at a rollback. | false |
update_keep_previous_days | Days the previous version is kept after a verified switch. | 7 |
update_state_dir | Where the run state, the lock and the list of refused versions are kept. | control_dir |
update_peers, update_peer_listen | Fetch from peer watchers when the feed cannot be read; serve the staged files to them (cluster secret required). | none |
In stage mode a release is staged only if it is newer than the running version, the Ed25519 signature of its update manifest is valid, the manifest names the same version as the feed and does not list it as withdrawn, and the download has exactly the manifest's size and SHA-256 (and, for a Windows .zip, every entry its CRC-32). A broken download is resumed at the next check. A redirect is refused, never followed. Anything else is refused, the download is deleted and versions/ and current stay as they were. GET /v1/update/status on the status port shows the last result. No release signing key is built into this version and update_public_key_file is empty by default, so a watcher in stage mode refuses every release and says so at start. A key file that is not exactly one key line is refused when the settings are read; on Linux so is a key file that the group or others may write. Requests send only User-Agent: raftdb-watch/<version> (<os>; <arch>). On Windows the Authenticode check runs after the unpack and before any program of the new version is run; a refusal names each file and the reason, and the new folder is deleted. The release's programs are signed by Fowlguard, Inc and are expected to pass require and that publisher; the check was tested with throw-away test certificates and with the signed programs of release 0.0.4, not with a real release fetched by the watcher.
The watcher's account must be an administrator for the backup check before a switch (GET /v1/backup); with a lesser account a switch is skipped, never forced. By hand, in every mode: raftdb-watch --config watch.conf update status, update apply --to VERSION, update rollback, update cleanup, update recover. In a cluster the plan is given once to the master watcher: PUT /v1/update/plan?expected=N with the cluster secret as bearer token (GET reads it, DELETE cancels it); GET /v1/update/status shows each node's version, staged versions and last result.
Set-up on Linux with systemd#
- Create an account for the watcher on the server (
--user watcher:PASSWORD:readwrite), store its password in a file only the watcher's user can read and name it withpassword_file. - Install
raftdb-watch,examples/watch.conf(edit it) andexamples/raftdb-watch.service. - Allow the watcher's user the one privileged command, in sudoers:
raftdbwatch ALL=(root) NOPASSWD: /bin/systemctl restart raftdb. raftdb-watch --config /etc/raftdb/watch.conf --check-config, then--test-notify(you should receive the report), then--once.systemctl enable --now raftdb-watch. systemd restarts the watcher if it dies (Restart=always). Run a second watcher on another machine pointing at the first one'sstatus_portif you need the watcher watched.
On Windows run it as a scheduled task or a service wrapper (NSSM, sc) with restart_command = powershell -Command "Restart-Service Raft DB". Note that raftdb-server install-service registers a startup task named Raft DB Server, not a service called Raft DB; use schtasks to restart that task (check the name with schtasks /query).
Limits#
- Plain TCP and HTTP only: run the watcher on the same machine or a trusted network.
- Restart fixes a stopped, hung or write-broken server. It cannot fix corrupt data or a full disk no cleanup can free; those escalate with the facts.
- Free disk space is read with
df(Linux and macOS) or PowerShell (Windows). --check-configprints the settings including passwords it loaded.