How to see set/get/ in redis log
Asked Answered
P

3

26

I need to see what redis gets/sets in the redis log.
I tried to set the redis log level to debug and verbose. This does not show me anything when I set a value.

Propman answered 5/2, 2013 at 17:14 Comment(0)
R
59

Unless it's important that you get in the log, in which case I don't think I can help you, you should be able to use the MONITOR command:

MONITOR is a debugging command that streams back every command processed by the Redis server. It can help in understanding what is happening to the database. This command can both be used via redis-cli and via telnet.

You could do something like:

redis-cli monitor | grep -E ' "(g|s)et" '

Note that there is a performance cost, though (it's mentioned in the linked docs as roughly 50%).

Pipe it to a file:

redis-cli monitor | grep -E ' "(g|s)et" ' > redis_get_set.log
Repugnance answered 6/2, 2013 at 11:40 Comment(5)
could you pipe it to a file somehow?Oaf
yes (this was asked 4 years ago) I am piping the output into a file (so I can analyze it later) and that into a colorize script so I get a nice colored logs on my console. We use this in development, not prod.Propman
Thanks for this! When piping to a file, redis-cli monitor > redis_get_set.log works for me but redis-cli monitor | grep -E ' "(g|s)et" ' > redis_get_set.log results in a file that remains empty. Any idea why that would be ? (Ubuntu 16.04)Astound
@PaulY what happens when u just do redis-cli monitor | grep -E ' "(g|s)et" 'Propman
@PaulY I had the same problem because grep was case sensitive by default for me. Try redis-cli monitor | grep -E ' "(G|S)ET" ' . For my use case, I also wanted multi get and truncate oversized entries so I used redis-cli monitor | grep -E ' "M?(G|S)ET" ' | cut -b 1-240 .Blackboard
F
7

I used redis-cli monitor > redis.log and that works just fine for me, better than console.

Farming answered 3/11, 2017 at 14:6 Comment(0)
H
1

RedisInsight is a free Redis GUI which contains a profiler.

(under the hood it just runs redis-cli monitor)

It also has options to save the logs to a file if desired.

RedisInsight

Horvitz answered 21/2, 2023 at 18:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.