Difficulty: Intermediate
What is the MONITOR command in Redis, when would you use it, and why is it risky in production?
MONITOR streams every command the Redis server processes, in real time, to the client that ran it. It is a debugging tool for answering "what is my application actually sending to Redis?", for example spotting an unexpected KEYS * or a loop that fires thousands of GETs per request. It has a real performance cost, so in production you run it only briefly, or reach for lighter tools like SLOWLOG and INFO commandstats.
Each line has a Unix timestamp with microseconds, the database number and client address, then the command and its arguments:
1760258412.551203 [0 10.0.3.14:52144] "HGETALL" "cart:42"
Commands run inside a Lua script show lua in place of the client address. For security, administrative commands are not logged and sensitive arguments, such as the password in AUTH, are redacted.
MONITOR client can noticeably reduce throughput, and running several makes it worse.head, to catch a hot key or a chatty code path during an incident.KEYS call.| Need | Tool |
|---|---|
| Find slow commands | SLOWLOG GET 10 (threshold slowlog-log-slower-than, default 10000 microseconds) |
| Which commands dominate CPU | INFO commandstats |
| Latency spikes and their causes | LATENCY DOCTOR, LATENCY LATEST |
| Who is connected and what they last ran | CLIENT LIST |
| Live ops per second overview | redis-cli --stat |
| Biggest or hottest keys | redis-cli --bigkeys, --memkeys, --hotkeys (LFU only) |
| Ongoing tracing | Client-side instrumentation such as OpenTelemetry spans |
timeout 5 redis-cli MONITOR or redis-cli MONITOR | head -n 500.grep, since the server cannot filter for you.# Capture at most 5 seconds of traffic
timeout 5 redis-cli MONITOR > monitor.log
# Most frequent commands in the sample
awk '{print $4}' monitor.log | sort | uniq -c | sort -nr | head
# Most frequently accessed keys
awk '{print $5}' monitor.log | sort | uniq -c | sort -nr | head
# Lighter alternatives
redis-cli SLOWLOG GET 5
redis-cli INFO commandstats | head
redis-cli --stat
In this sample one key is read tens of thousands of times in 5 seconds, a sign it should be cached in the application process instead.
MONITOR, SLOWLOG, Debugging, Command Tracing, Production Safety