Redis可视化监控
使用Redis数据源的方法
安装Grafana
Grafana安装
Grafana添加Redis数据源
在grafana启动的服务器上面输入下面命令
grafana-cli plugins install redis-datasource
![在这里插入图片描述](https://img-blog.csdnimg.cn/58de041ff9534c6aafe0d23b4b7dc4bd.png)
重启Grafana
systemctl restart grafana-server.service
设置数据源
![在这里插入图片描述](https://img-blog.csdnimg.cn/d6d9ad5e8c4c4a7fb1e07d44e12f3994.png)
添加Grafana面板
有两种仪表盘提供
![在这里插入图片描述](https://img-blog.csdnimg.cn/2c898b9254f24de3856a734c09f033e0.png)
效果图
Redis
![在这里插入图片描述](https://img-blog.csdnimg.cn/e5a605930e26444c89609b78367e8132.png)
Redis Streaming
![在这里插入图片描述](https://img-blog.csdnimg.cn/8ea280d2f1b84aa8b42fc59c951c9cc3.png)
优缺点
优点 | 缺点 |
---|
操作简单,快速部署 | 当重新打开页面或者切换条件的时候,历史数据就会消失 |
使用Prometheus当数据源方式
下载redis_exporter
wget https://github.com/oliver006/redis_exporter/releases/download/v0.30.0/redis_exporter-v0.30.0.linux-amd64.tar.gz
解压redis_exporter
tar -zxvf redis_exporter-v0.30.0.linux-amd64.tar.gz
启动redis_exporter
设置为Linux服务
添加配置文件
vim /usr/lib/systemd/system/redis_exporter.service
文件内容
[Service]
ExecStart=/你本地之前下载redis_exporter的位置/redis_exporter -redis.addr=192.168.1.158:6379 -web.listen-address 0.0.0.0:9121
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
[Unit]
Description=redis_exporter
After=network.target
systemctl daemon-reload
systemctl enable redis_exporter.service
systemctl start redis_exporter.service
启动完成
![在这里插入图片描述](https://img-blog.csdnimg.cn/39dc660844754fa2a9ad702b03ce6405.png)
配置Prometheus参数
安装Prometheus
Prometheus安装
修改配置文件
- job_name: 'redis'
static_configs:
- targets: ['192.168.1.105:9121']
labels:
instance: '192.168.1.105'
![在这里插入图片描述](https://img-blog.csdnimg.cn/bb71a3e10e984e2b905e706db1c97b65.png)
重启Prometheus
systemctl restart prometheus.service
![在这里插入图片描述](https://img-blog.csdnimg.cn/c978d0e01c2244e29e1a87a2b8a3c90b.png)
Grafana添加数据模板
安装Grafana
Grafana安装
Grafana添加模板
![在这里插入图片描述](https://img-blog.csdnimg.cn/13db7fb0fe59455d958acf842cf601ae.png)
选择添加过redis_exporter的Prometheus
![在这里插入图片描述](https://img-blog.csdnimg.cn/c9bcacde221b4ff7a72e39c1ceaac42c.png)
效果展示
![在这里插入图片描述](https://img-blog.csdnimg.cn/e9da444c484d43a2b34e11ffc0ef8f4a.png)
优缺点
优点 | 缺点 |
---|
查看历史数据方便,因为历史数据是保存在Prometheus中 | 操作比直接添加redis源复杂一些,需要安装并配置Prometheus |