Schedule icon
Request icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon

Appwrite Backend Health Gate

Check Appwrite database, cache, and clock health and alert Slack when a subsystem degrades.

Categories
Infrastructure

Appwrite ships its own /health endpoints specifically so operators can validate every internal subsystem without guessing from application-level errors. This blueprint calls three of them on a schedule, classifies the backend as healthy or degraded, and pages Slack the moment the database connection fails, the cache connection fails, or the server clock drifts too far from a trusted time source.

How it works

  1. check_database_health (io.kestra.plugin.core.http.Request) calls GET /health/db with the project's API key, returning {name, ping, status} where status is pass or fail.
  2. check_cache_health calls GET /health/cache the same way, checking the in-memory cache connection.
  3. check_clock_drift calls GET /health/time, returning {remoteTime, localTime, diff} where diff is the millisecond difference between the Appwrite server's clock and a trusted remote time source. All three tasks use allowFailure: true so a single unreachable endpoint does not abort the flow before classification.
  4. classify_backend_health (io.kestra.plugin.core.debug.Return) checks whether all three response bodies are defined; if not, UNREACHABLE. Otherwise it reads each status field and the absolute value of diff with jq, returning DEGRADED if the database check failed, the cache check failed, or the clock drift exceeds clock_drift_threshold_ms, otherwise HEALTHY.
  5. route_by_backend_health (io.kestra.plugin.core.flow.Switch) branches on that string: HEALTHY logs a quiet confirmation, DEGRADED pages Slack with the exact failing subsystem(s) and drift value, UNREACHABLE pages Slack separately, and defaults logs the raw outcome.
  6. log_audit_status records a status line on every run regardless of branch, so the execution history is a continuous backend-health trend.
  7. The errors block pages Slack separately if the flow itself fails outright.
  8. The backend_health_schedule trigger polls every 10 minutes with explicit input overrides, shipped disabled: true until you point it at a real Appwrite project.

What you get

  • A scheduled, multi-subsystem backend health check with zero custom Appwrite SDK code.
  • A three-way status output (HEALTHY / DEGRADED / UNREACHABLE) you can chart or gate other flows on.
  • A Slack page naming the exact subsystem (database, cache, or clock) behind a degradation, not just a generic warning.
  • A separate failure channel for the gate flow itself, plus a standing audit log line per run.

Who it's for

  • Platform teams running self-hosted Appwrite who want proactive alerting before a degraded database or cache connection turns into a user-facing outage.
  • Teams relying on Appwrite's time-sensitive features (JWT expiry, rate limiting, scheduled functions) who need to know when server clock drift could silently break them.

Why orchestrate this with Kestra

Hitting /health/db from an uptime monitor tells you pass or fail with no history. This flow keeps every probe, every classification, and every alert in the execution history, turns the check into a typed output other flows can depend on, and gives you a Switch branch to grow into real remediation (restarting a specific worker container, opening a ticket per failing subsystem) without rewriting the check itself.

Prerequisites

  • A self-hosted Appwrite instance reachable at appwrite_url. The free, official Docker Compose setup (docker run -it --rm appwrite/appwrite:latest, which generates the full docker-compose.yml) is enough to fully test this blueprint locally.
  • An Appwrite project and a server-side API key with access to the Health scope.
  • A Slack incoming webhook for the degraded and unreachable alerts.

Secrets

  • APPWRITE_API_KEY: Appwrite server API key with the Health scope, sent as the X-Appwrite-Key header.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used for the degraded alert, the unreachable alert, and the flow-failure alert.
  • OSS note: if your Kestra instance reads secrets from environment variables instead of a secrets backend, set SECRET_APPWRITE_API_KEY and SECRET_SLACK_WEBHOOK_URL as base64, for example echo -n "<your-value>" | base64.

Quick start

  1. Add the APPWRITE_API_KEY and SLACK_WEBHOOK_URL secrets.
  2. Set appwrite_url and project_id to your Appwrite instance and project.
  3. Run the flow once and confirm status reads HEALTHY.
  4. Enable backend_health_schedule.

How to extend

  • Add GET /health/storage and GET /health/pubsub as two more probe tasks for a full subsystem sweep instead of just database, cache, and clock.
  • Call GET /health/queue/webhooks and GET /health/queue/certificates to also catch a backlogged internal queue before it delays webhooks or certificate renewal.
  • Store each run's diff value in a KV store to build a longer clock-drift trend than the execution history alone provides.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.