How to Use INFO Command in Redis: Syntax and Examples
Use the
INFO command in Redis to get detailed information and statistics about the server and its databases. You can run INFO alone to get all info or specify a section like INFO memory to get specific details.Syntax
The INFO command can be used in two ways:
INFO: Returns all information sections.INFO <section>: Returns information only about the specified section.
Common sections include server, clients, memory, persistence, stats, replication, cpu, cluster, and keyspace.
redis
INFO INFO memory
Example
This example shows how to get all server information and then only memory-related info using the INFO command.
redis
127.0.0.1:6379> INFO # Server redis_version:7.0.11 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:... # Clients connected_clients:1 # Memory used_memory:1024000 used_memory_human:1000K # Keyspace db0:keys=5,expires=0,avg_ttl=0 127.0.0.1:6379> INFO memory # Memory used_memory:1024000 used_memory_human:1000K used_memory_rss:2048000 used_memory_peak:1536000 used_memory_peak_human:1.5M
Output
# Server
redis_version:7.0.11
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:...
# Clients
connected_clients:1
# Memory
used_memory:1024000
used_memory_human:1000K
# Keyspace
db0:keys=5,expires=0,avg_ttl=0
# Memory
used_memory:1024000
used_memory_human:1000K
used_memory_rss:2048000
used_memory_peak:1536000
used_memory_peak_human:1.5M
Common Pitfalls
Some common mistakes when using INFO include:
- Expecting JSON or structured output:
INFOreturns plain text with key-value pairs, not JSON. - Using incorrect section names: Section names are case-insensitive but must be valid (e.g.,
memory, notmem). - Running
INFOon a busy server may cause slight performance impact because it collects many stats.
redis
Wrong: INFO mem Right: INFO memory
Quick Reference
| Command | Description |
|---|---|
| INFO | Returns all server and database information |
| INFO server | Returns server-related info like Redis version |
| INFO clients | Shows connected clients info |
| INFO memory | Shows memory usage statistics |
| INFO persistence | Shows RDB and AOF persistence info |
| INFO stats | General statistics like commands processed |
| INFO replication | Replication and role info |
| INFO cpu | CPU usage statistics |
| INFO keyspace | Database keys and expiration info |
Key Takeaways
Use
INFO to get detailed Redis server and database stats.Specify a section name with
INFO to get focused information.Section names are case-insensitive but must be valid to avoid errors.
The output is plain text, not JSON, so parse accordingly.
Running
INFO on busy servers may slightly affect performance.