Schedule icon
Consume icon
Switch icon
SlackIncomingWebhook icon
If icon
Log icon

AMQP Queue Depth and Backlog Sentinel

Monitor RabbitMQ AMQP queue depth with Kestra. Sample backlog messages, evaluate threshold rules, dispatch Slack alerts, and trigger quarantine actions.

Categories
DataInfrastructure

Maintain message broker health by auditing AMQP queue depth before consumer lag causes memory pressure or downstream delivery timeouts. This blueprint uses Kestra's AMQP plugin to sample unconsumed messages from a target queue, evaluates backlog metrics against configurable threshold rules, and dispatches automated Slack notifications and safe quarantine logging when queue depth breaches operational SLAs.

How it works

  1. probe_queue (io.kestra.plugin.amqp.Consume) samples pending messages from the designated AMQP queue (inputs.queue_name) up to max_records_probe within a 10-second polling window (PT10S).
  2. evaluate_backlog (io.kestra.plugin.core.flow.Switch) checks whether the consumed message count (outputs.probe_queue.count) exceeds the backlog_threshold value.
  3. If the count exceeds the threshold, dispatch_backlog_alert (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) posts a notification to Slack detailing the queue name, message count, and remediation status.
  4. evaluate_remediation (io.kestra.plugin.core.flow.If) checks whether remediation_action is set to PURGE_EXPIRED and dry_run is set to false, logging active quarantine remediation if enabled.
  5. If the count is within threshold, log_queue_healthy (io.kestra.plugin.core.log.Log) records a healthy audit status.
  6. log_audit_summary (io.kestra.plugin.core.log.Log) confirms completion of the audit pass with full execution lineage.
  7. A flow-level errors block (alert_flow_failure) catches broker connection failures or unhandled task errors, dispatching an incident notification to Slack.

What you get

  • Automated, non-destructive queue depth sampling across RabbitMQ and AMQP brokers.
  • Configurable backlog threshold evaluation with dry-run protection.
  • Instant Slack alerts detailing queue backlog spikes before consumer exhaustion occurs.
  • Centralized execution lineage and audit history inside Kestra.

Who it's for

  • Site Reliability Engineers (SREs) and Messaging Platform engineers maintaining RabbitMQ clusters.
  • Data Engineers running real-time streaming pipelines who need automated consumer lag alerting.
  • System Administrators looking to eliminate opaque custom queue monitoring scripts.

Why orchestrate this with Kestra

Monitoring RabbitMQ queue depth with custom cron scripts or external exporter plugins leaves monitoring isolated from your primary workflow orchestrator. Kestra provides declarative YAML management, built-in secret management, native Slack notification blocks, and execution logging in a single pane of glass. By running queue health audits directly inside Kestra, SREs gain end-to-end visibility and can chain downstream recovery flows seamlessly.

Prerequisites

  • A running RabbitMQ or AMQP 0-9-1 compatible message broker.
  • An active AMQP queue with read permissions.
  • A configured Slack Incoming Webhook URL.

Quick start

Import this blueprint into your Kestra instance, configure your AMQP broker connection secrets (RABBITMQ_HOST, RABBITMQ_PORT, etc.), and run an initial execution to sample queue backlog metrics.

How to extend

Extend this flow by chaining container auto-scaling triggers or copying dead-letter payloads into object storage (e.g., AWS S3 or Google Cloud Storage) when queue backlog thresholds are breached.

Secrets

  • RABBITMQ_HOST: Hostname or IP address of the RabbitMQ broker.
  • RABBITMQ_PORT: Port number of the RabbitMQ broker (e.g. 5672).
  • RABBITMQ_USERNAME: Authentication username for AMQP broker access.
  • RABBITMQ_PASSWORD: Authentication password for AMQP broker access.
  • RABBITMQ_VHOST: Virtual host path (e.g. / or /production).
  • SLACK_WEBHOOK: Slack Incoming Webhook URL for alerting.

Note on OSS Secrets: In open-source (OSS) Kestra deployments without an external secret manager, set secrets via environment variables formatted as SECRET_RABBITMQ_HOST, SECRET_RABBITMQ_PORT, SECRET_RABBITMQ_USERNAME, SECRET_RABBITMQ_PASSWORD, SECRET_RABBITMQ_VHOST, and SECRET_SLACK_WEBHOOK.

Inputs

  • queue_name (STRING, default: "orders.queue"): Name of the target AMQP queue.
  • max_records_probe (INT, default: 50): Maximum messages to sample during probe pass.
  • backlog_threshold (INT, default: 10): Backlog count threshold for triggering alerts.
  • remediation_action (SELECT, default: "ALERT_ONLY", values: ["ALERT_ONLY", "PURGE_EXPIRED"]): Remediation strategy when threshold is breached.
  • dry_run (STRING, default: "true"): Safety flag ensuring remediation logic is executed in dry-run mode unless explicitly disabled.

Outputs

  • Sampled message count: {{ outputs.probe_queue.count }}
  • Internal payload URI: {{ outputs.probe_queue.uri }}

Links

Pitfalls

  • Port Conflicts: Ensure host port 5672 or 15672 does not conflict with existing local database or broker containers.
  • Virtual Host Scoping: AMQP queues are scoped to specific virtual hosts. Verify RABBITMQ_VHOST matches your queue setup.
  • Credential Permissions: The configured user must have read and consume permissions on the specified queue.

Local Container Setup

To start a local RabbitMQ broker container for testing, execute:

docker run -d --name kestra-rabbitmq -p 5673:5672 -p 15673:15672 -e RABBITMQ_DEFAULT_USER=guest -e RABBITMQ_DEFAULT_PASS=guest rabbitmq:3-management

If Kestra is running inside a Docker network, connect the broker container to Kestra's network:

docker network connect YOUR_KESTRA_NETWORK kestra-rabbitmq

(Run docker network ls to verify your active Kestra network name).

See How

New to Kestra?

Use blueprints to kickstart your first workflows.