Redis Well logging system

Source: Internet
Author: User

What is Slowlog

Slow log is a log system used by Redis to record query run times.

Query run time refers to not including IO operations such as client response (talking), sending replies, and simply the time it takes to run a query command.

In addition, slow log is stored in memory and reads and writes fast, so you can use it with confidence without worrying about the speed of Redis due to opening slow log.


Set Slowlog

slow log" is specified by two configuration parameters (config parameter). Able to rewrite redis.conf files or use  CONFIG    and  CONFIG  the command dynamically changes them.

The first option is Slowlog-log-slower-then , which determines how many microseconds (microsecond,1 seconds = 1,000,000 microseconds) to log for queries that run for more than a microsecond.

config slowlog-log-slower-then  ,

and the following command records queries with a full query time greater than 1000 microseconds:

CONFIG slowlog-log-slower-then .

There is also an option to  slowlog-max-len  , it decided slow log  up to how many logs can be saved, slow log itself is a LIFO queue when the queue size exceeds  slowlog-max-len  , the oldest log will be deleted. The latest log is added to slow log, and so on.

The following command allows slow log to save up to 1000 logs:

CONFIG Slowlog-max-len .

use  CONFIG  command to query the current value of two options:

redis> config get slowlog-log-slower-than1) "Slowlog-log-slower-than" 2) "$" redis> CONFIG get Slowlog-max-len1 ) "Slowlog-max-len" 2) "1000"

View Slow Log

To view slow log, be able to use  SLOWLOG  or  slowlog number   command, the former print all slow log, the maximum length depends on  slowlog-max-len the value of the   option, and  slowlog number   Prints only the specified amount of logs.

The most recent logs will be printed first:

Redis> slowlog GET1) 1) (integer)                      # Uniqueness (unique) log identifier   2) (integer) 1324097834              # The run-time point of the recorded command, in UNIX timestamp   3) (integer)                      # query run time. In microseconds   4) 1) "config"                       # Run the command, arranged as an array of      2) "GET"                          # Here's the complete command is CONFIG GET Slowlog-log-slower-than      3) " Slowlog-log-slower-than "2) 1) (integer)   2) (integer) 1324097825   3) (integer) 4   ) 1)" CONFIG "      2 ) "Get"      3) "*" 3) 1) (integer)   2) (integer) 1324097820   3) (integer) 4)   1) "CONFIG"      2) "Get" c19/>3) "Slowlog-log-slower-then" # ...

The unique ID of the log is only reset when the Redis server restarts, which avoids repeated processing of the log (for example, you might want to notify you whenever a new slow query is found).

View the current number of logs

Use the command slowlog to view the current number of logs.

Note the difference between this value and Slower-max-len , which is the number of current logs, and the maximum number of logs that are agreed to log.

redis> slowlog LEN (integer) 14


Empty Log

Use the command slowlog RESET to empty the slow log.

redis> slowlog len (integer) 14redis> slowlog resetokredis> slowlog len (integer) 0


Redis Well logging system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.