前沿:Docker环境下整合Prometheus和Grafana监控Redis性能
环境:Centos、Docker
一、下载镜像版本
docker pull prom/node-exporter
ocker run -d -p 9100:9100 prom/node-exporter
docker pull grafana/grafana
docker run -d --name=grafana -p 3000:3000 grafana/grafana
docker pull prom/prometheus
1、在/usr/local/src新建touch prometheus.yml文件,文件夹可自定义
2、编辑vim prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'redis'
static_configs:
- targets: ['服务器IP:9121']
labels:
instance: redis
- job_name: 'linux'
static_configs:
- targets: ['服务器IP:9100']
labels:
instance: node
3、启动容器
sudo docker run -d -p 9090:9090 -v /usr/local/src/prometheus.yml:/usr/local/src/prometheus.yml prom/prometheus --config.file=/usr/local/src/prometheus.yml
docker pull redis
docker run -d --name=redis -p 6379:6379 redis
docker pull redis_exporter
docker run -d --name redis_exporter -p 9121:9121 redis_exporter --redis.addr redis://redis连接IP:6379
二、查看镜像容器是否启动成功
三、查看Prometheus是否创建完成
四、登陆Grafana创建数据源,登陆初始账号密码:admin/admin