Webhook icon
Schedule icon
WorkingDirectory icon
Commands icon
Docker icon
Script icon
If icon
SlackIncomingWebhook icon
Fail icon
Switch icon
Log icon

Gate on Stuck IBM MQ Queues and Dead Letter Growth

Score IBM MQ queue depth and oldest message age against a stall SLA, fail stuck queues with Slack alerts, and gate on dead letter queue accumulation.

Categories
Infrastructure

How it works

  1. on_queue_status (io.kestra.plugin.core.trigger.Webhook, keyed with the IBM_MQ_STATUS_WEBHOOK_KEY secret) receives the queue status snapshot from your MQ exporter. hourly_queue_net (io.kestra.plugin.core.trigger.Schedule, cron 0 * * * *) is the safety net and ships disabled: true until an operator turns it on.
  2. queue_workspace (io.kestra.plugin.core.flow.WorkingDirectory) opens one shared directory so the staged fixture and the scorer read the same file, a scratch directory outside a WorkingDirectory is purged between tasks and would break that hand-off.
  3. write_queue_status_fixture (io.kestra.plugin.scripts.shell.Commands on the io.kestra.plugin.scripts.runner.docker.Docker runner, image alpine:3.20) writes queue_status.json with a heredoc. The fixture holds a request queue at depth 1450 whose oldest message is 95 minutes old, a quiet reply queue and an orders queue sitting at ninety percent of its depth capacity, the shape a stalled QManager produces. entryPoint: [] clears the image entrypoint so the shell script runs instead of the default command.
  4. score_queues (io.kestra.plugin.scripts.python.Script on python:3.12-slim) prefers the posted webhook body when present and falls back to the staged file. A queue with depth above zero whose oldest message age meets stale_age_minutes is stuck, a queue at eighty percent of its depth capacity or carrying dlq_threshold dead letters on its own is degraded, and the overall verdict reads stuck when any queue stalled, degraded when only pressure signals fired, healthy when the QManager is quiet and unknown when the snapshot could not be parsed. The verdict, the stuck queue list, the deepest depth, the dead letter total and the oldest stuck age are printed as a single ::{"outputs": ...}:: line.
  5. dlq_gate (io.kestra.plugin.core.flow.If) runs first on the dead letter total. A pile at or past dlq_threshold reaches alert_dlq_accumulation (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) and then fail_dlq (io.kestra.plugin.core.execution.Fail). Every other run reaches route_stall (io.kestra.plugin.core.flow.Switch), whose map shaped cases alert and fail on a stuck queue through alert_stuck and fail_stuck, record a degraded QManager on log_degraded, record a quiet one on log_healthy and fall through to log_unknown_status when the snapshot could not be parsed.
  6. The flow level errors handler (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) reports any failure with the execution id, because a dead scorer looks exactly like a healthy queue manager.

What you get

  • A three way stall verdict, stuck, degraded or healthy, that separates a stopped consumer channel from a merely busy one.
  • Two hard gates, a dead letter total at or past dlq_threshold and any queue past the staleness SLA, both fail the execution and alert Slack with the exact counters.
  • Channel context that names the stuck queues, the deepest depth and the oldest message age instead of a bare page.
  • verdict, stuck_queues, stuck_count, max_depth, dlq_total and oldest_stuck_age_minutes as typed outputs for delivery SLA dashboards.
  • A disabled hourly schedule as a second net once the webhook path is trusted.

Who it's for

  • Messaging platform teams that own IBM MQ queue managers and need stalled queues named before consumers miss delivery SLAs.
  • SREs on call for dead letter growth who want the drain list and the deepest queue in the page itself.
  • Integration engineers wiring queue health into a release or batch window gate instead of watching channels by eye.

Why orchestrate this with Kestra

MQ depth and dead letter counters live in the QManager, but nothing correlates a stale oldest-message age with a growing DLQ and stops the line when both fire. Kestra gives the check a keyed webhook for on demand scoring, a disabled schedule as the safety net, a fixture driven scorer whose stall rules live in version control, a dead letter gate that fails fast, and a map shaped Switch that routes each stall verdict into Slack and execution failure from one declarative file. A cron script with a queue manager client gives you none of the history, the branching or the gateable outputs.

Prerequisites

  • A worker with Docker access, the fixture runs in alpine:3.20 and the scorer in python:3.12-slim.
  • An MQ exporter or monitoring relay that can POST queue status JSON with per queue depth, oldest message age and dead letter count to the webhook, or rely on the staged fixture for trial runs.
  • A Slack incoming webhook for the stall alerts and for failure alerts.

Secrets

  • IBM_MQ_STATUS_WEBHOOK_KEY: key segment guarding the queue status webhook URL, anyone holding it can trigger a scoring run.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used by the DLQ alert, the stuck alert and the errors block.

Quick start

  1. Add the two secrets to your Kestra namespace.
  2. Run the flow once with the default inputs. The staged fixture carries a 95 minute old message on APP.REQUEST.Q and 15 dead letters in total, so the DLQ gate passes, the Switch routes stuck, Slack names APP.REQUEST.Q and the execution fails.
  3. Re-run with stale_age_minutes at 120 to watch the same fixture route degraded, because the request queue recovers while the orders queue still sits at depth capacity.
  4. Re-run with dlq_threshold at 10 to watch the DLQ gate fire first with the full dead letter total before the Switch is ever reached.
  5. Point your exporter at /api/v1/{tenant}/executions/webhook/{namespace}/ibm-mq-queue-stuck-and-dlq-gate/{IBM_MQ_STATUS_WEBHOOK_KEY} and enable hourly_queue_net once the path is trusted.

How to extend

  • Score each queue manager separately by fanning out with io.kestra.plugin.core.flow.ForEachItem over a subflow that grades one QManager snapshot each.
  • Persist every scored snapshot with io.kestra.plugin.jdbc.postgresql.Queries to trend depth and dead letter growth per queue over the week.
  • Add a per queue override map inside score_queues so critical queues get a shorter staleness SLA than bulk archives.
  • Swap the Slack alerts for a PagerDuty integration when a stuck queue should page the messaging on-call instead of posting to a channel.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.