Administration

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 understood

Any 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:

CheckHowBad meansFix
reachableTCP connect, login and ping, each within timeout_msDown, hung or out of connections: criticalrestart
loginThe watcher's own account is acceptedWrong user, password or token: criticalnone (a person must fix the configuration)
latencyThe ping round tripSlower than slow_ms: warningnone
write_probeWrites, reads back and deletes one canary row (__rdb_watch_canary__)The server answers but cannot store data (log failure, disk full, read-only): criticalrestart
serverGET /v1/server: role, uptime, replication, degraded commitsStatus silent, a replicated table not connected to its primary, replication error, commits acknowledged without every replica: warningnone
diskFree space where disk_path livesBelow disk_min_free_percent: warning; below half of it: criticalcleanup command
replica:<addr>Other nodes in replicas answer pingwarningnone

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#

  1. A bad round is not an incident. A check must be bad fail_after rounds in a row (default 3) before anything happens.
  2. The incident opens and a report goes out (opened).
  3. A fix is tried if one applies and its command is configured: reachable and write_probe run restart_command; disk runs cleanup_command. Each step is reported (fix_started, then fix_succeeded or fix_failed). After a restart the watcher waits up to restart_timeout_seconds for the server to answer a login and a ping.
  4. Limits on fixing. At most max_restarts per restart_window_minutes (default 3 in 30). When the budget is used up, the watcher stops restarting, reports gave_up ("a person is needed") and keeps reminding. A server that crashes in a loop is never restarted in a loop.
  5. Reminders every reminder_minutes while the incident lasts; a worse incident is escalated.
  6. After two good rounds in a row a resolved report 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)#

KeyMeaningDefault
nameNode name in reports.raftdb
addresshost:port of the server (binary protocol and HTTP share the port).127.0.0.1:7480
user, password, password_fileThe watcher's account. It needs readwrite for the canary (a read-only account works if probe_write = false).none
tokenA token instead of user and password.none
interval_secondsSeconds between rounds.10
timeout_msHow long one connection or request may take (at least 100).3000
fail_afterBad rounds before an incident opens (1 to 1000).3
slow_msA ping slower than this is "slow".500
probe_writeRun the canary write check.true
disk_pathDirectory whose disk is checked; empty means no disk check.empty
disk_min_free_percentWarn below this free percentage.10
restart_commandCommand that restarts the server; empty means report only.empty
restart_timeout_secondsWait for the server to come back.60
max_restarts, restart_window_minutesRestart budget.3, 30
cleanup_commandCommand run when the disk is low.empty
notify_fileAppend one JSON line per event.empty
notify_commandRun with the event as JSON on standard input and in RAFTDB_WATCH_NODE, _EVENT, _CHECK, _SEVERITY, _DETAIL, _HEADLINE; 30 s limit.empty
notify_webhookPOST the message to an http:// or https:// URL (HTTPS is verified against tls_ca_file; see the notifications page).empty
reminder_minutesRepeat the report while an incident stays open.30
replicasOther nodes (host:port, comma separated) pinged every round.empty
status_portServe GET /status on 127.0.0.1 at this port; 0 is off.0

Reports#

Event JSON:

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.

KeyMeaningDefault
update_modeoff: no request at all, no folder created. stage: download, check and stage. apply: also switch (needs the next three keys).off
update_windowWhen a switch may start: any or HH:MM-HH:MM (UTC).none
update_stop_command, update_start_commandHow the server is stopped and started (systemctl stop raftdb-server, the Windows service).none
update_feedThe release feed.https://www.raftdb.com/api/release
update_rootThe program folder holding versions/ and current (needed for stage).none
update_interval_secondsTime between checks (60 s to 30 days).21600
update_os, update_archWhich archive to take: linux or windows, x64 or arm64.this machine
update_max_mbLargest archive accepted.1024
update_timeout_secondsLimit of every network wait.60
update_check_config, update_check_dataThe live settings file and data folder that the new server checks, read-only, before the release is staged.none
update_ca_filePEM roots for an https:// feed; the certificate and host name are always verified.tls_ca_file
update_public_key_fileA 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_authenticodeWindows 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_publisherThe 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_secondsTime the new version has to answer, report its version and (on a primary) take a test write.120 (Windows 300)
update_settle_secondsHow long it must keep passing.10
update_drain_secondsLongest wait for a running backup to end; still busy: the switch is skipped this round.300
update_command_timeout_secondsLimit of the stop and start commands.300
update_pre_commandRun before the stop (a backup); a failure stops the switch.none
update_data_hashHash the data folder at the stop and compare it at a rollback.false
update_keep_previous_daysDays the previous version is kept after a verified switch.7
update_state_dirWhere the run state, the lock and the list of refused versions are kept.control_dir
update_peers, update_peer_listenFetch 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#

  1. 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 with password_file.
  2. Install raftdb-watch, examples/watch.conf (edit it) and examples/raftdb-watch.service.
  3. Allow the watcher's user the one privileged command, in sudoers: raftdbwatch ALL=(root) NOPASSWD: /bin/systemctl restart raftdb.
  4. raftdb-watch --config /etc/raftdb/watch.conf --check-config, then --test-notify (you should receive the report), then --once.
  5. 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's status_port if 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-config prints the settings including passwords it loaded.

See also#