当前位置: 首页 > news >正文

Prometheus+Grafana监控redis

1、简述

        使用 Prometheus 和 Grafana 监控 Redis 的方案与监控 MySQL 类似,需要通过 Redis Exporter 来暴露 Redis 的监控指标,再由 Prometheus 采集并通过 Grafana 可视化。

2、整体架构

  • Redis Exporter:部署在可访问 Redis 的节点上,负责收集 Redis 的运行指标(如内存使用、连接数、命中率等)并提供 HTTP 接口。
  • Prometheus:定时从 Redis Exporter 抓取指标并存储。
  • Grafana:连接 Prometheus 数据源,通过仪表盘可视化 Redis 指标。

3、部署组件

3.1 部署 Redis Exporter

下载安装包

从官方仓库下载对应版本(以v1.75.0为例):

wget https://github.com/oliver006/redis_exporter/releases/download/v1.75.0/redis_exporter-v1.75.0.linux-amd64.tar.gz
tar -zxvf redis_exporter-v1.75.0.linux-amd64.tar.gz
mv redis_exporter-v1.75.0.linux-amd64 /usr/local/redis_exporter

启动 Exporter-系统服务方式(推荐)

创建/etc/systemd/system/redis-exporter.service

[Unit]
Description=Redis Exporter
After=network.target[Service]
User=root
ExecStart=/usr/local/redis_exporter/redis_exporter --redis.addr=redis://localhost:6379 --redis.password=your_redis_password
Restart=always[Install]
WantedBy=multi-user.target

启动并设置开机自启:

systemctl daemon-reload
systemctl start redis-exporter
systemctl enable redis-exporter

验证 Exporter

访问http://服务器IP:9121/metrics,若能看到 Redis 相关指标(如redis_upredis_connected_clients),说明启动成功。

3.2 Prometheus+Grafana

安装

参考文章:docker compose安装Prometheus、Grafana_grafana docker-compose-CSDN博客

配置 Prometheus 抓取 Exporter 指标

编辑 Prometheus 配置文件(/usr/local/prometheus/prometheus.yml),在scrape_configs中添加 Redis 任务:

scrape_configs:- job_name: 'redis'static_configs:- targets: ['localhost:9121']  # Redis Exporter的地址

重启Prometheus。

4、配置 Grafana 可视化 Redis指标

添加 Prometheus 数据源

进入 Grafana(http://IP:3000),依次点击 “Configuration -> Data Sources -> Add data source”,选择 “Prometheus”,填写 URL(如http://localhost:9090),保存测试。

导入 Redis 监控仪表盘

  • 点击 “Dashboards -> Import”,输入仪表盘 ID(推荐76311835,可在Grafana Dashboards搜索 “Redis” 获取)。
  • 选择 Prometheus 数据源,点击 “Import”,即可看到 Redis 监控面板,包含以下核心指标:
    • 可用性:redis_up(1 为正常)
    • 连接数:redis_connected_clients(当前连接数)、redis_client_longest_output_list(最长输出列表)
    • 内存指标:redis_used_memory(已用内存)、redis_used_memory_peak(内存峰值)
    • 命中率:redis_keyspace_hits(命中数)、redis_keyspace_misses(未命中数),命中率 = hits/(hits+misses)
    • 持久化:redis_rdb_last_save_time(最近 RDB 保存时间)、redis_aof_last_rewrite_time_sec(AOF 重写时间)

http://www.xdnf.cn/news/1346113.html

相关文章:

  • 制造企业用档案宝,档案清晰可查
  • 81 柔性数组造成的一些奇怪情况
  • 农业-学习记录
  • 关于 WebDriver Manager (自动管理浏览器驱动)
  • 当下一次攻击发生前:微隔离如何守护高敏数据,防范勒索攻击下的数据泄露风险!
  • 一、Python IDLE安装(python官网下的环境安装)
  • 腾讯云EdgeOne安全防护:快速上手,全面抵御Web攻击
  • Datawhale AI夏令营---coze空间共学
  • 【图像算法 - 21】慧眼识虫:基于深度学习与OpenCV的农田害虫智能识别系统
  • 关于日本服务器的三种线路讲解
  • 在自动驾驶中ESKF实现GINS时,是否将重力g作为变量考虑进去的目的是什么?
  • ASPICE过程能力确定——度量框架
  • Unity--判断一个点是否在扇形区域里面(点乘和叉乘的应用)
  • 视觉语言大模型应用开发——基于 CLIP、Gemini 与 Qwen2.5-VL 的视频理解内容审核全流程实现
  • ref 简单讲解
  • flutter geolocator Android国内定位失败问题解决
  • JVM 调优全流程案例:从频繁 Full GC 到百万 QPS 的实战蜕变
  • 【大模型本地运行与部署框架】Ollama的cmd常用命令
  • Linux 软件编程(九)网络编程:IP、端口与 UDP 套接字
  • 【Python】两条命令永久切国内源
  • 本地组策略编辑器图形化工具
  • 力扣(在排序数组中查找元素的第一个和最后一个位置)
  • 当我们想用GPU(nlp模型篇)
  • 开源 python 应用 开发(十)音频压缩
  • 开源 python 应用 开发(十一)短语音转文本
  • ZKmall模块商城的跨境电商支付安全方案:加密与权限的双重防护
  • 数据结构 -- 树
  • STM32G4-比较器
  • 亚马逊老品怎么再次爆发流量?
  • 计算机内存中的整型存储奥秘、大小端字节序及其判断方法