Prometheus + Grafana 监控 Redis

Prometheus安装

wget https://github.com/prometheus/prometheus/releases/download/v2.1.0/prometheus-2.1.0.linux-amd64.tar.gz
tar -zxvf prometheus-2.1.0.linux-amd64.tar.gz -C /prometheus --strip-components=1
cd /prometheus
# Start Prometheus.
# By default, Prometheus stores its database in ./data (flag --storage.tsdb.path).
./prometheus --config.file=prometheus.yml

在浏览器输入localhost:9090

Grafana安装

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.3-1.x86_64.rpm 
sudo yum localinstall grafana-4.6.3-1.x86_64.rpm 

启动服务

$ sudo service grafana-server start

开机启动

$ sudo /sbin/chkconfig --add grafana-server

安装完成。浏览器打开 http://192.168.0.15:3000 ,输入默认用户名密码 (admin/admin) 可以进入 Grafana 。

Prometheus 和 Grafana 对接

 

 

Prometheus: URL: localhost:9090/

即可完成 Prometheus 和 Grafana 的对接。

在redis服务器安装node_exporter和redis_exporter

redis_exporter安装

wget https://github.com/oliver006/redis_exporter/releases/download/v0.15.0/redis_exporter-v0.15.0.linux-amd64.tar.gz
tar -zxvf redis_exporter-v0.15.0.linux-amd64.tar.gz -C /prometheus_exporters --strip-components=1
wget https://github.com/prometheus/node_exporter/releases/download/v0.15.2/node_exporter-0.15.2.linux-amd64.tar.gz
tar -zxvf redis_exporter-v0.15.2.linux-amd64.tar.gz -C /prometheus_exporters --strip-components=1

启动

cd  /prometheus_exporters
./node_exporter & 
./redis_exporter redis//localhost:6379 & -web.listenaddress 0.0.0.0:9121

 配置prometheus.yml 加入

扫描二维码关注公众号,回复: 1790776 查看本文章
 
  
global:  
   scrape_interval:     15s   
   external_labels:    
   monitor: 'codelab-monitor'
scrape_configs:   
    - job_name: 'prometheus'    
   scrape_interval: 5s    
 static_configs:      
     - targets: ['localhost:9090']  
     - job_name: redis    
 static_configs:      
     - targets: ['xxx.xxx.xxx.xxx:9121']        
 labels:          
     instance: db1

注意prometheus.yml中缩进不能有tab。

导入json模板

下载grafana的redis的prometheus-redis_rev1.json模板

wget  https://grafana.com/api/dashboards/763/revisions/1/download

在grafana中导入json模板

启动redis

在redis安装路径执行

src/redis-server

 

猜你喜欢

转载自blog.csdn.net/qq_35396905/article/details/80452523