Redis monitoring.
Key metrics
- Connected clients.
- Ops/sec.
- Memory used.
- Eviction count.
- Hit/miss ratio.
- Replication lag.
- Latency (p99).
INFO
redis-cli INFO clients
redis-cli INFO memory
redis-cli INFO stats
redis-cli INFO replication
redis-cli INFO commandstats
redis-cli INFO latencystats
SLOWLOG
CONFIG SET slowlog-log-slower-than 10000 # 10ms
SLOWLOG GET 10
SLOWLOG LEN
SLOWLOG RESET
Latency
redis-cli --latency
redis-cli --latency-history -i 5
redis-cli --latency-dist
redis-cli LATENCY DOCTOR
Commandstats
redis-cli INFO commandstats
# cmdstat_set:calls=1234,usec=5678,usec_per_call=4.6
Hot keys (LFU)
CONFIG SET maxmemory-policy allkeys-lfu
redis-cli --hotkeys
Big keys
redis-cli --bigkeys
redis-cli --memkeys
redis-exporter (Prometheus)
docker run -d --name redis-exporter -p 9121:9121 \
-e REDIS_ADDR=redis://redis:6379 \
oliver006/redis_exporter
Exposes metrics at :9121/metrics. Grafana dashboards: 763, 11835.
Useful PromQL
# Hit rate
rate(redis_keyspace_hits_total[5m])
/ (rate(redis_keyspace_hits_total[5m]) + rate(redis_keyspace_misses_total[5m]))
# Evictions
rate(redis_evicted_keys_total[5m])
# Memory
redis_memory_used_bytes / redis_memory_max_bytes
# Replication lag (seconds)
redis_slave_lag
Alerts
redis_up == 0for 1m.evictions/sec > 0for 5m.memory_used / maxmemory > 0.9.connected_clients > 10000(or your max).replication_lag > 10.
Healthcheck
redis-cli ping
# PONG
CONFIG
CONFIG GET maxmemory*
CONFIG GET save
CONFIG SET maxmemory 4gb
CONFIG REWRITE # save to file
Latency events
LATENCY LATEST
LATENCY HISTORY event-name
LATENCY RESET
Events: expire-cycle, eviction-cycle, fork, etc.
Persistence latency
Heavy BGSAVE forks → latency spikes. Watch LATENCY LATEST for fork events.
Active expiration
If TTLs heavy: tune hz (default 10/sec).
CONFIG SET hz 100
Higher hz → more CPU spent expiring, less memory.
Hot patterns
# What commands are slow?
SLOWLOG GET 100 | grep -E 'KEYS|SMEMBERS|HGETALL'
# Big sets/lists?
redis-cli --bigkeys
KEYS, SMEMBERS, HGETALL, ZRANGE 0 -1 on huge keys block server.
Capacity planning
- Avg key size × keys = memory.
- Plus 20-30% overhead.
- Plus headroom for fork (snapshot doubles memory briefly).
Reduce memory footprint
- Compact encodings (small structures).
- Shorter keys / values.
- Compression (zstd) for big values.
- Use HyperLogLog instead of sets where applicable.
Common mistakes
- Monitoring CPU but not memory.
- Slowlog disabled → can’t debug.
- No alerts on evictions.
- Forgetting BGSAVE fork costs RAM.
- Single Redis for cache + queue + sessions → noisy neighbor.
Read this next
If you want my Redis monitoring stack, it’s at rajpoot.dev .
Building something AI-, backend-, or data-heavy and want a second pair of eyes? I do consulting and freelance work — see my projects and ways to reach me at rajpoot.dev .