basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    Gatus: conditions, ntfy alerts and editing the config without crashing

    Gatus fetches a URL on a schedule and checks the response against your conditions. An alert fires after several consecutive failures and shows which condition failed and with what value. Gatus reloads its config on its own and crashes on a syntax error, so validate edits before moving the file into place.

    A typo in config.yaml crashes Gatus: it reloads the file on its own without a restart and panics on a parse error. The container enters a restart loop, checks stop, and nothing tells you because Gatus is the one sending the alerts. Silent breaks happen too: an endpoint without alerts: or with an empty ntfy topic turns red on the page while your phone stays quiet. Installation is in stage “Gatus: services over HTTPS” of Metrics, uptime checks and alerts; here is how conditions and alerts work, and how to edit the config without knocking out monitoring.

    How Gatus checks an endpoint

    An endpoint has a URL, an interval, and a list of conditions. Every interval, Gatus hits the URL and evaluates each condition against the response. The check passes only when every condition matches.

      - name: memos
        url: https://memos.example.org
        interval: 60s
        conditions:
          - "[STATUS] == 200"
          - "[CERTIFICATE_EXPIRATION] > 336h"

    Each condition is a placeholder in square brackets, an operator, and an expected value. Quotes are mandatory: YAML parses an unquoted value starting with [ as a sequence, and Gatus refuses to start.

    Placeholder Meaning Example
    [STATUS] HTTP status code; 0 means no response "[STATUS] == 200", "[STATUS] < 400"
    [CERTIFICATE_EXPIRATION] time left before the TLS certificate expires "[CERTIFICATE_EXPIRATION] > 336h"
    [RESPONSE_TIME] response time in milliseconds "[RESPONSE_TIME] < 1000"
    [BODY] response body; add a path for a JSON field "[BODY].status == UP"
    [CONNECTED] whether a TCP connection succeeded (tcp://) "[CONNECTED] == true"

    Operators are ==, !=, <, <=, >, >=. With == you can use any(200, 401) to match any listed value or pat(2*) for wildcard matching. Checks aren’t limited to HTTP: url: tcp://203.0.113.10:22 with [CONNECTED] == true verifies that SSH is listening.

    Traefik renews certificates 30 days before expiry. Setting > 336h (14 days) triggers only if renewal has been failing for over two weeks — early enough to fix while the site still loads.

    Alerts: how many failures in a row

    A single failed check doesn’t fire an alert. Gatus counts consecutive failures and alerts once they hit failure-threshold; the resolved message goes out after success-threshold consecutive passes. One or two failures followed by a pass reset the counter with no notification.

    alerting:
      ntfy:
        topic: "${NTFY_TOPIC}"
        default-alert:
          failure-threshold: 3
          success-threshold: 2
          send-on-resolved: true

    With a 1-minute interval and a threshold of 3, an alert arrives after two to three minutes of downtime — the first failing check can land up to a minute after the outage begins. A 30-second container restart passes unnoticed. send-on-resolved is off by default; without it you never get the recovery notice.

    default-alert sets shared thresholds, yet it doesn’t turn alerts on. Every endpoint needs:

        alerts:
          - type: ntfy

    Without it, the endpoint turns red on the dashboard and sends nothing. You can override thresholds in the same block — for instance, failure-threshold: 5 for a service that takes longer to come up after an update.

    While a service stays down, Gatus sends nothing after the initial alert. To repeat it, add minimum-reminder-interval to the endpoint’s alert (minimum 5 minutes); it resends the same text:

        alerts:
          - type: ntfy
            minimum-reminder-interval: 1h

    What lands on your phone

    The title is Gatus: plus the endpoint name. The body lists each condition with its status and, for failed ones, the actual value in parentheses:

    Gatus: memos
    An alert has been triggered due to having failed 3 time(s) in a row
    🔴 [STATUS] (404) == 200
    🟢 [CERTIFICATE_EXPIRATION] > 336h

    The value in parentheses tells you what broke: (404) means Traefik is up and the backend behind it is gone; (0) means Gatus couldn’t reach the server at all; [CONNECTED] (false) means the port is closed; a certificate check prints the remaining lifetime like (250h12m5s). A plain [BODY] condition dumps the whole response in parentheses, so match a JSON field instead: [BODY].status (DOWN) == UP.

    The topic comes from the environment: Gatus expands ${NTFY_TOPIC} when loading the config, and Compose injects it from .env. To write a literal $ in the config, escape it as $$. alerting.ntfy also supports priority (defaults to 3), click for the URL opened when you tap the notification, and url plus token for a self-hosted ntfy server.

    Editing the config: Gatus reloads automatically

    Every 30 seconds Gatus checks whether config.yaml changed and reloads it without a container restart. Mount the config/ directory rather than a single file: with a single-file mount, edits made via sed -i or git pull stay invisible to the container (Single-file mounts).

    A broken config crashes Gatus, and every restart hits the same bad file:

    panic: error parsing config: yaml: line 17: did not find expected '-' indicator

    skip-invalid-config-update: true doesn’t save you in 5.38: Gatus logs The old configuration will continue being used., then stops running checks and serving the page until a valid config arrives. The container stays Up, so it looks healthy from the outside.

    Edit a copy, validate it with a one-shot Gatus container, and only then move it into place:

    1. Copy

      cd /opt/gatus
      sudo cp config/config.yaml config.new.yaml
      sudo nano config.new.yaml

      Keep the copy outside config/ so the running Gatus instance ignores it.

    2. Validate

      sudo timeout 10 docker run --rm --tmpfs /data --env-file .env \
        -v ./config.new.yaml:/config/config.yaml:ro twinproduction/gatus:stable 2>&1 \
        | grep -E 'panic|Listening'

      Listening on 0.0.0.0:8080 means the YAML and all conditions parsed cleanly; timeout stops the temporary container after 10 seconds. panic: … shows the error and line number. --tmpfs /data gives the one-shot container a writable database directory — without it, Gatus exits with unable to open database file even when the config is valid.

    3. Replace

      sudo mv config.new.yaml config/config.yaml
      sudo docker logs gatus 2>&1 | tail -3

      Within 30 seconds the log prints Configuration file has been modified, followed by checks using the updated config.

    Validation catches YAML and condition syntax errors, not bad URLs — a typo in url shows up as a red check on the page. Gatus doesn’t alert on its own death; the Beszel hub sends the external heartbeat to Healthchecks.io (Beszel).

    If it doesn’t work

    gatus loops in restarts, and sudo docker logs gatus says panic: error parsing config: yaml: line 17: did not find expected '-' indicator

    Cause
    There is a syntax error in config.yaml, and Gatus reloaded it automatically. Most often a condition is missing quotes: YAML reads a string starting with [ as a list. The line number points to where YAML tripped.
    Fix
    Fix the line and wrap conditions in double quotes. The next container restart will load the valid file. For future edits, test a copy first — see “Editing the config”.

    The container is Up, yet the Gatus page won’t load and checks stop; the log says The old configuration will continue being used.

    Cause
    skip-invalid-config-update: true is set and the config received an invalid edit. In 5.38 Gatus doesn’t crash, yet it halts both checks and the web UI until a valid config replaces it.
    Fix
    Fix the config — Gatus recovers within 30 seconds. Remove skip-invalid-config-update: silent monitoring is worse than a crashed container.

    A check is red, your phone is quiet, and the log says Not sending alert of type=ntfy … because the provider wasn't configured properly

    Cause
    The ntfy topic is empty: NTFY_TOPIC is missing from .env or the container wasn’t recreated after editing it. On startup Gatus logs Ignoring provider=ntfy due to error=topic not set.
    Fix
    Set the topic in /opt/gatus/.env, then run cd /opt/gatus && sudo docker compose up -d. The startup log should show configuredProviders=[ntfy].

    A check is red, your phone is quiet, and the log mentions nothing about an alert

    Cause
    The endpoint has no alerts: block. default-alert under alerting.ntfy sets thresholds, whereas - type: ntfy on each endpoint is what enables alerting.
    Fix
    Add alerts: with - type: ntfy to the endpoint.

    The notification dumps an entire HTML page

    Cause
    A condition checks [BODY] as a whole: on failure Gatus inserts the actual value into the alert text, which is the full response body.
    Fix
    Check a JSON field instead ([BODY].status == UP prints only (DOWN)), or drop the body condition: [STATUS] is enough for a web page.

    The alert shows [STATUS] (0) == 200

    Cause
    No response came back: the connection failed, DNS didn’t resolve, or the request timed out. Status 0 means Gatus never reached the service.
    Fix
    Test from the server with curl -sI https://memos.example.org. If curl fails too, the service is down or DNS is broken; if it succeeds, compare url in config.yaml against that address.

    A service was down for a minute and no alert fired

    Cause
    Gatus alerts after failure-threshold failures in a row: with 3 and a 1-minute interval, that takes three minutes. Anything shorter isn’t supposed to alert.
    Fix
    Leave it as is. If you need faster alerts, lower interval on that endpoint instead of setting the threshold to 1, which pages on every restart.

    How to check

    Confirm ntfy is active in the startup log:

    sudo docker logs gatus 2>&1 | grep -o 'configuredProviders=\[[a-z-]*\]' | tail -1
    # configuredProviders=[ntfy]

    Test alerts by action (Test your server’s protection by action): stop a service and wait for the notification.

    cd /opt/memos && sudo docker compose stop
    # after 2–3 minutes: Gatus: memos, 🔴 [STATUS] (404) == 200
    sudo docker compose start
    # after a couple of minutes: An alert has been resolved…