Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 180Observability · Uptime

How to monitor a website from outside

Monitoring that runs on the same server cannot tell you the server is down — it is down too. An outside check calls your site like a visitor does, from another network, every minute: is the status 200, does the page contain the right text, is the TLS certificate still valid for more than 14 days? This how-to does it with Uptime Kuma (simple, with a status page) and with the Prometheus blackbox exporter (if you already run Prometheus).

  • 5 Lessen
  • 3 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

180.1

The quick answer

curl -o /dev/null -s -w '%{http_code} %{time_total}s\n' https://www.example.com/
docker run -d --name uptime-kuma --restart unless-stopped -p 127.0.0.1:3001:3001 -v uptime-kuma:/app/data louislam/uptime-kuma:2

Then open the UI (through a reverse proxy with TLS), add a monitor HTTP(s) – Keyword, interval 60 s, and a notification.

180.2

Step by step

  1. Run the checker somewhere else — another cloud, another provider, or a small VPS. Never on the server you watch.
  2. Start Uptime Kuma (quick answer) — listen on localhost only and put Nginx with TLS in front; create the admin account at the first visit.
  3. Add good monitors:
    • HTTP(s) – Keyword: URL https://www.example.com/, keyword that only a working page has (for example the footer text). A 200 error page then still counts as down.
    • Certificate expiry notification: on, 14 days.
    • TCP port for non-web services (SMTP 587, SSH 22 from the allowed IP).
    • DNS monitor for the domain's A record.
  4. Avoid false alarms — interval 60 s, retries 2 before "down", timeout 10–20 s.
  5. Send alerts where people act — Slack, Teams, Telegram or mail; one test notification per channel.
  6. Status page — a public page with the monitors you choose, so users see "we know" during an outage.
  7. With Prometheus: blackbox exporter — a module and a scrape job:
blackbox.yml
modules:
  http_2xx:
    prober: http
    timeout: 10s
    http:
      fail_if_not_ssl: true
      fail_if_body_not_matches_regexp: ["Example Ltd"]
prometheus.yml (part)
  - job_name: blackbox
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets: ["https://www.example.com/"]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115

Alert on probe_success == 0 for 2 minutes, and on probe_ssl_earliest_cert_expiry - time() < 14 * 86400.

180.3

Check that it worked

Test the blackbox module by hand: curl -s 'http://127.0.0.1:9115/probe?target=https://www.example.com/&module=http_2xx' | grep probe_success shows probe_success 1. In Uptime Kuma the monitor is green; change the keyword to a wrong word and an alert arrives after the retries.

Commando's in deze les

180.4

Common problems

ProblemCauseFix
Alerts at night that nobody can confirmOne failed check counts as down.Retries 2–3; check from two places.
Site down but monitor greenOnly the status code is checked; an error page returns 200.Keyword check / fail_if_body_not_matches_regexp.
Monitor down, site fineWAF or rate limit blocks the checker.Allow the checker's IP; slower interval.
No alert when the checker itself diesNobody watches the watcher.A push/heartbeat monitor from a second system, or a paid outside check.
Certificate expired without warningExpiry not monitored.Certificate expiry alert at 14 days.
Uptime Kuma UI open to the internetPort 3001 published on all addresses.Bind to 127.0.0.1; reverse proxy with TLS and a strong admin password.

180.5

Go further

1Why must an uptime check run outside the server it watches?

If the server or its network is down, a check on the same server is down too and cannot send an alert.

2Why check for a keyword and not only the status code?

Many broken sites still return 200 with an error page; a keyword proves the real page loaded.

Alle commando's in dit hoofdstuk