Skip to main content

Monitoring

Redis MONITOR — Real-Time Command Inspection

MONITOR streams every command that Redis processes in real time.

What it shows:

  • Every Redis command executed
  • The exact arguments
  • The client issuing it
  • Millisecond timestamps

When to use:

  • Debugging application behavior
  • Detecting unexpected commands
  • Real-time auditing
  • Checking if clients are overloading Redis with unnecessary calls

Caution:

  • MONITOR is slow and CPU-heavy because it logs every operation.
  • Use on development or temporary debugging, not production long-term.

Output Example:

1617043000.123456 [0 127.0.0.1:51726] "SET" "user:1" "Alice"
1617043000.123789 [0 127.0.0.1:51726] "INCR" "visits"
1617043000.124001 [0 127.0.0.1:51726] "LPUSH" "tasks" "task1"
  • Timestamp: 1617043000.123456
  • DB index: [0
  • Client IP: 127.0.0.1
  • Command: "SET", "INCR", "LPUSH"

Redis INFO — Health, Stats, and System Overview

INFO gives a complete snapshot of Redis server status.

It has many sections, including:

SectionShows
serverRedis version, uptime
clientsConnected clients, blocked clients
memoryRAM usage, fragmentation
persistenceRDB/AOF status
statsCommand statistics
replicationMaster/slave info
cpuCPU usage
clusterCluster status
keyspaceKey counts, expirations

Output Example:

# Server
redis_version:7.0.0
uptime_in_seconds:3600

# Clients
connected_clients:42
blocked_clients:1

# Memory
used_memory:25600000
used_memory_peak:30000000
mem_fragmentation_ratio:1.12

# Stats
total_commands_processed:105000
instantaneous_ops_per_sec:1200

# Keyspace
db0:keys=5000,expires=2000,avg_ttl=60000
  • Server section
    • Redis has been running for 1 hour
    • Version: 7.0.0
  • Clients
    • 42 active connections
    • 1 blocked client (likely due to BRPOP or Lua script)
  • Memory
    • used_memory: ~25 MB
    • mem_fragmentation_ratio: 1.12 (healthy)
  • Stats
    • 105,000 commands processed overall
    • Throughput: 1200 ops/sec
  • Keyspace
    • Database db0 has 5,000 keys
    • 2,000 of them have TTLs

Useful options

  • Get only memory info: INFO memory
  • Get only clients info: INFO clients

Redis SLOWLOG — Detect Slow Commands

SLOWLOG records Redis commands that exceed a configured execution time threshold.

Redis is fast, so anything > 1 millisecond is often suspicious.

How to configure Slow Log

  • Set threshold to 1000 microseconds (1ms): CONFIG SET slowlog-log-slower-than 1000
  • Set number of entries stored: CONFIG SET slowlog-max-len 128

Adding a Slow Command

If your application runs:

LRANGE huge_list 0 -1

…on a list with millions of items, it may take >1ms.

Redis will record it in the slow log.

Viewing the Slow Log

SLOWLOG GET 5

Example output:

1) 1) (integer) 15
2) (integer) 1617043400
3) (integer) 1200
4) 1) "LRANGE"
2) "biglist"
3) "0"
4) "-1"
5) "127.0.0.1:51726"
FieldMeaning
(integer) 15Slowlog entry ID
1617043400Unix timestamp
1200Execution time in microseconds (1.2ms)
"LRANGE" "biglist" "0" "-1"Command that was slow
"127.0.0.1:51726"Client that executed it

Redis caught a slow command.

  • Get slowlog length: SLOWLOG LEN
  • Reset slowlog: SLOWLOG RESET

Memory Usage Inspection

CommandPurpose
INFO memoryHigh-level memory stats
MEMORY USAGE keyInspect single key memory
MEMORY STATSDeep memory metrics
MEMORY DOCTORAutomated advice
MEMORY MALLOC-STATSAllocator-level stats
MEMORY PURGEDefrag attempt