手動部署 Docker+Grafana+Prometheus系統監控之Redis
- 2019 年 10 月 26 日
- 筆記
監控規劃圖

使用Docker 創建兩台Redis
docker run -d --name redis1 redis docker run -d --name redis2 redis 查看redis的部署地址
docker inspect (docker ps -a | grep redis | awk '{print $1}') | grep IPAddress 部署redis_exporter收集redis數據
docker run -d --name redis_exporter_1 -p 9121:9121 oliver006/redis_exporter --redis.addr=172.17.0.2:6379 docker run -d --name redis_exporter_2 -p 9122:9121 oliver006/redis_exporter --redis.addr=172.17.0.3:6379 添加prometheus配置文件
global: scrape_interval: 15s evaluation_interval: 15s # Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: "prometheus-stack-monitor" # Load and evaluate rules in this file every 'evaluation_interval' seconds. #rule_files: # - "first.rules" # - "second.rules" scrape_configs: # scrape Prometheus itself - job_name: prometheus scrape_interval: 10s scrape_timeout: 5s static_configs: - targets: ["localhost:9090"] # scrape Redis Enterprise - job_name: redis-enterprise scrape_interval: 3s scrape_timeout: 3s static_configs: - targets: ['172.17.0.4:9121','172.17.0.7:9121'] targets中為redis_exporter的地址和埠號,多個逗號分隔
部署prometheus
docker run -d --name prome -p 9090:9090 -v /prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus prometheus配置文件需要使用絕對位置
部署grafana
docker run -d --name=grafana -p 3000:3000 grafana/grafana 添加prometheus數據源

下載redis模板 且導入到 grafana
效果圖


