Schedule icon
Request icon
Switch icon
SlackIncomingWebhook icon
If icon
Log icon

PocketBase API Engine Health & Database Storage Sentinel

Audit PocketBase API engine health, monitor embedded SQLite database responsiveness, and alert via Slack to prevent application data persistence failures.

Categories
Infrastructure

PocketBase is an open-source, single-binary Go backend consisting of embedded SQLite database storage, real-time subscriptions, file storage, and a comprehensive REST API. Widely adopted across internal engineering tools, mobile applications, and edge services, PocketBase provides an all-in-one backend architecture with minimal operational footprint. However, in production microservices, uncheckpointed SQLite Write-Ahead Logging (WAL), unindexed full-text queries, or high write concurrency can cause SQLite database locks, resulting in HTTP 500 errors and degraded API responsiveness. This blueprint implements an automated operational sentinel that polls PocketBase core health endpoints, monitors database collection catalogs against capacity baselines, dispatches incident alerts to Slack, and maintains execution audit lineage.

How it works

  1. periodic_pocketbase_audit (io.kestra.plugin.core.trigger.Schedule) initiates scheduled monitoring every 15 minutes. Shipped disabled so initial connectivity can be verified manually.
  2. probe_pocketbase_health (io.kestra.plugin.core.http.Request) invokes GET /api/health to confirm Go engine health, SQLite read/write capability, and storage volume integrity.
  3. probe_pocketbase_collections (io.kestra.plugin.core.http.Request) invokes GET /api/collections to audit active database tables and verify schema responsiveness.
  4. classify_pocketbase_status (io.kestra.plugin.core.flow.Switch) analyzes probe results:
    • ENGINE_UNHEALTHY: Fires if /api/health returns non-200 or an error code, routing an emergency Slack notification via io.kestra.plugin.slack.notifications.SlackIncomingWebhook.
    • SCHEMA_DRIFT_WARNING: Fires when total collection count exceeds max_collections_threshold, notifying the DevOps team of potential migration sprawl.
    • HEALTHY: Confirms that both the API runtime and embedded SQLite operate within nominal latency and capacity bounds.
  5. log_sentinel_audit_summary (io.kestra.plugin.core.log.Log) records an immutable audit record documenting operational status and collection tallies.
  6. Global errors handler catches connection drops, timeouts, or daemon crashes, immediately firing an outage alert to Slack.

What you get

  • Automated continuous surveillance of PocketBase backend API responsiveness and SQLite database availability.
  • Proactive alerts on Slack before SQLite database lockups or disk saturation impact user-facing client applications.
  • Safe dry-run guarding: default dry_run: true prevents inadvertent mutations during health evaluations.
  • Centralized audit lineage within Kestra tracking database collection growth and uptime history.

Who it's for

  • Platform Engineers and SREs hosting PocketBase backends on edge nodes, Docker, or Kubernetes clusters.
  • DevOps Teams running internal developer portals and lightweight database services requiring uptime guarantees.
  • Full-Stack Developers operating self-hosted PocketBase backends seeking automated failure notifications.

Why orchestrate this with Kestra

PocketBase exposes lightweight HTTP health endpoints but lacks built-in alerting, cron scheduling, and multi-channel incident escalation. Relying on standalone cron scripts introduces single points of failure, unprotected credentials, and zero execution tracking. Kestra delivers a declarative YAML blueprint featuring scheduled triggers, masked secret management, conditional branching, and comprehensive execution observability.

Prerequisites

  • A running PocketBase instance (version 0.20.0+) accessible over HTTP. PocketBase provides an official open-source Docker image (ghcr.io/muchobien/pocketbase:latest) requiring zero commercial licensing.
  • An incoming Slack webhook URL for operational notifications.

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook URL for operational notifications and incident routing.

Quick start

  1. Start a local PocketBase test container:
    docker run -d --name pocketbase-test -p 8090:8090 ghcr.io/muchobien/pocketbase:latest
    
  2. Configure SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  3. Import this blueprint and execute with default inputs (dry_run: true).
  4. Confirm that log_healthy_state records a successful API response (code: 200).
  5. Test alerting by stopping the container (docker stop pocketbase-test) and re-running the flow to verify alert_pocketbase_network_failure.
  6. Enable periodic_pocketbase_audit to activate recurring 15-minute surveillance.

How to extend

  • Add automated SQLite database backup sync to AWS S3 using io.kestra.plugin.aws.s3.Upload.
  • Integrate with PagerDuty via io.kestra.plugin.pagerduty.notifications.PagerDutyAlert for high-severity database outages.
  • Add automated container restart tasks via io.kestra.plugin.docker when dry_run: false to self-heal crashed daemons.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.