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

FerretDB Backend Readiness & Connection Pool Sentinel

Audit FerretDB MongoDB-proxy readiness, track PostgreSQL backend connection saturation, and alert via Slack to prevent unhandled database query failures.

Categories
Infrastructure

FerretDB is an open-source proxy that translates MongoDB wire protocol queries into PostgreSQL SQL statements, providing a drop-in open-source alternative to MongoDB. In production environments where analytics and application workloads communicate through FerretDB, unhandled MongoDB aggregation queries or PostgreSQL connection pool exhaustion can cause silent proxy degradation, transaction backlogs, and connection drops. This blueprint deploys an automated operational sentinel that queries FerretDB health and Prometheus metrics endpoints, validates PostgreSQL backend connectivity, evaluates connection pool headroom, routes incident notifications to Slack, and provides guarded remediation paths.

How it works

  1. periodic_ferretdb_audit (io.kestra.plugin.core.trigger.Schedule) triggers the audit workflow every 15 minutes. Shipped disabled so initial parameters can be validated manually first.
  2. probe_readiness_status (io.kestra.plugin.core.http.Request) invokes GET /debug/readyz to verify proxy uptime and backend PostgreSQL database connectivity.
  3. probe_runtime_metrics (io.kestra.plugin.core.http.Request) invokes GET /debug/metrics to scrape Prometheus telemetry including connection pool states and command error counters.
  4. classify_ferretdb_health (io.kestra.plugin.core.flow.Switch) classifies the operational condition:
    • UNREADY: Triggers when the readiness endpoint returns non-200 or failure status, dispatching a critical Slack alert via io.kestra.plugin.slack.notifications.SlackIncomingWebhook.
    • DEGRADED: Triggers when telemetry indicates connection pool contention or query errors, routing a warning to Slack and evaluating diagnostic logging.
    • HEALTHY: Confirms that both the proxy and backend PostgreSQL operate with nominal headroom.
  5. log_sentinel_audit (io.kestra.plugin.core.log.Log) records an immutable audit log entry documenting execution status and endpoint response codes.
  6. Global errors handler catches connection refusals or network timeouts, immediately firing an outage alert to Slack.

What you get

  • Automated continuous surveillance of FerretDB proxy health and backend PostgreSQL connectivity.
  • Proactive alerts on Slack before backend connection saturation causes application-level connection timeouts.
  • Safe dry-run guarding: default dry_run: true prevents automated mutations during cluster audits.
  • Centralized audit lineage within Kestra tracking database health over time.

Who it's for

  • Platform Engineers and SREs managing open-source database infrastructure and MongoDB-to-PostgreSQL migrations.
  • DevOps Teams running FerretDB in containerized environments (Kubernetes, Docker) needing automated health surveillance.
  • Database Administrators monitoring PostgreSQL connection pools and query translation efficiency.

Why orchestrate this with Kestra

FerretDB exposes lightweight HTTP health and telemetry endpoints but does not provide built-in alerting, scheduling, or remediation capabilities. Replacing brittle external shell scripts or unmonitored crons with Kestra delivers a declarative YAML blueprint featuring scheduled triggers, masked secret handling, conditional multi-branch routing, and comprehensive execution audit logs.

Prerequisites

  • A running FerretDB instance (version 1.0+) accessible over HTTP. FerretDB provides an official open-source all-in-one Docker image (ghcr.io/ferretdb/all-in-one:latest) bundling PostgreSQL with zero external dependencies.
  • An incoming Slack webhook URL for incident notifications.

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook URL for operational and emergency alerts.

Quick start

  1. Launch a local FerretDB all-in-one test container:
    docker run -d --name ferretdb-test -p 27017:27017 -p 8088:8088 ghcr.io/ferretdb/all-in-one: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 readiness status.
  5. Test alerting by stopping the container (docker stop ferretdb-test) and re-running the flow to verify alert_probe_network_failure.
  6. Enable periodic_ferretdb_audit to activate automated 15-minute monitoring.

How to extend

  • 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 to self-heal stalled proxy containers when dry_run: false.
  • Export Prometheus health status to external APM dashboards using io.kestra.plugin.prometheus.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.