Redis

洞悉Redis技术内幕:缓存,数据结构,并发,集群与算法
帅旋
关注
充电
IT宅站长,技术博主,共享单车手,全网id:arthinking。

Redis常用监控工具

发布于 2021-06-16 | 更新于 2024-03-03

info命令

最常用的就是Redis内置的info命令了。通过info命令,可以打印有关Redis服务器的指标和信息。

输出的信息分为以下10组:server, client, memory, persistence, stats, replication, cpu, commandstats, cluster, keyspace。

启用慢日志[1]

Redis 慢日志是一种记录超过指定执行时间的查询的系统。执行时间不包括与客户端通信、发送回复等 I/O 操作,而只是实际执行命令所需的时间(这是命令执行的唯一阶段,该阶段Redis线程会被阻塞)。

可以通过编辑redis.conf或在服务器运行时使用 CONFIG GET 和 CONFIG SET 命令来完成配置。

如,可以通过以下命令设置慢日志监控参数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 命令执行超过5毫秒则记录为慢日志,注意,设置为负数会禁用慢日志,设置为0会强制记录每个命令
127.0.0.1:6379> CONFIG SET slowlog-log-slower-than 5000
OK
# 只保留最近1000条慢日志
127.0.0.1:6379> CONFIG SET slowlog-max-len 1000
OK
# 查看慢日志
127.0.0.1:6379> slowlog get 2
1) 1) (integer) 14
2) (integer) 1309448221
3) (integer) 15
4) 1) "ping"
2) 1) (integer) 13
2) (integer) 1309448128
3) (integer) 30
4) 1) "slowlog"
2) "get"
3) "100"

redis-stat

Redis-stat是一个Redis指标可视化监控工具,采用ruby开发,基于Redis的info命令来统计,不影响Redis性能。

https://github.com/junegunn/redis-stat

RedisLive

RedisLive是一个采用Python开发的Redis可视化及查询分析工具。

https://github.com/nkrode/RedisLive

redis_exporter

如果您正在使用Prometheus,则可以使用这个工具。redis_exporter是为Prometheus提供的Redis指标监控exporter,支持Redis 2.x, 3.x, 4.x, 5.x, and 6.x。

https://github.com/oliver006/redis_exporter

redmon

简单的基于 sinatra 的 redis 仪表板,提供了用于管理 redis 的 Web 界面:cli、admin,同时能够实时监控Redis。

https://github.com/steelThread/redmon

接下来介绍其中最常用的性能指标[2]

References


  1. SLOWLOG subcommand [argument]. Retrieved from https://redis.io/commands/slowlog ↩︎

  2. Understanding the Top 5 Redis Performance Metrics. Retrieved from https://www.datadoghq.com/pdf/Understanding-the-Top-5-Redis-Performance-Metrics.pdf ↩︎

本文作者: 帅旋

本文链接: https://www.itzhai.com/columns/redis/monitoring-tools.html

版权声明: 版权归作者所有,未经许可不得转载,侵权必究!联系作者请加公众号。

×
IT宅

关注公众号及时获取网站内容更新。