我正在使用cadvisor和node_exporter设置prometheus + grafana。我需要收集2台以上服务器的指标。但可以说我要2个不做。我正在使用docker compose。
在主服务器上,我有以下配置:
[root@172.31.115.207 ~]# cat prometheus.yml
scrape_configs:
- job_name: prometheus
scrape_interval: 5s
static_configs:
- targets:
- prometheus:9090
- pushgateway:9091
- job_name: docker
scrape_interval: 5s
static_configs:
- targets:
- 172.31.115.207:9323
- job_name: cadvisor
scrape_interval: 5s
static_configs:
- targets: ['172.31.112.84:8080','172.31.115.207:8080']
- job_name: node-exporter
scrape_interval: 5s
static_configs:
- targets: ['172.31.112.84:9100','172.31.115.207:9100']
cat prometheus.yml
- 172.31.115.207:9323
- job_name: cadvisor
scrape_interval: 5s
static_configs:
- targets: ['172.31.112.84:8080','172.31.115.207:8080']
- job_name: node-exporter
scrape_interval: 5s
static_configs:
- targets: ['172.31.112.84:9100','172.31.115.207:9100']
[root@pivanko1c ~]# cat docker-compose.yml
version: '3'
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- 9090:9090
command:
- --config.file=/etc/prometheus/prometheus.yml
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
depends_on:
- cadvisor
cadvisor:
image: google/cadvisor:latest
container_name: cadvisor
ports:
- 8080:8080
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
pushgateway:
image: prom/pushgateway
container_name: pushgateway
ports:
- 9091:9091
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
ports:
- 9100:9100
grafana:
image: grafana/grafana
container_name: grafana
ports:
- 3000:3000
environment:
- GF_SECURITY_ADMIN_PASSWORD=Uniform189
depends_on:
- prometheus
- cadvisor
这是我的docker-compose.yml;在工作服务器上
[root@172.31.112.84 ~]# cat docker-compose.yml
version: '3'
services:
cadvisor:
image: google/cadvisor:latest
container_name: cadvisor
ports:
- 8080:8080
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
ports:
- 9100:9100
当我仅设置了主人后,在grafana中一切看起来都很好。但是,当我在工作节点上启动容器时,grafana会出错。我只看到容器的数量。其他所有内容均为N / A。
请您告知我的配置问题出在哪里?我想在grafana中有个不错的视图,在这里可以选择node1或node2并查看所有指标。
谢谢