Keyspace: Database related statisticsIt supports custom return lists:
[root@~]# redis-cli info[root@~]# redis-cli info default[root@~]# redis-cli info all
See http://www.redis.cn/commands/info.html for details
2. MONITOR
MONITOR is a debugging command that returns every command processed by the server. It helps us understand what operations have taken place on the database. There are three methods:
[root@~]# redis-cli monitorOK1417532512.619715 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623624"[root@~]# telnet 127.0.0.1 6379Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is '^]'.monitor+OK+1417532567.733458 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623708"+1417532568.735936 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623708"quit+OKConnection closed by foreign host.[root@~]# redis-cli 127.0.0.1:6379> monitorOK1417532590.785487 [0 127.0.0.1:55043] "REPLCONF" "ACK" "6623736"
Because the MONITOR command returns all the commands processed by the server, it consumes some performance. The test results using the official stress testing tool are as follows:
Benchmark's test results without running the MONITOR command:
[root@~/software/redis-2.8.17]# src/redis-benchmark -c 10 -n 100000 -qPING_INLINE: 51020.41 requests per secondPING_BULK: 50607.29 requests per secondSET: 37257.82 requests per secondGET: 49800.80 requests per secondINCR: 38699.69 requests per secondLPUSH: 38910.51 requests per secondLPOP: 39277.30 requests per secondSADD: 54614.96 requests per secondSPOP: 51948.05 requests per secondLPUSH (needed to benchmark LRANGE): 38819.88 requests per secondLRANGE_100 (first 100 elements): 20112.63 requests per secondLRANGE_300 (first 300 elements): 9025.27 requests per secondLRANGE_500 (first 450 elements): 6836.67 requests per secondLRANGE_600 (first 600 elements): 5406.28 requests per secondMSET (10 keys): 19394.88 requests per second
When running the MONITOR command, benchmark Test Result: (redis-cli monitor>/dev/null ):
[root@~/software/redis-2.8.17]# src/redis-benchmark -c 10 -n 100000 -qPING_INLINE: 42211.91 requests per secondPING_BULK: 42936.88 requests per secondSET: 26143.79 requests per secondGET: 33990.48 requests per secondINCR: 26553.37 requests per secondLPUSH: 27337.34 requests per secondLPOP: 27225.70 requests per secondSADD: 30459.95 requests per secondSPOP: 39494.47 requests per secondLPUSH (needed to benchmark LRANGE): 26315.79 requests per secondLRANGE_100 (first 100 elements): 22055.58 requests per secondLRANGE_300 (first 300 elements): 8104.38 requests per secondLRANGE_500 (first 450 elements): 6371.05 requests per secondLRANGE_600 (first 600 elements): 5031.95 requests per secondMSET (10 keys): 14861.05 requests per second
We can see that all the indicators have declined.
See http://www.redis.cn/commands/monitor.html for details
3. SLOWLOG
You can use SLOWLOG to read slow query logs.
You can use slowlog len to obtain the length of the current slow log.
[root@~/software/redis-2.8.17]# redis-cli 127.0.0.1:6379> slowlog len(integer) 28
You can use slowlog get to obtain all slow logs.
127.0.0.1:6379> slowlog get 1) 1) (integer) 27 2) (integer) 1417531320 3) (integer) 24623 4) 1) "info"
The indicators are as follows:
- A unique progressive identifier for every slow log entry.
- The unix timestamp at which the logged command was processed.
- The amount of time needed for its execution, in microseconds (Note: microseconds is translated into microseconds instead of milliseconds ).
- The array composing the arguments of the command.
You can use slowlog get n to obtain the last N slow logs.
127.0.0.1:6379> slowlog get 21) 1) (integer) 27 2) (integer) 1417531320 3) (integer) 24623 4) 1) "info"2) 1) (integer) 26 2) (integer) 1417528379 3) (integer) 21363 4) 1) "get" 2) "user:score"
Use the slowlog reset command to RESET slow logs. Once executed, all previous slow logs will be lost.
127.0.0.1:6379> slowlog reset