Redis monitoring commands

Slow query

The execution time here does not include IO operations, such as communicating with the client, sending replies, etc., but only the time required to actually execute the command (this is the only stage where the thread is blocked and cannot process other requests at the same time) .
You can configure the slow query log with two parameters:

  1. _slowlog-log-slower-than_ tells how many microseconds the execution time of the Redis command will be recorded. Please note that using a negative number will turn off the slow query log, and a value of 0 will force every command to be logged.
  2. _slowlog-max-len_ is the length of the slow query log. The minimum value is 0. When a new command is recorded, and the slow query log has reached its maximum length, the oldest command will be removed from the queue of recorded commands to make room.
    Configuration can be done by editing the redis.conf file, or by using the CONFIG GET and CONFIG SET commands while the server is running.

To read the slow query log, use the SLOWLOG GET command, which returns every entry in the slow query log. It is possible to return only the most recent N entries by passing an additional parameter to the command (for example: SLOWLOG GET 10).
Each entry consists of four fields:

  • The unique incremental identifier for each slow query entry.
  • Process the unix timestamp of the recording command.
  • The total time required for command execution, in microseconds.
  • The array of parameters that make up the command.
redis 127.0.0.1:6379> slowlog get 2
1) 1) (integer) 14   # 慢查询条目的唯一的递增标识符
   2) (integer) 1309448221  # 处理命令的unix时间戳
   3) (integer) 15 # 命令执行所需的总时间,以微秒为单位
   4) 1) "ping"  # 组成该命令的参数的数组
2) 1) (integer) 13
   2) (integer) 1309448128
   3) (integer) 30
   4) 1) "slowlog"
      2) "get"
      3) "100"

infoGet service details

The INFO command returns various information and statistics about the Redis server in a format that is easy to understand and read.

By giving the optional parameter section, you can make the command return only a certain part of the information:

  • server: General information of the Redis server
  • clients: the connection part of the client
  • memory: memory consumption related information
  • persistence: RDB and AOF related information
  • stats: general statistics
  • replication: master / slave replication information
  • cpu: Statistics CPU consumption
  • commandstats: Redis command statistics
  • cluster: Redis cluster information
  • keyspace: database related statistics

It can also take the following values:

  • all: return all information
  • default: value returns the information of the default setting

If no parameters are used, the default is default.
Examples:

redis> INFO
# Server
redis_version:999.999.999
redis_git_sha1:ceaf58df
redis_git_dirty:1
redis_build_id:a5eeeb464ee54856
redis_mode:standalone
os:Linux 4.1.5-x86_64-linode61 x86_64
arch_bits:32
multiplexing_api:epoll
gcc_version:4.4.1
process_id:21798
run_id:2569bb7433bfe013c2627edf62d9bf21eaf8a010
tcp_port:6379
uptime_in_seconds:3348607
uptime_in_days:38
hz:10
lru_clock:491100
config_file:/etc/redis/6379.conf

# Clients
connected_clients:8
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:7556576
used_memory_human:7.21M
used_memory_rss:10555392
used_memory_rss_human:10.07M
used_memory_peak:8370272
used_memory_peak_human:7.98M
total_system_memory:4142215168
total_system_memory_human:3.86G
used_memory_lua:24576
used_memory_lua_human:24.00K
maxmemory:3221225472
maxmemory_human:3.00G
maxmemory_policy:unknown
mem_fragmentation_ratio:1.40
mem_allocator:jemalloc-3.6.0
lazyfree_pending_objects:0

# Persistence
loading:0
rdb_changes_since_last_save:521
rdb_bgsave_in_progress:0
rdb_last_save_time:1460108780
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:1058
total_commands_processed:20227305
instantaneous_ops_per_sec:0
total_net_input_bytes:1528543656
total_net_output_bytes:2155353808
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:22616
evicted_keys:0
keyspace_hits:5059386
keyspace_misses:1405484
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:645
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:2776.27
used_cpu_user:2449.24
used_cpu_sys_children:59.10
used_cpu_user_children:1237.45

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=3790,expires=2,avg_ttl=95446662632
redis> 

See the meaning of each parameter: http://www.redis.cn/commands/info.html

reference

http://www.redis.cn/commands/info.html
http://www.redis.cn/commands/slowlog.html

Guess you like

Origin www.cnblogs.com/cnwenf/p/12760273.html