Skip to content

The Webalert server agent

webalert-agent reports a Linux server’s health to Webalert every 15 seconds: CPU, memory, disks, network, the services you choose and, if you turn them on, error logs, Docker containers, checks and custom metrics. A second, optional service on the same binary runs the fixes you allow.

It is one small static binary, run by systemd as an unprivileged webalert-agent user. It only makes outbound HTTPS requests to the Webalert API and listens on no port. What it does is described here; Servers and AI SRE explain what Webalert does with it. The full reference is the README on GitHub.

Supported systems

Linux on x86_64 or arm64 with systemd and cgroup v2: Ubuntu 22.04 and later, Debian 11 and later, RHEL, Alma and Rocky 9, and Amazon Linux 2023. The installer also needs curl or wget and OpenSSL 1.1.1 or later. It checks all of this and stops with a clear message otherwise.

Install

In Webalert, open Servers, then Add server, and copy the command. It holds a one-time token (valid 24 hours) and installs, enrolls and starts the agent in one step:

curl -fsSL https://web-alert.io/agent/releases/latest/download/install.sh | sudo sh -s -- --token wae_…

Before it installs anything, the script checks the Ed25519 signature on the release’s checksums and the package’s checksum, and stops if a check fails. The last line says what happened, for example webalert-agent 0.7.0: enrolled as web-1 (id 2), agent running. Within 30 seconds the server shows as Online.

To keep the token out of the process list, pass it as WEBALERT_TOKEN=wae_… or with --token-file FILE. Running the command again upgrades the agent and keeps the enrollment.

By hand

To read the script first, or to choose the services before the first report:

# 1. install (starts nothing)
curl -fsSLO https://web-alert.io/agent/releases/latest/download/install.sh
less install.sh
sudo sh install.sh

# 2. choose services (see agent.yaml below), then check what would be sent
sudoedit /etc/webalert/agent.yaml
webalert-agent preview

# 3. enroll with the token from Servers, Add server (read from stdin)
echo wae_… | sudo webalert-agent enroll --endpoint https://api.web-alert.io

# 4. start and check
sudo systemctl enable --now webalert-agent
sudo webalert-agent status

Releases and their signatures are public at github.com/web-alert/webalert-agent.

Server groups (autoscaling)

An AWS Auto Scaling group, a Google Cloud managed instance group, an Azure scale set or any other pool of identical instances joins Webalert as one server group. Create it under Servers, Add server, A group that scales and copy its key (wag_…, shown once). Then put one line in the launch template’s user-data, which runs as root at boot:

#!/bin/sh
curl -fsSL https://web-alert.io/agent/releases/latest/download/install.sh \
  | WEBALERT_GROUP_KEY=wag_… sh -s -- --with-actions --with-config
  • Each instance joins as <group>-<last 6 of its instance id>, reading its id, region, zone and type from the cloud’s metadata service.
  • Instances leave quietly. On a clean shutdown (a scale-in) the agent tells Webalert, and the instance is retired without an alert. After a crash or a spot interruption it is retired after the group’s timeout (default 10 minutes).
  • One incident per group, such as “nginx.service is failed on 3 of 4 instances in web-asg”, not one page per instance. Set a minimum number of instances to be alerted when too few are reporting.
  • --with-actions writes the group’s fixes to actions.yaml, and --with-config adds the group’s log watches, checks and collectors to agent.yaml. Without them nothing is written. Running instances pick up later changes with actions apply --group and config apply --group.
  • --with-remote-config (agent 0.7.0) lets Webalert manage monitoring on new instances as on the group’s running ones: at boot it writes the scope those instances allow (see Monitoring from Webalert). After that, what you add on the group reaches every instance without a command.
  • A group is billed on the average number of instances running over the last 30 days, rounded up.

The key only lets machines join this group; revoke it in the group’s Settings if it leaks. To keep it out of user-data, read it from AWS Systems Manager Parameter Store or Secrets Manager at boot. On AWS, turn on instance metadata tags so the agent can read the Auto Scaling group’s name.

What it sends, and what never leaves the server

Every 15 seconds, one sample of about 1 KB, gzipped:

  • CPU, load, processes, memory and swap, out-of-memory kills, network in and out;
  • for every disk: size, use, inodes, read-only state, reads and writes per second and how busy it is;
  • for each service you list: its state, restarts and memory;
  • only if you turn them on: per log source, how many lines matched an error pattern (and, with send_log_lines: true, those lines, redacted); Docker container state; check results; custom metric values;
  • with the first report and when they change: hostname, OS, kernel, architecture, CPU count, memory size, boot time, clock sync and IPv4 addresses. Enrollment sends a SHA-256 hash of /etc/machine-id, never the id itself.

Never sent

  • Log lines that don’t match your pattern, and any log line unless you set send_log_lines: true. Before a line leaves, passwords, tokens, secrets, API keys, cookies, bearer tokens, credentials in URLs, email and IP addresses are removed, plus anything matching your own redact: patterns.
  • Database passwords from collector credential files, and the agent’s own credential.
  • File contents, environment variables, container contents and the bodies of local health checks.

Redaction works on patterns, so a secret in a form it doesn’t recognise is sent as is: add a redact: pattern for it, or leave send_log_lines off. Run webalert-agent preview to see exactly what would be sent, without sending it. When AI SRE is on, what the AI reads goes to a model provider; see the privacy page.

agent.yaml

/etc/webalert/agent.yaml is owned by root and decides what the agent may read. Webalert can add to it only within the remote_config scope root allows, and never beyond it. Apply changes with sudo systemctl restart webalert-agent. An invalid value stops the agent with a message saying what is wrong.

# interval: 15s                        # 15s to 300s; unset: Webalert's (15s)
services: [nginx, postgresql, docker]  # systemd units to watch
mounts: auto                           # or a list: [/, /var/lib/docker]
docker: false                          # true: container state (needs the docker group)

Disks are found on their own. A listed service that isn’t installed is skipped and logged, never reported as down; preview suggests the right name for a typo. Reading the Docker socket needs the docker group, which is equivalent to root on that server.

Logs

logs:
  - journald: nginx                 # a systemd unit
  - file: /var/log/myapp/app.log    # follows rotation
    pattern: "ERROR|Traceback"
send_log_lines: true                # also send matching lines, redacted
redact: ["(?i)x-api-key: \\S+"]     # extra redactions

The agent counts the new lines that match the pattern (a sensible error pattern is the default). With send_log_lines: true it also sends those lines with their stack traces, which the log explorer needs. Reading the journal or /var/log needs a group such as systemd-journal or adm; the agent never adds itself to one, and status prints the command that grants the access.

Checks

Read-only checks of things on this server, each with a chart and an alert in Webalert:

checks:
  - {id: health, type: http, url: "http://127.0.0.1:8080/health"}
  - {id: postgres, type: tcp, host: localhost, port: 5432}
  - {id: backups, type: file_age, dir: /var/backups/db, glob: "*.sql.gz", max_age_s: 93600}
  - {id: workers, type: process, name: "^celery$", min: 1}
  - {id: app-cert, type: cert_file, path: /etc/ssl/certs/app.pem, warn_days: 14}

http and tcp only reach localhost, 127.0.0.1 or [::1] (or a unix socket), and a response body is read up to 64 KB and dropped, never sent. A check that can’t run, for example for lack of permission, reports why and never alerts.

Custom metrics: collectors

Any number your software already exposes, as charts and alerts: requests a second, error rate and p95 response time from an access log, MySQL and MariaDB, Postgres, Redis, a Prometheus endpoint or a JSON status page.

collectors:
  - id: nginx
    type: log_metrics
    source: {file: /var/log/nginx/access.log}
    regex: '" (?P<status>\d{3}) \d+ .* (?P<request_time>[\d.]+)$'
    metrics:
      - {name: nginx.requests, kind: rate}
      - {name: nginx.errors_5xx, kind: rate, filter: {status: "^5"}}
      - {name: nginx.response_time, kind: percentiles, field: request_time, scale: 1000, unit: ms}
  - id: mysql
    type: mysql                     # reads /etc/webalert/mysql.cnf
    include: [mysql.questions, mysql.slow_queries, "mysql.threads_*", mysql.max_connections]
  - id: redis
    type: redis
  - id: app
    type: prometheus
    url: "http://127.0.0.1:9100/metrics"
  • Types: log_metrics, prometheus, json, mysql, postgres and redis. Counters become per-second rates and histograms become p50, p95 and p99 on the server.
  • Collectors are read-only and local: URLs must be on the server itself, and the database collectors run only fixed read-only statements (for MySQL, SHOW GLOBAL STATUS, SHOW GLOBAL VARIABLES and replica status).
  • Database passwords live in a file in /etc/webalert, readable by the agent and no other user (chown root:webalert-agent, chmod 640). A file others can read is refused. Passwords are never logged or sent.
  • For MySQL or MariaDB, a read-only login is enough: CREATE USER 'webalert'@'localhost' IDENTIFIED BY '…'; GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'webalert'@'localhost'; When you add a database collector in Webalert, it gives you the exact command: the server makes the password itself and writes the file, so nobody types it and Webalert never sees it.
  • Up to 200 series per server are included in the server price.

Monitoring from Webalert

From agent 0.7.0 you can add, change and remove collectors, checks and log watches in Webalert, on the server’s Monitoring card, with no command each time. Webalert tests each one on the server before you save it, and every change can be undone. Root allows it once, with a scope: which kinds Webalert may change and which folders it may read. The card gives you the command:

sudo webalert-agent config allow ABCD-2345

It shows the exact change to agent.yaml and what Webalert can never do, and asks first. It writes this block, which you can also write yourself:

remote_config:
  enabled: true
  allow: [collectors, checks, logs]   # what Webalert may add, change and remove
  read_paths: [/var/log]              # the only folders it may read

Whatever Webalert sends, the agent itself holds it to these limits:

  • It never runs commands, changes actions.yaml or adds fixes: it only changes what the agent reads.
  • Files only inside read_paths, checked after following symlinks and again each time a file is opened. Never /etc/shadow, sudoers, private keys or anything under .ssh; read_paths may not be, hold or be under /etc, /home, /root, /proc, /sys or /dev.
  • Checks and collectors reach only this server (localhost, 127.0.0.1, [::1] or a unix socket) and never follow redirects. Database credentials only from files in /etc/webalert, which root puts there.
  • Entries in agent.yaml always win: Webalert can’t change or remove them. Log lines are sent only if send_log_lines is on, redacted as usual.
  • Webalert’s config is signed for this one machine and applied all or nothing; an older version never replaces a newer one. The agent keeps it in /var/lib/webalert-agent and picks up changes without a restart.

Turn it off at any time with sudo webalert-agent config allow --off: Webalert’s entries stop at once. webalert-agent config show lists the scope and what Webalert added, and status says which version runs. Webalert AI’s recommendations for collectors, checks and log watches then apply with one click too.

config apply

On a server that doesn’t allow monitoring from Webalert, accepted log watches, checks or collectors come with one command instead:

sudo webalert-agent config apply ABCD-2345

It fetches the changes with this server’s credential (the code works once, for an hour), merges them into agent.yaml, validates the result, and shows a diff with every new file, journal, socket, URL and credentials file the agent will read. Nothing is written until you answer yes. Other keys and comments in the file stay as they are.

Fixes: actions.yaml

The agent can also fix a few things itself. That is done by a separate root service, webalert-actions, and it is off until /etc/webalert/actions.yaml exists: the only list of what may ever run on the server. The easiest way to write it is the server’s Automation tab in Webalert, which suggests fixes for what runs there and gives you one command:

sudo webalert-agent actions apply ABCD-2345

It validates the file exactly as the runner will, shows a diff and a plain summary (marking every AI switch), and asks before writing. Nothing changes on the server unless root runs it. Or start from the commented example:

webalert-agent actions example | sudo tee /etc/webalert/actions.yaml
sudo webalert-agent actions check             # what each action would do
sudo systemctl enable --now webalert-actions
sudo webalert-agent actions list              # tier, state, last run
sudo webalert-agent actions test free-disk-tmp  # dry run, runs nothing
version: 1
max_actions_per_hour: 6
actions:
  - id: free-disk-journal
    template: vacuum-journal
    size: 500M
    when: { disk_used_pct_above: 90, mount: / }
  - id: renew-certs
    template: renew-cert
    when: { cert_expires_within_days: 14 }
  - id: restart-nginx
    template: restart-unit
    unit: nginx
    when: { unit_down_for_minutes: 2 }
Action templates
TemplateDoesRuns
vacuum-journalShrinks the systemd journalOn its own
clean-old-filesDeletes old files in one directory you nameOn its own
docker-pruneRemoves dangling images and old build cacheOn its own
force-logrotateRotates logs nowOn its own
renew-certRuns certbot renewOn its own
restart-unitRestarts a systemd serviceAfter approval
restart-containerRestarts a Docker containerAfter approval

Commands are fixed, run without a shell from root-owned binaries, with a timeout. Every action has a cooldown and a daily cap, and two failed runs in a row turn it off until you fix the file or run actions enable. A restart runs only with an order signed by Webalert, for this machine, used once, after the runner checks the service is still down. Every run and refusal goes to /var/log/webalert-actions/audit.log and to Webalert.

Levels and the practice run

In Webalert each server (or group) has one level. It can only lower what the file allows, never raise it:

  • Tell me: nothing runs on its own; every fix waits for approval.
  • Fix the safe stuff (default): cleanups, log rotation and certificate renewal run on their own; restarts wait for approval.
  • Autopilot: during an open incident, restarts and AI-written scripts can run without approval, if the file allows it (below).

For the first 7 days after install the runner is in a practice run: it records what it would have done and runs nothing. End it early with sudo webalert-agent actions start. A server group practices once for the whole group, so new instances start for real.

AI and Autopilot switches

With AI SRE, three more opt-ins in actions.yaml, all off by default. Only this file turns them on; Webalert never can.

allow_probes: true             # read-only diagnostics for the AI
allow_ai_commands: true        # AI-written scripts, each approved by a person
ai_autopilot: true             # Autopilot may act during an incident
ai_autopilot_max_risk: medium  # low | medium | high
probe_paths: [/etc/nginx]      # config folders the AI may read (default none)
  • Probes are read-only commands from a fixed list (top processes, disk usage, a service’s status and journal, Docker logs, listening ports, nginx -t, recent package changes, certificates and a few more). Parameters are validated, output is redacted and capped at 16 KB, and at most 60 run an hour. Try one: sudo webalert-agent actions probe disk_usage path=/var depth=2.
  • AI-written scripts run only after a person approves the exact script in Webalert. The runner checks its hash, refuses anything on the denylist (wiping disks, deleting system folders, piping a download into a shell, users and SSH keys, firewall flushes, stopping SSH, reboots and more), and runs it with a timeout. The full script goes in the audit log.
  • Autopilot also needs the account owner to choose Autopilot for the server in Webalert. Its risk is capped at the lower of the two settings, it runs at most 3 times an hour and 10 a day, and after 3 failures in a row it pauses for 24 hours (actions enable autopilot resumes it).

Commands

webalert-agent commands
CommandWhat it does
webalert-agent statusWhether it runs, the last accepted report, the last error, and what it can and can’t read (with the command that fixes it).
webalert-agent previewTakes two samples and prints exactly what they contain. Sends nothing.
sudo webalert-agent enrollConnects the server with a token on stdin, or joins a group with --group-key-file.
sudo webalert-agent config allow CODELets Webalert add, change and remove monitoring within a scope, after showing the change. --off turns it off again.
webalert-agent config showThe remote_config scope and what Webalert added.
sudo webalert-agent config apply CODEAdds accepted log watches, checks and collectors to agent.yaml, after showing the diff. --group on a group member.
sudo webalert-agent actions listThe fixes, their tier, state, last run and level.
sudo webalert-agent actions checkValidates actions.yaml and says what each action would do.
sudo webalert-agent actions test IDA dry run: the precondition, the command, the caps. Never runs it.
sudo webalert-agent actions historyThe audit log.
sudo webalert-agent actions startEnds the 7-day practice run now.
sudo webalert-agent actions apply CODEApplies the setup from the Automation tab, after showing the diff. --group on a group member.
sudo webalert-agent actions enable IDTurns an action back on after two failures; autopilot resumes a paused Autopilot.
sudo webalert-agent deregisterTells Webalert the server is going away, without paging anyone.

Upgrade and uninstall

To upgrade, run the install command again. It keeps agent.yaml and the enrollment and restarts the agent if it was running.

curl -fsSL https://web-alert.io/agent/releases/latest/download/install.sh | sudo sh

To remove it, run sudo webalert-agent-uninstall. It first tells Webalert the server is going away, so nobody is alerted, then removes the services, the binary, the configuration and the user. actions.yaml and the actions audit log stay unless you add --purge.

Stuck? sudo webalert-agent status and journalctl -u webalert-agent -n 50 usually say why. The README has a troubleshooting list, or email support@web-alert.io.