二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

  • Nginx

  • Php

  • Zabbix

  • AWS

  • Prometheus

    • Prometheus安装部署及简单监控
    • Prometheus邮件报警配置
    • Prometheus配置Grafana Dashboard
    • Prometheus 监控之 Redis
      • 1、安装部署
      • 2、redis_exporter 用法
      • 3,运行 redis_exporter 服务
        • 1,方式 A 直接启动。
        • 2,方式 B 通过 system 管理。
      • 4、配置 prometheus.yml 添加监控目标
      • 5,配置 Grafana 的模板
    • Prometheus 监控之 MySQL
    • 从CPU的获取来学习理解Prometheus查询语句
    • Prometheus监控之kafka集群
    • Prometheus监控之elasticsearch集群
    • Prometheus关于with和by的作用及用法
    • 利用promwrite对prometheus进行remote-write写入
    • prometheus结合nginx-lua-prometheus监控openresty
  • Grafana

  • Loki

  • CentOS

  • Supervisord

  • Systemd

  • Docker

  • Docker-Compose

  • Rancher

  • Ansible

  • OpenLdap

  • GitLab

  • GitHub

  • Etcd

  • Consul

  • RabbitMQ

  • Kafka

  • Mysql

  • MongoDB

  • OpenVPN

  • Kvm

  • VMware

  • 配置文件详解

  • Other

  • 运维观止
  • Prometheus
二丫讲梵
2019-02-18
目录

Prometheus 监控之 Redis

文章发布较早,内容可能过时,阅读注意甄别。

prometheus 监控 redis 需要用到 redis_exporter。

redis_exporter 项目地址:https://github.com/oliver006/redis_exporter

# 1、安装部署

我这里的 redis 部署在 192.168.111.11 之上,而 prometheus 服务端是在 192.168.111.3 上,这个时候,监控的工具 redis_exporter 可以部署在这两台主机任一一台上,只不过需要注意的是,在配置 prometheus.yaml 添加监控目标的时候,注意填写对应 ip 即可。

我这里则部署在了 Prometheus Server 之上。

$ cd /usr/local/src
$ wget https://github.com/oliver006/redis_exporter/releases/download/v0.21.2/redis_exporter-v0.21.2.linux-amd64.tar.gz
$ mkdir /usr/local/redis_exporter
$ tar xf redis_exporter-v0.21.2.linux-amd64.tar.gz -C /usr/local/redis_exporter/
1
2
3
4

# 2、redis_exporter 用法

解压后只有一个二进制程序就叫 redis_exporter 通过 -h 可以获取到帮助信息,下面列出一些常用的选项:

-redis.addr:指明一个或多个 Redis 节点的地址,多个节点使用逗号分隔,默认为 redis://localhost:6379
-redis.password:验证 Redis 时使用的密码;
-redis.file:包含一个或多个redis 节点的文件路径,每行一个节点,此选项与 -redis.addr 互斥。
-web.listen-address:监听的地址和端口,默认为 0.0.0.0:9121
1
2
3
4

# 3,运行 redis_exporter 服务

# 1,方式 A 直接启动。

## 无密码
./redis_exporter redis//192.168.111.11:6379 &
## 有密码
redis_exporter  -redis.addr 192.168.111.11:6379  -redis.password 123456
1
2
3
4

# 2,方式 B 通过 system 管理。

创建 redis_exporter.service 启动脚本

$ vim /usr/lib/systemd/system/redis_exporter.service
[Unit]
Description=redis_exporter
Documentation=https://github.com/oliver006/redis_exporter
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 192.168.111.11:6379  -redis.password 123456
Restart=on-failure
[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12

注意:关于 redis 的相关信息,则在ExecStart配置项当中进行定义!

redis_exporter 使用 prometheus 用户运行,所以需要创建该用户:

$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus
1
2

启动服务:

$ systemctl daemon-reload
$ systemctl start redis_exporter
$ systemctl status redis_exporter
$ ss -tnl|grep 9121
1
2
3
4

# 4、配置 prometheus.yml 添加监控目标

$ vim /usr/local/prometheus/prometheus.yml
  - job_name: 'redis'
    scrape_interval: 10s
    static_configs:
      - targets:
        - ['localhost:9121']    #如果是部署在192.168.111.11上,那么localhost需要改成192.168.111.11
1
2
3
4
5
6

重启服务。

$ systemctl restart prometheus
1

申明

原创文章eryajf,未经授权,严禁转载,侵权必究!此乃文中随机水印,敬请读者谅解。

Copyright 二丫讲梵 (opens new window) 版权所有

# 5,配置 Grafana 的模板

redis_exporter 在 Grafana 上为我们提供好了 Dashboard 模板:https://grafana.com/dashboards/763

下载后在 Grafana 中导入 json 模板就可以看到官方这样的示例截图啦:

image

参考:https://codegreen.cn/2018/09/29/prometheus-redis/

微信 支付宝
#prometheus#redis
上次更新: 2024/07/04, 22:40:37
Prometheus配置Grafana Dashboard
Prometheus 监控之 MySQL

← Prometheus配置Grafana Dashboard Prometheus 监控之 MySQL→

最近更新
01
学习周刊-总第212期-2025年第21周
05-22
02
从赵心童世锦赛夺冠聊聊我的斯诺克情缘
05-16
03
学习周刊-总第211期-2025年第20周
05-15
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式