Schedule icon
Query icon
Log icon
Switch icon
SlackIncomingWebhook icon

SurrealDB Table Record Volume High-Watermark and Storage Quota Sentinel

Monitor SurrealDB table record counts against high-watermark capacity limits, audit schema indexes, and alert Slack on storage quota breaches via Kestra.

Categories
Data

Proactively audit SurrealDB multi-model table record volumes, evaluate row growth against operational high-watermark quotas, verify active schema indexes, and dispatch incident alerts to Slack before storage exhaustion or query degradation occurs.

How it works

  1. Automated Heartbeat Trigger: periodic_capacity_schedule (io.kestra.plugin.core.trigger.Schedule) initiates a periodic surveillance check every 30 minutes, with support for manual on-demand execution.
  2. Multi-Stage Database Probes:
    • probe_table_record_metrics (io.kestra.plugin.surrealdb.Query) runs an aggregation query (SELECT count() AS total_records FROM table GROUP ALL) against the specified SurrealDB namespace and database to measure exact table row volume.
    • probe_table_schema_indexes (io.kestra.plugin.surrealdb.Query) runs INFO FOR TABLE table to inspect active schema definitions and verify index coverage for scalable queries.
  3. Pebble Capacity Evaluation: Evaluates the retrieved record count against configured warning and critical capacity limits to classify cluster status as HEALTHY, WARNING, or CRITICAL.
  4. Switch Routing & Safe Remediation:
    • CRITICAL: Emits an error log and dispatches a high-priority incident alert to Slack with table details, current record volume, and quota limits.
    • WARNING: Emits a warning log and dispatches a warning notification to Slack when warning alerts are enabled.
    • HEALTHY: Emits an operational log confirming record volume is safely below capacity limits.
  5. Audit Trail Logging: log_audit_summary (io.kestra.plugin.core.log.Log) writes a persistent telemetry summary into Kestra execution logs for capacity planning and historical trend tracking.
  6. Error Incident Fallback: Dedicated errors tasks catch connection timeouts or credential authentication failures, paging engineering teams immediately.

What you get

  • Automated capacity monitoring for self-hosted or cloud SurrealDB clusters.
  • Early warning detection for runaway append-only tables, uncompacted event streams, or session log accumulation before storage limits are breached.
  • Real-time Slack notifications with actionable run context and remediation recommendations.
  • Verification of schema table configuration and index health alongside record counts.
  • Fully reproducible orchestration testable against free, open-source SurrealDB Docker images.

Who it's for

  • Database Administrators (DBAs) & Platform Engineers: Managing SurrealDB multi-model storage capacity and ensuring database cluster headroom.
  • Site Reliability Engineers (SREs): Automating proactive quota alerting and incident prevention across operational data services.
  • Backend & Data Engineers: Monitoring high-throughput ingestion pipelines and maintaining query performance SLA bounds.

Why orchestrate this with Kestra

SurrealDB delivers high-performance multi-model querying, but lacks native scheduled quota enforcement and cross-system incident alerting. Orchestrating this sentinel with Kestra provides declarative YAML workflows, secret isolation for database credentials, automated retries against transient network delays, and unified execution history across your infrastructure.

Prerequisites

  • A running SurrealDB instance reachable from the Kestra worker over TCP (default port 8000).
  • Administrative or namespace-level credentials with read access to the target database and tables.
  • An incoming Slack webhook URL for alert notifications.
  • port is hard-coded to 8000 on both probe_table_record_metrics and probe_table_schema_indexes, not exposed as a flow input: io.kestra.plugin.surrealdb.Query's port is a plain int property, not a Property<T>, so it does not accept a Pebble expression. If your instance listens on a different port, edit the port: 8000 line on both tasks directly.

Secrets

  • SURREALDB_PASSWORD: Password for authenticating the SurrealDB user account.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used to dispatch capacity breach alerts.

Quick start

  1. Start a local open-source SurrealDB container for testing:
    docker run -d --name surrealdb -p 8000:8000 surrealdb/surrealdb:latest start --user root --pass root memory
    
  2. Add the SURREALDB_PASSWORD and SLACK_WEBHOOK_URL secrets in your Kestra namespace.
  3. Import this blueprint into your Kestra instance.
  4. Execute the flow manually to verify database connectivity and inspect the initial capacity scan.
  5. Enable the periodic_capacity_schedule trigger for automated background monitoring.

How to extend

  • Automated Data Lifecycle Retention: Add an automated cleanup task in the CRITICAL branch to archive records older than a retention window into cloud object storage (S3/GCS) and execute DELETE FROM table WHERE created_at < time::now() - 30d.
  • Multi-Table Fan-Out: Wrap the probe tasks in a Loop flow task to iterate through all tables returned by INFO FOR DB and audit the entire database fleet in a single flow execution.
  • Prometheus & Grafana Export: Push row count gauges to a Prometheus Pushgateway or OpenTelemetry endpoint for continuous trend dashboards.
  • PagerDuty & Opsgenie Escalation: Add secondary notification tasks to page on-call SRE rotations during persistent critical quota breaches.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.