docker運行prometheus報錯:error loading config from \"prometheus.yml\": couldn't load configuration

目錄

prometheus.yml路徑

原命令

報錯

 解決

完整命令


prometheus.yml路徑

/root/katy/prometheus/prometheus.yml

原命令

// --log.level=debug: log以debug模式輸出
// --storage.tsdb.retention.time=3d: 數據保留時間爲3天
docker run -d -p 9090:9090 -v /root/katy/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro prom/prometheus:latest --log.level=debug --storage.tsdb.retention.time=3d

報錯

docker ps |grep prometheus根本沒起起來。

從日誌level可以看出我的log.level=dubug已經生效,並且還可以看到我設置的retention時間。

但在加載配置文件的時候就報錯:

error loading config from \"prometheus.yml\": couldn't load configuration (--config.file=\"prometheus.yml\"): open prometheus.yml: no such file or directory

 解決

有大佬說-v是掛載目錄,不能用文件,我操作了,效果一樣的。

https://github.com/prometheus/prometheus/issues/5986

在命令後追加--config.file=/etc/prometheus/prometheus.yml,就解決了

完整命令

// --log.level=debug:日誌以debug輸出
// --storage.tsdb.retention.time=3d,數據保留3天
// --config.file=/etc/prometheus/prometheus.yml:這個其實是容器裏面的默認路徑,我也不知道爲啥需要這個,反正我加了這個就解決了
docker run -d -p 9090:9090 -v /root/katy/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus  prom/prometheus:latest --log.level=debug --storage.tsdb.retention.time=3d --config.file=/etc/prometheus/prometheus.yml

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章