How to Monitor Redis: Commands and Tools Explained
To monitor
Redis, use the built-in INFO command to get server statistics and MONITOR to see real-time commands. You can also use external tools like RedisInsight or Prometheus exporters for detailed monitoring and visualization.Syntax
The main Redis commands for monitoring are:
INFO [section]: Returns server statistics and information. You can specify a section likememory,stats, orclients.MONITOR: Streams every command processed by the Redis server in real-time.CLIENT LIST: Shows connected clients and their details.
redis
INFO INFO memory MONITOR CLIENT LIST
Example
This example shows how to use the INFO command to get memory usage and the MONITOR command to watch commands in real-time.
redis
127.0.0.1:6379> INFO memory # Memory used_memory:1024000 used_memory_human:1000K used_memory_rss:2048000 used_memory_peak:1500000 127.0.0.1:6379> MONITOR +1617181920.123456 [0 127.0.0.1:6379] "SET" "key1" "value1" +1617181921.123789 [0 127.0.0.1:6379] "GET" "key1"
Output
# Memory
used_memory:1024000
used_memory_human:1000K
used_memory_rss:2048000
used_memory_peak:1500000
+1617181920.123456 [0 127.0.0.1:6379] "SET" "key1" "value1"
+1617181921.123789 [0 127.0.0.1:6379] "GET" "key1"
Common Pitfalls
Common mistakes when monitoring Redis include:
- Using
MONITORon a production server without caution, as it can slow down Redis due to the high volume of data streamed. - Not filtering
INFOoutput by sections, which can make it hard to find relevant data. - Ignoring client connections with
CLIENT LIST, which can help identify slow or stuck clients.
redis
Wrong: MONITOR Right: INFO memory CLIENT LIST
Quick Reference
| Command | Purpose |
|---|---|
| INFO [section] | Get server stats and info, e.g., memory, clients, stats |
| MONITOR | Stream all commands processed by Redis in real-time |
| CLIENT LIST | List connected clients and their details |
| SLOWLOG GET | Retrieve slow queries logged by Redis |
| CONFIG GET * | View current Redis configuration settings |
Key Takeaways
Use the INFO command to get detailed Redis server statistics.
Use MONITOR carefully as it streams all commands and can impact performance.
CLIENT LIST helps identify connected clients and troubleshoot issues.
External tools like RedisInsight provide user-friendly monitoring dashboards.
Regularly check slow logs with SLOWLOG GET to find performance bottlenecks.