Skip to content
Redis CLI

MONITOR, SLOWLOG и отладка задержек

Наблюдение за каждой командой в реальном времени и поиск медленных запросов.

#monitor#slowlog#latency#debug

Code

redis-cli
# MONITOR streams every command executed by the server (ALL clients)
$ redis-cli MONITOR
OK
1748200000.123456 [0 127.0.0.1:54321] "SET" "foo" "bar"
1748200000.234567 [0 127.0.0.1:54322] "GET" "foo"

# SLOWLOG — commands exceeding slowlog-log-slower-than (default 10ms)
127.0.0.1:6379> CONFIG GET slowlog-log-slower-than
127.0.0.1:6379> CONFIG SET slowlog-log-slower-than 5000   # 5ms (microseconds)
127.0.0.1:6379> SLOWLOG GET 10        # last 10 slow entries
127.0.0.1:6379> SLOWLOG RESET

# Latency monitoring (Redis 7+)
127.0.0.1:6379> CONFIG SET latency-monitor-threshold 100   # ms
127.0.0.1:6379> LATENCY HISTORY event
127.0.0.1:6379> LATENCY GRAPH event

# Per-command stats (Redis 7+)
127.0.0.1:6379> INFO commandstats
# cmdstat_get:calls=1234,usec=5678,usec_per_call=4.60,rejected_calls=0,failed_calls=0

# Check what's blocking the server
127.0.0.1:6379> INFO clients
127.0.0.1:6379> CLIENT NO-EVICT on   # protect this client from eviction