【发布时间】:2021-11-27 09:25:05
【问题描述】:
我的 prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- job_name: golang
metrics_path: /prometheus
static_configs:
- targets:
- localhost:9000
现在,我想动态传递主机名,而不是使用 localhost:9000 和 localhost:9090
我的 docker-compose.yml 使用这个 prometheus.yml 如下所示:
prometheus:
image: prom/prometheus:v2.24.0
volumes:
- ./prometheus/:/etc/prometheus/
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
network_mode: "host"
ports:
- 9090:9090
restart: always
现在,我想通过这个主机地址说:172.0.0.1 来自 docker-compose up 命令
我能做到:
Host=172.0.0.1 docker-compose up
但是,我怎样才能将此值发送到 prometheus.yml ?
提前致谢!
【问题讨论】:
标签: docker docker-compose yaml environment-variables prometheus