Prometheus+Grafana学习(十)监控Redis

news/2024/5/19 0:21:54 标签: redis, redis_exporter, redis监控, grafana, prometheus

文章目录

  • 1、安装Prometheus和Grafana
  • 2、安装Redis
  • 3、安装redis_exporter
    • 3.1、下载源码
    • 3.2、安装redis_exporter
    • 3.3、测试redis_exporter
  • 4、配置Prometheus
  • 5、配置Grafana


1、安装Prometheus和Grafana

prometheus参考:https://blog.csdn.net/u011943534/article/details/122519799
grafana参考:https://blog.csdn.net/u011943534/article/details/122520190

2、安装Redis

参考:https://blog.csdn.net/u011943534/article/details/81812824

redis_exporter_16">3、安装redis_exporter

最简单的方式是使用docker安装,这里选择编译源码安装。
Github地址:https://github.com/oliver006/redis_exporter

3.1、下载源码

版本列表地址:https://github.com/oliver006/redis_exporter/tags
使用版本:v1.33.0
下载地址:https://github.com/oliver006/redis_exporter/releases/download/v1.33.0/redis_exporter-v1.33.0.linux-amd64.tar.gz

redis_exporter_24">3.2、安装redis_exporter

将上一步下载的包redis_exporter-v1.33.0.linux-amd64.tar.gz上传至Redis所在机器。
解压:

tar zvxf redis_exporter-v1.33.0.linux-amd64.tar.gz
mv redis_exporter-v1.33.0.linux-amd64 /usr/local/redis_exporter

注册为系统服务
vi /etc/systemd/system/redis_exporter.service

[Service]
WorkingDirectory=/opt/soft/redis_exporter/
PrivateTmp=true
Restart=always
Type=simple
ExecStart=/usr/local/redis_exporter/redis_exporter -redis.addr 172.16.10.169:6379
ExecStop=/usr/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target
systemctl enable redis_exporter && systemctl start redis_exporter

*如果redis有密码,在ExecStart后添加密码参数-redis.password xxx

redis_exporter_54">3.3、测试redis_exporter

访问http://IP:9121/metrics
在这里插入图片描述

4、配置Prometheus

修改prometheus.yml配置文件,添加一个redis的job。
vi /usr/local/prometheus/prometheus.yml
将刚启动的redis_exporter配置进去

# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets: ["172.16.10.171:9093"]

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "*rule.yml"
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]
  - job_name: "spring"
    scrape_interval: 15s
    scrape_timeout: 10s
    metrics_path: "/demo/actuator/prometheus"
    static_configs:
    - targets: ["192.168.100.88:7901"]
  - job_name: "mysql8.x"
    static_configs:
    - targets: ["172.16.10.169:9104", "192.168.100.88:9104"]
  - job_name: "nginx"
    static_configs:
    - targets: ["172.16.10.171:9913"]
  - job_name: "node"
    static_configs:
    - targets: ["172.16.10.171:9100","172.16.10.160:9100","172.16.10.161:9100", "172.16.10.162:9100", "172.16.10.163:9100", "172.16.10.164:9100", "172.16.10.165:9100", "172.16.10.167:9100", "172.16.10.168:9100", "172.16.10.169:9100", "172.16.10.170:9100"]
  - job_name: "alertmanager"
    static_configs:
    - targets: ["172.16.10.171:9093"]
  - job_name: "rocketmq"
    static_configs:
    - targets: ["172.16.10.168:5557", "172.16.10.169:5557"]
  - job_name: "redis"
    static_configs:
    - targets: ["172.16.10.169:9121"]

重启prometheus

systemctl restart prometheus

访问http://172.16.10.171:9090/targets
在这里插入图片描述

5、配置Grafana

使用9338的模板:https://grafana.com/grafana/dashboards/9338/revisions
下载JSON(已下载)
导入JSON
效果:
在这里插入图片描述


http://www.niftyadmin.cn/n/1302151.html

相关文章

Linux安装、运行nginx

Linux安装、运行nginx 安装参考链接&#xff1a;https://www.cnblogs.com/pxstar/p/14808244.html 运行命令&#xff1a; 安装完成一般常用命令进入安装目录中&#xff0c; 命令&#xff1a; cd /usr/local/nginx/sbin 启动&#xff0c;关闭&#xff0c;重启&#xff0c;命令&…

springboot学习(六十七) springboot项目通过gradle-docker-plugin插件构建为doker镜像并推送至镜像私服

文章目录前言1、使用gradle部署springboot项目2、Docker开启远程访问3、安装镜像私服Harbor4、gradle中配置插件前言 springboot从2.4默认提供了打镜像的gradle插件&#xff0c;但通过此插件没找到能设置基础镜像的方式&#xff0c;参见&#xff1a;https://blog.csdn.net/u01…

Linux CentOS7设值nginx开机自启动

Linux CentOS7设值nginx开机自启动 进入到/lib/systemd/system/目录 [rootiz2z init.d]# cd /lib/systemd/system/ 创建nginx.service文件&#xff0c;并编辑 # vim nginx.service 内容如下: [Unit] Descriptionnginx service Afternetwork.target [Service] Typeforking E…

Springboot捕获全局异常:MethodArgumentNotValidException

Springboot捕获全局异常&#xff1a;MethodArgumentNotValidException 控制器 方法上添加Valid注解 PostMapping("/update")RequiresPermissions("user:update")public R update(RequestBody Valid UserEntity user) {userService.update(user);return R…

istio学习(二) 使用JWT进行权限验证

文章目录前言1、生成JWK2、测试密钥可用性3、创建RequestAuthentication4、访问测试5、创建AuthorizationPolicy6、JAVA生成密钥前言 参考&#xff1a;https://www.cnblogs.com/kirito-c/p/12464531.html 提示&#xff1a;以下是本篇文章正文内容&#xff0c;下面案例可供参考…

EasyExcel 去掉不需要导出的字段

EasyExcel 去掉不需要导出的字段 参考链接&#xff1a;https://blog.csdn.net/a_tzluy/article/details/111830900

springboot学习(六十八) springboot-webflux全局异常处理

文章目录前言一、自定义错误处理二、加载自定义错误处理的配置信息三、效果前言 如果springboot中未使用springmvc的依赖&#xff0c;而是使用了webflux的依赖&#xff0c;全局异常处理的方式需要做给改变。 如果是springmvc,可以通过下面方式处理异常 Configuration Slf4j p…

MySQL 名次查询

MySQL 名次查询 链接&#xff1a;https://www.cnblogs.com/-mrl/p/9073375.html