简体   繁体   English

如何在Docker容器中运行的Prometheus中保存数据?

[英]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.

相关问题 如何将在 Docker 容器中运行的 Grafana 连接到在主机上运行的 Prometheus 数据源(在 Docker for Mac 上)? - How to connect Grafana running in a Docker container to a Prometheus data source running on the host machine (on Docker for Mac)? 如何将HDFS数据持久保存在Docker容器中 - How to persist HDFS data in docker container 如何坚持MongoDB - 新图像中正在运行的Docker容器的数据? - Howto persist MongoDB - data of a running Docker container in a new image? 在Docker容器中保留数据文件 - Persist Data files in docker container Postgresql in a Docker Container on Windows:How to persist data to a local windows folder - Postgresql in a Docker Container on Windows: How to persist data to a local windows folder 如何将我的笔记本和数据保存在我的 Docker 镜像/容器中 - How to persist my notebooks and data in my Docker image/container 如何将我的数据保存在 docker/postgres 容器中? - How can i persist my data in docker/postgres container? 在Docker容器中保留弹性搜索数据 - Persist Elastic Search Data in Docker Container 将数据从Docker容器持久保存到主机 - Persist data from docker container to host machine 将数据保存在 db2 LuW Docker 容器中 - Persist data in db2 LuW Docker Container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM