INFO
Introduction and Use Case(s)
The INFO command in Redis is used to retrieve various pieces of information and statistics about the server. This includes memory usage, client connections, replication status, CPU usage, and more. It is typically used for monitoring and debugging purposes.
Syntax
INFO [section]
Parameter Explanations
- section: (Optional) Specifies the section of information to return. Possible values include:
server: General information about the Redis server.clients: Client connections information.memory: Memory usage details.persistence: RDB and AOF status.stats: General statistics.replication: Master/slave status.cpu: CPU consumption.commandstats: Command statistics.cluster: Cluster information.keyspace: Database-related statistics.all: All of the above sections.default: Default set of sections.
Return Values
The INFO command returns a bulk string formatted as a series of lines containing property names and their values. Each line is terminated by a newline character (\n). For example:
# Serverredis_version:6.2.5redis_git_sha1:00000000redis_git_dirty:0os:Linux 4.15.0-142-generic x86_64# Clientsconnected_clients:10client_longest_output_list:0client_biggest_input_buf:0blocked_clients:0...
Code Examples
Using the CLI:
dragonfly> INFO server# Serverredis_version:6.2.5redis_git_sha1:00000000redis_git_dirty:0os:Linux 4.15.0-142-generic x86_64...dragonfly> INFO memory# Memoryused_memory:1024000used_memory_human:1000Kused_memory_rss:2048000...dragonfly> INFO all# Serverredis_version:6.2.5...# Clientsconnected_clients:10...# Memoryused_memory:1024000...# Persistenceloading:0...
Best Practices
- Regularly check the
memorysection to monitor and manage your Redis instance’s memory usage. - Use the
statsandcommandstatssections to identify performance bottlenecks or unusual activity. - Automate the collection of
INFOoutputs for continuous monitoring and alerting.
Common Mistakes
- Not specifying a section when only specific information is needed can lead to an overload of data, making it harder to find relevant information.
- Ignoring crucial metrics such as memory usage and replication status, which can lead to undiagnosed issues.
FAQs
What information does the INFO command provide?
The INFO command provides detailed information on different aspects of the Redis server, including server configuration, memory usage, client connections, replication status, and more.
How can I use the INFO command to debug performance issues?
You can use the INFO stats and INFO commandstats commands to get insights into server operations and command execution times, which can help in identifying and addressing performance bottlenecks.
Can I limit the output of the INFO command?
Yes, you can limit the output by specifying a section. For example, INFO memory will only return memory-related statistics.