[英]How to persist data in Prometheus running in a Docker container?
I'm developing something that needs Prometheus to persist its data between restarts. 我正在开发一些需要Prometheus在重启之间保持数据的东西。 Having followed the instructions 遵循了指示
$ docker volume create a-new-volume
$ docker run \
--publish 9090:9090 \
--volume a-new-volume:/prometheus-data \
--volume "$(pwd)"/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
I have a valid prometheus.yml
in the right directory on the host machine and it's being read by Prometheus from within the container. 我在主机上的正确目录中有一个有效的prometheus.yml
,它正由容器内的Prometheus读取。 I'm just scraping a couple of HTTP endpoints for testing purposes at the moment. 我现在只是为了测试目的而抓取几个HTTP端点。
But when I restart the container it's empty, no data from the previous run. 但是,当我重新启动容器时,它是空的,没有来自上一次运行的数据。 What am I missing from my docker run ...
command to persist the data into the a-new-volume
volume? 我的docker run ...
缺少什么命令将数据保存到a-new-volume
卷中?
Use the default data dir, which is /prometheus
. 使用默认数据目录,即/prometheus
。 To do that, use this line instead of what you have in your command: 要做到这一点,请使用此行而不是命令中的内容:
...
--volume a-new-volume:/prometheus \
...
Found here: https://github.com/prometheus/prometheus/blob/master/Dockerfile 在这里找到: https : //github.com/prometheus/prometheus/blob/master/Dockerfile
Surprisingly is not mentioned in the image docs 令人惊讶的是在图像文档中没有提到
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.