doina

一个小菜鸟运维工程师.

prometheus 监控redis

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

Redis export 安装和使用

# 下载 redis_exporter
https://github.com/oliver006/redis_exporter/releases

cd /usr/local/src/
wget https://github.com/oliver006/redis_exporter/releases/download/v1.0.1/redis_exporter-v1.0.1.linux-amd64.tar.gz
tar xf redis_exporter-v1.0.1.linux-amd64.tar.gz

cd redis_exporter-v1.0.1.linux-amd64
./redis_exporter  -h

# 常用参数
-redis.addr
-redis.password
-web.listen-address

# 创建redis_exporter工作目录
mkdir /usr/local/redis_exporter
mv redis_exporter  /usr/local/redis_exporter/
cd /usr/local/redis_exporter/

# 编写启动脚本
vim start_redis_exporter.sh 
#!/bin/bash
HOSTIP=192.168.1.73
nohup ./redis_exporter -redis.addr $HOSTIP:7000 -redis.password Password -web.listen-address $HOSTIP:27000 &
nohup ./redis_exporter -redis.addr $HOSTIP:7001 -redis.password Password -web.listen-address $HOSTIP:27001 &

# 测试 URL 获取 metrics
curl -s  192.168.1.73:27000/metrics|grep -v "^#"| more 
exporter_scrape_duration_seconds{quantile="0.5"} NaN
exporter_scrape_duration_seconds{quantile="0.9"} NaN

[root@kvm000 redis_exporter]# curl -s  192.168.1.73:27001/metrics|grep -v "^#"| more  
exporter_scrape_duration_seconds{quantile="0.5"} NaN
exporter_scrape_duration_seconds{quantile="0.9"} NaN
exporter_scrape_duration_seconds{quantile="0.99"} NaN

配置prometheus

[root@localhost sd_config]# vim /opt/prometheus/prometheus.yml 
  - job_name: 'redis'
    file_sd_configs:
    - files: ['/opt/prometheus/sd_config/redis.yml']
      refresh_interval: 180s

[root@localhost sd_config]# vim /opt/prometheus/sd_config/redis.yaml 
- targets:
  - 192.168.1.73:27000
  - 192.168.1.73:27001
  labels:
    idc: bj_company
    service: redis

[root@localhost sd_config]# kill -hup `ps -ef |grep prometheus|grep -v grep|awk '{print $2}'`

《prometheus 监控redis》

配置grafana

导入模板: 763, 需要简单修改
《prometheus 监控redis》

点赞

发表评论

邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据