viewof monQueueDepth = Inputs.range([0, 100000], {
value: 8000,
step: 500,
label: "Current queue depth:",
width: 400
})
viewof monQueueCapacity = Inputs.range([10000, 200000], {
value: 50000,
step: 5000,
label: "Queue max capacity:",
width: 400
})
viewof monConsumerCount = Inputs.range([0, 20], {
value: 3,
step: 1,
label: "Active consumers:",
width: 400
})
viewof monPublishRate = Inputs.range([0, 10000], {
value: 2000,
step: 100,
label: "Publish rate (msg/sec):",
width: 400
})
viewof monConsumeRate = Inputs.range([0, 10000], {
value: 1800,
step: 100,
label: "Consume rate (msg/sec):",
width: 400
})
viewof monUnacked = Inputs.range([0, 10000], {
value: 200,
step: 50,
label: "Unacknowledged messages:",
width: 400
})Try It: AMQP Health Monitor Dashboard
Try It: AMQP Health Monitor Dashboard
animation
amqp
protocols
messaging
Try Change active consumers to 0.
Observe Watch Consumers and Broker Health Dashboard after Play broker.
Explain Explain why 0 active consumers makes Consumers critical.
Technical boundaries. Time to full assumes the current net rate continues. Backlog Rate uses the difference between publish and consume rates, and publish rate status uses publish rate multiplied by 1.2.
NoteTry It: AMQP Health Monitor Dashboard
Simulate a production AMQP broker by adjusting queue depth, consumer count, and message rates. The dashboard applies the warning and critical thresholds from the monitoring table above and shows which alerts would fire.
monColors = ({
navy: "#2C3E50",
teal: "#16A085",
orange: "#E67E22",
blue: "#3498DB",
gray: "#7F8C8D",
purple: "#9B59B6",
red: "#E74C3C"
})
monMetrics = {
const depthPct = (monQueueDepth / monQueueCapacity) * 100;
const depthStatus = depthPct > 80 ? "critical" : depthPct > 50 ? "warning" : "ok";
const consumerStatus = monConsumerCount === 0 ? "critical" : monConsumerCount < 2 ? "warning" : "ok";
const ratePct = monPublishRate > 0 ? (monPublishRate / (monPublishRate * 1.2)) * 100 : 0;
const rateStatus = ratePct > 95 ? "critical" : ratePct > 80 ? "warning" : "ok";
const unackedStatus = monUnacked > 5000 ? "critical" : monUnacked > 1000 ? "warning" : "ok";
const netRate = monPublishRate - monConsumeRate;
const timeToFull = netRate > 0 ? ((monQueueCapacity - monQueueDepth) / netRate) : Infinity;
const dlRate = monPublishRate > 0 ? Math.max(0, (monPublishRate - monConsumeRate) / monPublishRate * 100) : 0;
const dlStatus = dlRate > 5 ? "critical" : dlRate > 1 ? "warning" : "ok";
const overallAlerts = [depthStatus, consumerStatus, rateStatus, unackedStatus, dlStatus];
const overallStatus = overallAlerts.includes("critical") ? "critical" : overallAlerts.includes("warning") ? "warning" : "ok";
return {depthPct, depthStatus, consumerStatus, rateStatus, unackedStatus, netRate, timeToFull, dlRate, dlStatus, overallStatus};
}
statusColor = (status) => status === "critical" ? monColors.red : status === "warning" ? monColors.orange : monColors.teal
statusLabel = (status) => status === "critical" ? "CRITICAL" : status === "warning" ? "WARNING" : "OK"
html`
<div style="background: linear-gradient(135deg, #1a1a2e 0%, ${monColors.navy} 100%); padding: 25px; border-radius: 12px; color: white; margin: 10px 0; font-family: Arial, sans-serif;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 2px solid rgba(255,255,255,0.2); padding-bottom: 12px;">
<h3 style="margin: 0; color: white;">Broker Health Dashboard</h3>
<div style="background: ${statusColor(monMetrics.overallStatus)}; padding: 6px 16px; border-radius: 20px; font-weight: bold; font-size: 0.85em;">
${statusLabel(monMetrics.overallStatus)}
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px;">
<div style="background: rgba(255,255,255,0.08); padding: 14px; border-radius: 8px; border-left: 4px solid ${statusColor(monMetrics.depthStatus)};">
<div style="font-size: 0.78em; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px;">Queue Depth</div>
<div style="font-size: 1.6em; font-weight: bold; margin: 4px 0;">${monMetrics.depthPct.toFixed(1)}%</div>
<div style="background: rgba(255,255,255,0.15); border-radius: 4px; height: 6px; overflow: hidden;">
<div style="background: ${statusColor(monMetrics.depthStatus)}; height: 100%; width: ${Math.min(100, monMetrics.depthPct)}%; border-radius: 4px; transition: width 0.3s;"></div>
</div>
<div style="font-size: 0.75em; opacity: 0.65; margin-top: 4px;">${monQueueDepth.toLocaleString()} / ${monQueueCapacity.toLocaleString()}</div>
</div>
<div style="background: rgba(255,255,255,0.08); padding: 14px; border-radius: 8px; border-left: 4px solid ${statusColor(monMetrics.consumerStatus)};">
<div style="font-size: 0.78em; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px;">Consumers</div>
<div style="font-size: 1.6em; font-weight: bold; margin: 4px 0;">${monConsumerCount}</div>
<div style="font-size: 0.75em; opacity: 0.65;">${statusLabel(monMetrics.consumerStatus)} ${monMetrics.consumerStatus === 'critical' ? '(no consumers!)' : monMetrics.consumerStatus === 'warning' ? '(< 2 active)' : '(healthy)'}</div>
</div>
<div style="background: rgba(255,255,255,0.08); padding: 14px; border-radius: 8px; border-left: 4px solid ${statusColor(monMetrics.unackedStatus)};">
<div style="font-size: 0.78em; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px;">Unacked</div>
<div style="font-size: 1.6em; font-weight: bold; margin: 4px 0;">${monUnacked.toLocaleString()}</div>
<div style="font-size: 0.75em; opacity: 0.65;">Threshold: 1K warn / 5K crit</div>
</div>
<div style="background: rgba(255,255,255,0.08); padding: 14px; border-radius: 8px; border-left: 4px solid ${monMetrics.netRate > 0 ? monColors.red : monColors.teal};">
<div style="font-size: 0.78em; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px;">Net Rate</div>
<div style="font-size: 1.6em; font-weight: bold; margin: 4px 0;">${monMetrics.netRate > 0 ? '+' : ''}${monMetrics.netRate} msg/s</div>
<div style="font-size: 0.75em; opacity: 0.65;">${monMetrics.netRate > 0 ? `Queue fills in ${monMetrics.timeToFull === Infinity ? '--' : monMetrics.timeToFull.toFixed(0) + 's'}` : 'Queue draining (stable)'}</div>
</div>
<div style="background: rgba(255,255,255,0.08); padding: 14px; border-radius: 8px; border-left: 4px solid ${statusColor(monMetrics.dlStatus)};">
<div style="font-size: 0.78em; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px;">Backlog Rate</div>
<div style="font-size: 1.6em; font-weight: bold; margin: 4px 0;">${monMetrics.dlRate.toFixed(1)}%</div>
<div style="font-size: 0.75em; opacity: 0.65;">Threshold: 1% warn / 5% crit</div>
</div>
</div>
<div style="margin-top: 16px; padding: 12px; background: rgba(255,255,255,0.06); border-radius: 8px; font-size: 0.85em;">
<strong>Alert Summary:</strong>
${monMetrics.overallStatus === 'ok'
? 'All metrics within healthy thresholds. No action required.'
: html`<ul style="margin: 6px 0 0 0; padding-left: 18px;">
${monMetrics.depthStatus !== 'ok' ? html`<li>Queue depth at ${monMetrics.depthPct.toFixed(1)}% -- ${monMetrics.depthStatus === 'critical' ? 'scale consumers immediately' : 'monitor closely'}</li>` : ''}
${monMetrics.consumerStatus !== 'ok' ? html`<li>Consumer count is ${monConsumerCount} -- ${monMetrics.consumerStatus === 'critical' ? 'alert on-call, zero consumers!' : 'add redundant consumer'}</li>` : ''}
${monMetrics.unackedStatus !== 'ok' ? html`<li>Unacked messages at ${monUnacked.toLocaleString()} -- ${monMetrics.unackedStatus === 'critical' ? 'check consumer health' : 'investigate slow consumers'}</li>` : ''}
${monMetrics.netRate > 0 ? html`<li>Queue growing at ${monMetrics.netRate} msg/s -- fills in ${monMetrics.timeToFull === Infinity ? '--' : monMetrics.timeToFull.toFixed(0) + ' seconds'}</li>` : ''}
</ul>`}
</div>
</div>
`