docker安装prometheus (转)


 

总览                   
服务 端口 是否有web界面 作用

prometheus

9090 作为监控主服务器,拉取并存储时序数据

node-exporter

9100 收集内核公??开的硬件和操作系统指标

grafana

3000 数据展示可视化

cadvisor

9595 收集宿主机上运行的所有容器的性能数据

一、安装prometheus server

docker pull prom/node-exporter

# 拉取镜像

docker run -d --name node-exporter2020 -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" --net="host" prom/node-exporter

# 启动容器

firewall-cmd --zone=public --add-port=9100/tcp --permanent

firewall-cmd --reload

# 开放防火墙9100端口

访问

http://192.168.1.113:9100/metrics 

vim prometheus/prometheus.yml

# 修改宿主机prometheus配置文件,重启后会同步到容器内部

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 scrape_configs:   # The job name is added as a label `job=` to any timeseries scraped from this config.   - job_name: 'prometheus'       # metrics_path defaults to '/metrics'     # scheme defaults to 'http'.       static_configs:     - targets: ['192.168.1.113:9090']       labels:           instance: prometheus     - job_name: 'centos_1'     static_configs:     - targets: ['192.168.1.113:9100']       labels:          instance: centos_1

docker restart prometheus2020

重启容器

此时再访问

http://192.168.1.113:9090/targets

三、安装grafana

docker pull google/cadvisor

# 拉取镜像

docker run -d \
--name=cadvisor2020 \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/cgroup:/cgroup:ro \
--publish=9595:8080 \
--detach=true \
--privileged=true \
google/cadvisor

# 启动容器

firewall-cmd --zone=public --add-port=9595/tcp --permanent

firewall-cmd --reload

# 开放防火墙9595端口

访问

http://192.168.1.113:9595/

http://192.168.1.113:9595/metrics