Schedule icon
Request icon
Log icon
Switch icon
SlackIncomingWebhook icon
OutputValues icon

Directus API Engine Health, Database Pool, and Schema Sentinel

Audit Directus API engine health, monitor database pool liveness, validate OpenAPI schema specification readiness, and alert Slack on incidents via Kestra.

Categories
Data

Proactively audit Directus headless data platform health, database connection pooling readiness, and OpenAPI schema generation integrity to prevent client API downtime.

How it works

  1. Automated Heartbeat Trigger: A scheduled cron trigger executes every 15 minutes to run an automated surveillance audit across Directus sub-systems, with on-demand manual or webhook execution supported.
  2. Multi-Stage Service Probes:
    • probe_server_health: Queries the native Directus /server/health endpoint to verify PostgreSQL/MySQL/SQLite database connection pool health and server heartbeat.
    • probe_server_info: Queries /server/info to check server release version, rate limiter status, and caching tier responsiveness.
    • probe_schema_specification: Queries /server/specs/oas to validate that OpenAPI 3.0 schema generation and data model reflection engines are fully responsive.
  3. Pebble Health Classification: Evaluates response status codes, sub-service availability, and response latencies to classify cluster state into OPERATIONAL, DEGRADED, or CRITICAL.
  4. Switch Routing & Safe Remediation:
    • CRITICAL: Emits urgent error diagnostics and immediately dispatches a formatted incident alert to Slack containing status codes and execution context.
    • DEGRADED: Emits a warning log for non-critical sub-service delays and dispatches a Slack warning notification if warning alerts are enabled.
    • OPERATIONAL: Emits a health verification log confirming all Directus endpoints and schema generators are healthy.
  5. Structured Telemetry Output: Emits structured outputs via io.kestra.plugin.core.output.OutputValues for downstream monitoring dashboards, APM systems, or data lake ingestion.
  6. Error Incident Fallback: Dedicated errors task catches network connection refused errors or worker timeout exceptions, alerting engineering teams instantly.

What you get

  • Continuous validation of your self-hosted Directus data engine and headless API layer.
  • Early warning detection for database connection pool exhaustion, migration lockups, or OpenAPI schema generation failures before client applications fail.
  • Automated multi-channel Slack incident alerting with formatted block layouts and execution context.
  • Comprehensive telemetry audit log with timestamped metrics for long-term health tracking.
  • Zero vendor lock-in, fully testable against standard open-source Directus Docker containers.

Who it's for

  • Data Platform Engineers: Ensuring high availability of database-backed headless APIs and operational data layers.
  • Site Reliability Engineers (SREs): Automating proactive drift detection and platform heartbeat monitoring without external SaaS dependencies.
  • Backend & Full-Stack Developers: Maintaining reliable GraphQL and REST endpoints across production client applications.

Why orchestrate this with Kestra

  • Declarative YAML Workflows: Define your infrastructure monitoring alongside your CI/CD pipelines in version-controlled Git repositories.
  • Built-in Resilience & Retries: Automatically handle transient network jitter with configurable retry policies on individual probe tasks.
  • Stateful Flow Control: Seamlessly branch between operational logs and multi-channel incident dispatches without writing fragile shell scripts.
  • Unified Telemetry & Auditability: Every execution retains full output history, timing metrics, and response payloads for forensic analysis.

Prerequisites

  • An operational Directus instance (accessible via HTTP or HTTPS).
  • Network connectivity from the Kestra worker to the Directus instance.
  • (Optional) An incoming Slack Webhook URL for incident notifications.
  • (Optional) A Directus static API token if your instance restricts public access to server specs.

Secrets

  • SLACK_WEBHOOK_URL: (Optional) Slack Incoming Webhook URL to dispatch alerts on degraded or critical status.
  • DIRECTUS_API_TOKEN: (Optional) Admin or static token for authenticated API requests if the Directus server requires authorization.

Quick start

  1. Start a local Directus container for testing:
    docker run -d --name directus -p 8055:8055 -e KEY=kestra-secret-key -e SECRET=kestra-jwt-secret -e ADMIN_EMAIL=admin@example.com -e ADMIN_PASSWORD=admin directus/directus:latest
    
  2. Add the SLACK_WEBHOOK_URL secret in your Kestra namespace or pass it as an execution input.
  3. Import this flow into your Kestra instance.
  4. Execute the flow manually with directus_url: http://localhost:8055 to verify connectivity.
  5. Enable the schedule trigger for continuous 15-minute background monitoring.

How to extend

  • Schema Drift Auditor: Compare the OpenAPI JSON output against a version-controlled contract in Git to detect unapproved collection or field alterations.
  • Database Read/Write Canary: Add a task that performs a test record creation and deletion against a designated canary collection to test write transaction readiness.
  • Cache Invalidation Trigger: Call /utils/cache/clear automatically when degraded schema states or cache desynchronizations are identified.
  • Prometheus Metric Export: Push probe latency and health scores to a Prometheus Pushgateway or OpenTelemetry collector for unified Grafana dashboards.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.