本文介绍了如何在运行于Docker容器中的Prometheus中持久存储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一些需要Prometheus在重新启动之间保留其数据的东西.遵循了说明

I'm developing something that needs Prometheus to persist its data between restarts. 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

我在主机的正确目录中有一个有效的 prometheus.yml ,Prometheus正在容器内对其进行读取.目前,我仅抓取几个HTTP端点以进行测试.

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. I'm just scraping a couple of HTTP endpoints for testing purposes at the moment.

但是当我重新启动容器时,它是空的,上一次运行没有数据.我的 docker run ... 命令将数据持久保存到 a-new-volume 卷中,我缺少什么?

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?

推荐答案

使用默认数据目录,即/prometheus .为此,请使用以下行而不是命令中的行:

Use the default data dir, which is /prometheus. To do that, use this line instead of what you have in your command:

...
--volume a-new-volume:/prometheus \
...

在这里找到: https://github.com/prometheus/prometheus/blob/master/Dockerfile

图像文档

这篇关于如何在运行于Docker容器中的Prometheus中持久存储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:27