dur*_*lla 5 yaml docker docker-compose prometheus cadvisor
我是 prometheus 、 cadvisor 和 docker-compose 的新手。我制作了一个 docker-compose 文件,其中包括我自己创建的名为 chat 的应用程序,以及一个 mongo 容器。那些工作正常。现在我想用 prometheus 和 cadvisor 监控我的容器。我收到以下错误:
cadvisor | W0419 11:41:00.576916 1 sysinfo.go:203] Nodes topology is not available, providing CPU topology
cadvisor | W0419 11:41:00.577437 1 sysfs.go:348] unable to read /sys/devices/system/cpu/cpu0/online: open /sys/devices/system/cpu/cpu0/online: no such file or directory
cadvisor | E0419 11:41:00.582000 1 info.go:114] Failed to get system UUID: open /etc/machine-id: no such file or directory
Run Code Online (Sandbox Code Playgroud)
和
prometheus | ts=2022-04-19T11:54:19.051Z caller=main.go:438 level=error msg="Error loading config (--config.file=/etc/prometheus/prometheus.yml)" file=/etc/prometheus/prometheus.yml err="parsing YAML file /etc/prometheus/prometheus.yml: yaml: unmarshal errors:\n line 2: field scrape-interval not found in type config.plain"
Run Code Online (Sandbox Code Playgroud)
我尝试将 docker-compose 中的配置参数更改为,但它没有改变错误:
command:
- '--config.file=./prometheus/prometheus.yml'
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml:
version : '3.7'
services:
chat-api:
container_name: chat-api
build:
context: .
dockerfile: ./Dockerfile
ports:
- '4000:4000'
networks:
- cchat
restart: 'on-failure'
userdb:
image: mongo:latest
container_name: mongodb
volumes:
- userdb:/data/db
networks:
- cchat
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- '9080:9080'
networks:
- cloudchat
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: cadvisor
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
devices:
- /dev/kmsg:/dev/kmsg
depends_on:
- chat-api
networks:
- cchat
volumes:
userdb:
networks:
cchat:
Run Code Online (Sandbox Code Playgroud)
普罗米修斯.yml:
global:
scrape-interval: 2s
scrape_configs:
- job_name: 'cadvisor'
static_configs:
- targets: ['cadvisor:8080']
Run Code Online (Sandbox Code Playgroud)
项目结构: 项目结构图
我想已经很晚了,但你可以尝试安装/etc/machine-id:/etc/machine-id:ro
。在特权模式下运行也有帮助。这是我的配置,运行没有问题:
cadvisor:
image: gcr.io/cadvisor/cadvisor:v0.47.0
container_name: cadvisor
restart: unless-stopped
privileged: true
ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
Run Code Online (Sandbox Code Playgroud)
一些重要的注意事项,不要使用latest
它,它似乎不是最新版本(来源: https: //github.com/google/cadvisor/issues/3066)。
归档时间: |
|
查看次数: |
7575 次 |
最近记录: |