Schedule icon
Request icon
Script icon
Set icon
If icon
SlackIncomingWebhook icon
Loop icon
Log icon

RabbitMQ Dynamic Shovel Unacknowledged Backlog and Link Health Guard

Monitor RabbitMQ dynamic shovels for unacknowledged backlog and stalled link rates, auto-restart frozen workers, and persist telemetry in Kestra KV.

Categories
DataInfrastructure

RabbitMQ Dynamic Shovels move messages reliably across queues, exchanges, and clusters. However, dynamic shovel worker threads can quietly stall when TCP half-open states occur, downstream prefetch buffers fill up with unacknowledged messages without acknowledgments, or transient network disconnects leave links in terminated or starting states. Because the source queue continues to accept upstream publishes while the shovel consumer is frozen, unacknowledged messages and backlogs accumulate, leading to consumer starvation and broker memory pressure.

This blueprint implements an automated health guard for RabbitMQ Dynamic Shovels. It polls the RabbitMQ Management HTTP API (/api/shovels, /api/parameters/shovel, and /api/queues), correlates live link states with source queue unacknowledged message depths and delivery rates, flags stalled or dead links, dispatches Slack incident alerts, persists health telemetry in Kestra's KV store, and safely restarts stalled shovels via HTTP parameter deletion and recreation.

How it works

  1. periodic_shovel_health_audit (io.kestra.plugin.core.trigger.Schedule) triggers the flow every 5 minutes. It is initialized in disabled: true mode for safe manual validation.
  2. fetch_shovel_parameters, fetch_shovel_statuses, and fetch_queue_statistics query the RabbitMQ Management HTTP API using io.kestra.plugin.core.http.Request with HTTP Basic Authentication over TLS or plaintext.
  3. evaluate_shovel_health (io.kestra.plugin.scripts.python.Script) runs in a Python 3.11 sandbox to:
    • Cross-reference dynamic shovel parameter definitions with live link statuses.
    • Locate source queues and inspect messages_unacknowledged, messages_ready, and delivery rates (deliver_get_details.rate).
    • Flag any shovel whose state is not running (such as terminated or starting).
    • Flag stalled shovels where unacknowledged messages exceed unacked_threshold or ready messages exceed backlog_threshold while delivery rate is 0.
    • Structure comprehensive telemetry metrics for KV persistence and remediation.
  4. record_shovel_health_kv (io.kestra.plugin.core.kv.Set) stores the telemetry object under a namespaced KV key for historical reporting and external dashboards.
  5. branch_on_stalled_shovels (io.kestra.plugin.core.flow.If) evaluates whether any stalled shovels were detected:
    • When detected, alert_stalled_shovels_slack sends a detailed operational alert with affected shovel names, vhosts, backlog counts, and delivery rates.
    • If auto_restart is enabled and dry_run is false, restart_stalled_shovels (io.kestra.plugin.core.flow.Loop) executes an atomic restart sequence: deleting the shovel parameter (DELETE /api/parameters/shovel/{vhost}/{name}) to terminate the hung erlang worker, followed by recreating it (PUT /api/parameters/shovel/{vhost}/{name}) with the original parameter payload.
    • Otherwise, a dry-run log message records the findings without altering cluster state.
  6. When all shovels are running normally and message throughput is healthy, log_all_shovels_healthy logs the healthy audit summary.
  7. The flow-level errors block dispatches an alert to Slack if connectivity to the RabbitMQ API fails.

What you get

  • Early detection of silent shovel consumer stalls before queues exhaust broker memory limits.
  • Visibility into unacknowledged message accumulation and delivery rate starvation.
  • Automated self-healing through parameter recreation that unblocks frozen shovel connections without broker restarts.
  • Continuous operational telemetry persisted into Kestra's KV store.
  • Actionable Slack notifications with source and destination queue details, error reasons, and remediation status.

Who it's for

  • Site Reliability Engineers (SREs) and DevOps teams maintaining cross-region or hybrid-cloud RabbitMQ topologies.
  • Messaging and Event Platform teams operating RabbitMQ Dynamic Shovels for event replication.
  • Backend engineers troubleshooting unexplained queue backlog growth and consumer starvation.

Why orchestrate this with Kestra

RabbitMQ Management provides status dashboards but lacks native automated remediation for stalled dynamic shovel links. A bash cron script running curl lacks centralized audit lineage, secret masking, structured KV telemetry, and flexible dry-run control. Kestra combines declarative API polling, containerized python data correlation, Slack alerting, and automated REST parameter remediation into an observable, version-controlled blueprint.

Prerequisites

  • A running RabbitMQ cluster with the rabbitmq_management and rabbitmq_shovel_management plugins enabled.
  • A RabbitMQ user with monitoring or administrator tags to access management endpoints and manage runtime parameters.
  • An incoming Slack webhook URL for operational notifications.

Secrets

  • RABBITMQ_MANAGEMENT_USERNAME: RabbitMQ user with access to /api/shovels, /api/parameters/shovel, and /api/queues.
  • RABBITMQ_MANAGEMENT_PASSWORD: Password matching the management user.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used to dispatch alerts and remediation summaries.

Quick start

  1. Configure the RABBITMQ_MANAGEMENT_USERNAME, RABBITMQ_MANAGEMENT_PASSWORD, and SLACK_WEBHOOK_URL secrets in your Kestra namespace.
  2. Import this blueprint into Kestra.
  3. Execute the flow with default inputs (dry_run: true) to safely inspect active shovels and observe KV store metrics.
  4. Confirm that your dynamic shovels and queues appear in the execution logs and KV store.
  5. Set auto_restart: true and dry_run: false to enable automated self-healing remediation.
  6. Enable periodic_shovel_health_audit to schedule continuous 5-minute health monitoring.

How to extend

  • Route incident alerts to PagerDuty or Opsgenie using Kestra notification plugins for P1 alerts.
  • Combine with Kestra's Dead-Letter Queue (DLQ) blueprints to inspect and quarantine poison pills rejected by the destination cluster.
  • Add custom Prometheus metrics emission to record shovel latency and delivery throughput over time.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.