Redis Streams — alert when XPENDING grows
A Redis Streams consumer lags — it reads messages but never XACKs them (the worker hangs between read and ack). XLEN does not grow, XPENDING does.
Recipe
#!/usr/bin/env bash
# /etc/cron.d/redis-streams
# */2 * * * * root /opt/redis-streams.sh
HOST=${REDIS_HOST:-127.0.0.1}
STREAM=${STREAM}
GROUP=${CONSUMER_GROUP}
THRESH=${THRESH:-100} # alert above pending count
PENDING=$(redis-cli -h "$HOST" XPENDING "$STREAM" "$GROUP" | head -1)
if [ "${PENDING:-0}" -gt "$THRESH" ]; then
curl -fsS "$HEARTBEAT_URL" --data "pending=$PENDING,stream=$STREAM,group=$GROUP"
exit 2
fi
echo "OK (pending=$PENDING)"
Same thing in Enterno.io
Wire to an Enterno heartbeat — a couple of minutes without ack from the consumer is already a trend, you spot it before pipeline-wide degradation.
Related recipes
Redis slave is behind master — read-after-write returns stale data. No native alert, you need an external one.
Sentinel performed a failover at 3 AM and nobody noticed. We want a notification the moment the master flips, not next week.
Redis is up but `mem_fragmentation_ratio > 1.5` — real RAM use is much bigger than what `used_memory_human` reports. OOM will hit suddenly.