Alert on Redis replication lag
Redis slave is behind master — read-after-write returns stale data. No native alert, you need an external one.
Recipe
#!/usr/bin/env bash
# Run on the standby Redis host. Exposes `200 ok` / `500 lag` over HTTP
# so an external monitor can poll it.
LAG_LIMIT=${1:-10} # seconds
HOST=${REDIS_HOST:-127.0.0.1}
PORT=${REDIS_PORT:-6379}
LAG=$(redis-cli -h "$HOST" -p "$PORT" INFO replication \
| awk -F: '/master_last_io_seconds_ago/ {gsub(/\r/,""); print $2}')
if [ -z "$LAG" ] || [ "$LAG" -gt "$LAG_LIMIT" ]; then
printf 'HTTP/1.1 500 OK\r\nContent-Type: text/plain\r\n\r\nlag=%s\n' "$LAG"
else
printf 'HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nok lag=%s\n' "$LAG"
fi
Same thing in Enterno.io
Expose the script as /redis-replication-status via nginx + fcgiwrap (or a systemd socket) and point an Enterno HTTP monitor at it. Alert rule "not 200" is enough.
Related recipes
Detect the moment a replica falls behind the primary by more than 10 seconds.
One public DNS resolver (1.1.1.1, 8.8.8.8) degrades for a region. Your site "is up" but half the users see "server not found" — the uptime monitor stays silent.
Ensure your site returns 2xx every minute, alert to Slack/Telegram on failure.