我对Prometheus和Docker Compose是新手。我有一个项目结构与docker-compose.yml文件,设置普罗米修斯和Grafana:/prometheus-grafana/prometheus/docker-compose.yml
version: '3'
services:
prometheus:
image: prom/prometheus:v2.21.0
ports:
- 9000:9090
volumes:
- ./prometheus:/etc/prometheus
- prometheus-data:/prometheus
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana:$GRAFANA_VERSION
environment:
GF_SECURITY_ADMIN_USER: $GRAFANA_ADMIN_USER
GF_SECURITY_ADMIN_PASSWORD: $GRAFANA_ADMIN_PASSWORD
ports:
- 3000:3000
volumes:
- grafana-storage:/var/lib/grafana
depends_on:
- prometheus
networks:
- internal
networks:
internal:
volumes:
prometheus-data:
grafana-storage:我刚刚在/prometheus-grafana/prometheus/prometheus/prometheus.yml中添加了更多的配置,我添加的部分是最后3行:
global:
scrape_interval: 30s
scrape_timeout: 10s
rule_files:
- alert.yml
scrape_configs:
- job_name: services
metrics_path: /metrics
static_configs:
- targets:
- 'prometheus:9090'
- 'idonotexists:564'
- job_name: myapp
scrape_interval: 10s
static_configs:
- targets:
- localhost:2112我通过运行以下命令启动普罗米修斯:docker-compose up -d,我在http://localhost:9000/graph上找到了普罗米修斯,但我没有看到我添加到prometheus.yml中的新配置,在docker-compose.yml文件中,有一行:
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml我是不是应该把这个也改为我项目中另一个/prometheus-grafana/prometheus/prometheus/prometheus.yml的路径,而不是从/etc/prometheus/prometheus.yml,因为实际上,这个文件并不存在/etc/prometheus/prometheus.yml
提前谢谢你。
发布于 2021-04-12 18:34:38
如果你用--config.file=/etc/prometheus/prometheus.yml配置了普罗米修斯,它希望它的配置文件就在这个位置。
因为您已经配置了以下挂载点:
volumes:
- ./prometheus:/etc/prometheus
- prometheus-data:/prometheus您只需将配置文件放入./prometheus并将其命名为prometheus.yml
https://stackoverflow.com/questions/67056367
复制相似问题