Skip to main content

Command Palette

Search for a command to run...

Enable Redis logs

Updated
2 min read
Enable Redis logs
N

Working as a Principal Software Engineer. I have experience working on Java, Spring Boot, Go, Android Framework, OS, Shell scripting, and AWS. Experienced in creating scalable and highly available systems.

To check commands running in redis

To log all Redis commands that are being executed by Redis clients, including redis-cli, you can enable Redis slow log.

Redis slow log is a feature that logs Redis commands that exceed a specified execution time threshold. By default, Redis slow log is disabled. To enable Redis slow log, you need to set the slowlog-log-slower-than configuration parameter to a positive value in your Redis configuration file, or by using the CONFIG SET command.

For example, to enable Redis slow log for commands that take longer than 1000 microseconds (1 millisecond) to execute, you can add the following line to your Redis configuration file:

127.0.0.1:6379> CONFIG SET slowlog-log-slower-than 1000
OK

After enabling Redis slow log, Redis will log all commands that exceed the specified execution time threshold, along with their execution time and the client that executed them. You can view the Redis slow log entries by using the SLOWLOG GET command.

To view the Redis slow log in real-time, you can use the redis-cli tool with the MONITOR command. The MONITOR command displays all Redis commands that are being executed by Redis clients, including redis-cli. To enable MONITOR mode, simply run the following command in redis-cli:

redis-cli monitor

This will display all Redis commands as they are executed, along with their arguments and the client that executed them.

Note that enabling Redis slow log and MONITOR mode can have a performance impact on Redis, especially if your Redis instance is handling a large number of commands. Therefore, it's recommended to use these features only for debugging and troubleshooting purposes, and to disable them when they're not needed.

If you liked this blog, you can follow me on twitter, and learn something new with me.