Skip to content

Deploying Gatus uptime monitoring on Ubuntu 22.04 with multi-region probes and alert routing

Install Gatus on Ubuntu 22.04 as a self-hosted uptime + SLA monitor — HTTP/DNS/TCP/ICMP/TLS probes, multi-region worker nodes via remote endpoints, PostgreSQL storage, and alert routing to Slack/PagerDuty.

You run synthetic checks from a single VM in the same region as the application. The application’s region has a routing glitch, your checks all turn red, the on-call wakes up, and ten minutes in someone finally points out that real users were unaffected — the problem was the path from your checker to your app, not the app itself. Single-region uptime monitoring is monitoring the path, not the service. Gatus solves this in a way that doesn’t require a managed SaaS or an agent on every customer endpoint — you run a central Gatus instance for the dashboard and storage, and you run thin Gatus “worker” instances in two or three other regions whose probe results are aggregated. Below is the Ubuntu 22.04 installer for the central node, with the worker pattern and alert routing wired in.

What’s happening

Gatus is a single Go binary that loads a YAML config, runs HTTP/DNS/TCP/ICMP/TLS/SSH probes against endpoints on a schedule, evaluates declarative conditions ([STATUS] == 200, [RESPONSE_TIME] < 300, [BODY].id != null, [CERTIFICATE_EXPIRATION] > 240h), records the result in storage (memory, SQLite, or PostgreSQL), and fires configurable alerts when conditions transition. It ships its own HTTP UI and a public/private status page rendered from the same data. The multi-region pattern: a central Gatus instance owns config + storage + UI + alerts. Worker instances in other regions are configured with the same endpoints, but write results to a remote /api/v1/endpoints/{key}/external on the central node using a shared token. From the central UI you see per-region probe results and can build conditions like “alert only if at least 2 of 3 regions fail” by setting the endpoint’s alerts.failure-threshold high and running 3 redundant probes. PostgreSQL backs storage because SQLite doesn’t survive the central node being restarted under load.

How to verify

After the central node is up and at least one worker is reporting in:

# 1. Service status
systemctl status gatus --no-pager
journalctl -u gatus -n 50 --no-pager

# 2. Health endpoint
curl -s http://127.0.0.1:8080/health | jq

# 3. Endpoint results via API
curl -s http://127.0.0.1:8080/api/v1/endpoints/statuses | jq '.[] | {key,group,name,results: (.results | length)}'

# 4. Database has the expected row growth
sudo -u postgres psql gatus -c "SELECT endpoint_key, COUNT(*) FROM endpoint_results GROUP BY endpoint_key ORDER BY 2 DESC LIMIT 10;"

If endpoints/statuses returns endpoints but results: 0, the probes are configured but haven’t run yet — wait one interval. If one worker region is missing results for an endpoint that the central probe is happily checking, the worker has bad credentials or a bad endpoint key; tail the worker’s log first, then the central node.

The fix

Save the script as /root/setup-gatus.sh, edit the host vars at the top (FQDN, Postgres password, alert webhooks, regions), and run as root on the Ubuntu 22.04 central node. The installer pins the latest stable Gatus 5.x release tarball, lays out /opt/gatus/ with a dedicated system user, deploys a PostgreSQL 16 instance for storage (skip if you already have one — set PG_EXTERNAL=yes), writes a config covering HTTP/DNS/TLS endpoints with conditions and SLA-friendly intervals, declares per-endpoint failure thresholds and per-alert webhook routing (Slack for warning, PagerDuty for critical, email for digest), enables the public status page on /status, and fronts the dashboard with Caddy for automatic TLS. The script ends by emitting a sample worker config so you can scp it to the other regions.

#!/usr/bin/env bash
set -euo pipefail

### Ubuntu 22.04 Gatus deployment — central node + worker template
### Probes: HTTP / DNS / TLS, multi-region aggregation, PostgreSQL storage.

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT ME ===
GATUS_FQDN="status.example.com"
GATUS_VERSION="5.13.1"
PG_PASSWORD="CHANGE_ME_PG"
PG_EXTERNAL="no"              # "yes" if you already have a Postgres host
PG_HOST="127.0.0.1"
PG_PORT="5432"
PG_DB="gatus"
PG_USER="gatus"
SLACK_WEBHOOK="https://hooks.slack.com/services/CHANGE/ME"
PAGERDUTY_KEY="CHANGE_ME_PD_INTEGRATION_KEY"
ALERT_EMAIL_FROM="alerts@example.com"
ALERT_EMAIL_TO="ops@example.com"
SMTP_HOST="smtp.example.com"
SMTP_PORT="587"
SMTP_USER="alerts@example.com"
SMTP_PASS="CHANGE_ME_SMTP"
WORKER_TOKEN="CHANGE_ME_WORKER_TOKEN"
REGIONS=("ca-central" "eu-west" "us-east")
# ===============

echo
echo "========================================"
echo "Gatus central node on ${GATUS_FQDN}"
echo "========================================"
echo

echo "==> Base packages"
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
apt-get install -y curl wget jq ufw fail2ban ca-certificates gnupg \
  postgresql-client tar gzip iproute2

echo "==> Firewall"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable

echo "==> Dedicated user + layout"
id -u gatus >/dev/null 2>&1 || useradd -r -s /usr/sbin/nologin -d /opt/gatus gatus
mkdir -p /opt/gatus/bin /etc/gatus /var/lib/gatus /var/log/gatus
chown -R gatus:gatus /opt/gatus /etc/gatus /var/lib/gatus /var/log/gatus

echo "==> Fetching Gatus ${GATUS_VERSION}"
cd /tmp
wget -q "https://github.com/TwiN/gatus/releases/download/v${GATUS_VERSION}/gatus-linux-amd64" -O gatus
sha_remote=$(wget -qO- "https://github.com/TwiN/gatus/releases/download/v${GATUS_VERSION}/gatus-linux-amd64.sha256" | awk '{print $1}')
[ -n "${sha_remote}" ] && echo "${sha_remote}  gatus" | sha256sum -c -
install -m 0755 -o gatus -g gatus gatus /opt/gatus/bin/gatus

if [[ "${PG_EXTERNAL}" == "no" ]]; then
  echo "==> Installing local PostgreSQL 16"
  install -d /usr/share/keyrings
  curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/pgdg.gpg
  echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] https://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main" \
    > /etc/apt/sources.list.d/pgdg.list
  apt-get update -y
  apt-get install -y postgresql-16
  systemctl enable --now postgresql

  sudo -u postgres psql -tc "SELECT 1 FROM pg_roles WHERE rolname='${PG_USER}'" | grep -q 1 || \
    sudo -u postgres psql -c "CREATE ROLE ${PG_USER} LOGIN PASSWORD '${PG_PASSWORD}'"
  sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname='${PG_DB}'" | grep -q 1 || \
    sudo -u postgres psql -c "CREATE DATABASE ${PG_DB} OWNER ${PG_USER}"
fi

echo "==> Writing /etc/gatus/config.yaml"
cat > /etc/gatus/config.yaml <<EOF
metrics: true
debug: false

storage:
  type: postgres
  path: "postgres://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}/${PG_DB}?sslmode=disable"
  caching: true

web:
  address: "127.0.0.1"
  port: 8080

ui:
  title: "Acme — Service status"
  description: "Live availability and SLA over the past 90 days."
  header: "Service availability"
  logo: ""
  dark-mode: true
  buttons:
    - name: "Status page"
      link: "https://${GATUS_FQDN}/status"

connectivity:
  checker:
    target: "1.1.1.1:53"
    interval: 60s

# ---------- ALERT TARGETS ----------

alerting:
  slack:
    webhook-url: "${SLACK_WEBHOOK}"
    default-alert:
      description: "Endpoint down"
      send-on-resolved: true
      failure-threshold: 3
      success-threshold: 2

  pagerduty:
    integration-key: "${PAGERDUTY_KEY}"
    default-alert:
      send-on-resolved: true
      failure-threshold: 5
      success-threshold: 3

  email:
    from: "${ALERT_EMAIL_FROM}"
    username: "${SMTP_USER}"
    password: "${SMTP_PASS}"
    host: "${SMTP_HOST}"
    port: ${SMTP_PORT}
    to: "${ALERT_EMAIL_TO}"
    default-alert:
      send-on-resolved: true
      failure-threshold: 10
      success-threshold: 1

# ---------- ENDPOINTS ----------

endpoints:

  # Marketing site — warning on Slack, critical on PagerDuty.
  - name: "Marketing site"
    group: "public"
    url: "https://www.example.com/"
    interval: 60s
    conditions:
      - "[STATUS] == 200"
      - "[RESPONSE_TIME] < 800"
      - "[CERTIFICATE_EXPIRATION] > 240h"
      - "[BODY] == pat(*Acme*)"
    client:
      timeout: 10s
    alerts:
      - type: slack
        failure-threshold: 3
        success-threshold: 2
        description: "Marketing site failing — Slack"
      - type: pagerduty
        failure-threshold: 5
        success-threshold: 3
        description: "Marketing site sustained outage"

  # API health — tight thresholds, page fast.
  - name: "API /healthz"
    group: "api"
    url: "https://api.example.com/healthz"
    interval: 30s
    conditions:
      - "[STATUS] == 200"
      - "[RESPONSE_TIME] < 300"
      - "[BODY].status == ok"
    client:
      timeout: 5s
    alerts:
      - type: pagerduty
        failure-threshold: 3
        success-threshold: 2

  # Checkout flow — POST with body, slower threshold.
  - name: "Checkout submit (synthetic)"
    group: "api"
    url: "https://api.example.com/v1/checkout/preview"
    method: POST
    headers:
      Content-Type: application/json
      X-Synthetic: "gatus"
    body: |
      {"cart":[{"sku":"SKU-1","qty":1}],"region":"CA"}
    interval: 120s
    conditions:
      - "[STATUS] == 200"
      - "[RESPONSE_TIME] < 1500"
      - "[BODY].total > 0"
    alerts:
      - type: slack
        failure-threshold: 2
      - type: pagerduty
        failure-threshold: 4

  # DNS — answer must contain known A record.
  - name: "DNS A record for www"
    group: "dns"
    url: "1.1.1.1"
    dns:
      query-name: "www.example.com"
      query-type: "A"
    interval: 300s
    conditions:
      - "[DNS_RCODE] == NOERROR"
      - "[BODY] == pat(*203.0.113.*)"
    alerts:
      - type: slack
        failure-threshold: 3

  # TLS certificate near-expiry guard
  - name: "TLS — api.example.com"
    group: "tls"
    url: "tcp://api.example.com:443"
    interval: 600s
    conditions:
      - "[CONNECTED] == true"
      - "[CERTIFICATE_EXPIRATION] > 336h"
    alerts:
      - type: email
        failure-threshold: 2

# ---------- EXTERNAL ENDPOINTS (multi-region workers push here) ----------

external-endpoints:
  - name: "Marketing site"
    group: "public"
    token: "${WORKER_TOKEN}"
    alerts:
      - type: slack
        failure-threshold: 3
        success-threshold: 2
  - name: "API /healthz"
    group: "api"
    token: "${WORKER_TOKEN}"
    alerts:
      - type: pagerduty
        failure-threshold: 3
        success-threshold: 2

# ---------- MAINTENANCE WINDOWS ----------

maintenance:
  enabled: true
  start: "06:00"
  duration: 30m
  every:
    - sunday
EOF

chown gatus:gatus /etc/gatus/config.yaml
chmod 640 /etc/gatus/config.yaml

echo "==> systemd unit"
cat > /etc/systemd/system/gatus.service <<'UNIT'
[Unit]
Description=Gatus — automated developer-oriented status page
After=network.target postgresql.service
Wants=postgresql.service

[Service]
Type=simple
User=gatus
Group=gatus
WorkingDirectory=/opt/gatus
ExecStart=/opt/gatus/bin/gatus
Environment=GATUS_CONFIG_PATH=/etc/gatus/config.yaml
Environment=GATUS_LOG_LEVEL=INFO
Restart=on-failure
RestartSec=5s
LimitNOFILE=65535
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/gatus /var/log/gatus
PrivateTmp=true

[Install]
WantedBy=multi-user.target
UNIT

systemctl daemon-reload
systemctl enable --now gatus

echo "==> Caddy front (automatic TLS)"
apt-get install -y debian-keyring debian-archive-keyring apt-transport-https
curl -fsSL "https://dl.cloudsmith.io/public/caddy/stable/gpg.key" \
  | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -fsSL "https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt" \
  | tee /etc/apt/sources.list.d/caddy-stable.list > /dev/null
apt-get update -y
apt-get install -y caddy

cat > /etc/caddy/Caddyfile <<EOF
${GATUS_FQDN} {
  encode zstd gzip
  reverse_proxy 127.0.0.1:8080
  log {
    output file /var/log/caddy/gatus.log
  }
}
EOF
systemctl restart caddy

echo "==> Worker config templates"
mkdir -p /opt/gatus/worker-templates
for REGION in "${REGIONS[@]}"; do
cat > "/opt/gatus/worker-templates/gatus-worker-${REGION}.yaml" <<EOF
# Worker for ${REGION}. Deploy on an Ubuntu 22.04 host in that region.
# Same /etc/gatus/config.yaml binary; this is the worker variant.
metrics: false
debug: false
storage:
  type: memory
web:
  address: "127.0.0.1"
  port: 8080
endpoints:
  - name: "Marketing site"
    group: "public-${REGION}"
    url: "https://www.example.com/"
    interval: 60s
    conditions:
      - "[STATUS] == 200"
      - "[RESPONSE_TIME] < 1500"
    external-endpoint:
      url: "https://${GATUS_FQDN}/api/v1/endpoints/public_marketing-site/external?token=${WORKER_TOKEN}"
  - name: "API /healthz"
    group: "api-${REGION}"
    url: "https://api.example.com/healthz"
    interval: 30s
    conditions:
      - "[STATUS] == 200"
      - "[RESPONSE_TIME] < 600"
    external-endpoint:
      url: "https://${GATUS_FQDN}/api/v1/endpoints/api_apihealthz/external?token=${WORKER_TOKEN}"
EOF
done

sleep 4

echo
echo "========================================"
echo "DONE"
echo "========================================"
echo

echo "Service:"
systemctl is-active gatus || true
echo

echo "Recent journal:"
journalctl -u gatus -n 15 --no-pager || true
echo

echo "Health endpoint:"
curl -s http://127.0.0.1:8080/health | jq || true
echo

echo "Endpoints loaded:"
curl -s http://127.0.0.1:8080/api/v1/endpoints/statuses | jq '.[] | {key,group,name}' || true
echo

echo "Worker configs ready under /opt/gatus/worker-templates/ — scp them to ${REGIONS[*]} hosts."
echo "Web UI: https://${GATUS_FQDN}/  Status page: https://${GATUS_FQDN}/status"

Make it executable and run on the central node:

chmod 700 /root/setup-gatus.sh
/root/setup-gatus.sh

For each remote region, copy the matching gatus-worker-<region>.yaml to a fresh Ubuntu 22.04 host, install the Gatus binary the same way (or use the official Docker image — for workers it’s lighter), and point GATUS_CONFIG_PATH at the worker yaml. After fifteen minutes you’ll have probe results from all regions converging into the central dashboard; build a per-endpoint condition that escalates only when at least 2 of N regions fail, and you’ve eliminated the single-region false positive class.

For uptime monitoring you don’t want to maintain, our monitoring + on-call team runs Gatus (or equivalents) inside a customer’s environment management contract with on-call escalation in place. Scope it with us.