【问题标题】:Where does Prometheus store metrics data (in container)?Prometheus 在哪里存储指标数据(在容器中)?
【发布时间】:2020-09-14 07:55:27
【问题描述】:

我正在搜索Storage section pf Prometheus Documentation 中描述的./data 文件夹。 我在 Kubernetes 上运行了一个基本的 Prometheus Docker 容器prom/prometheus。如果我在容器内执行一个 shell,工作目录是 /prometheus,它包含 wal 目录,但它没有文档中提到的结构,我找不到任何指标数据。

我可以通过 Prometheus GUI 查询的指标存储在哪里?

【问题讨论】:

    标签: docker prometheus


    【解决方案1】:

    您可以在 Github (https://github.com/prometheus/prometheus/blob/master/Dockerfile#L24) 上查看 Prometheus Dockerfile,工作目录是 /prometheus,您可以在其中找到所有指标和数据。

    以下是/prometheus目录中的数据

    /prometheus $ ls -l
    total 8
    -rw-r--r--    1 nobody   nogroup          0 May 28 12:39 lock
    -rw-r--r--    1 nobody   nogroup      20001 May 28 12:45 queries.active
    drwxr-xr-x    2 nobody   nogroup       4096 May 28 12:39 wal
    

    这是您无法解码的*时间序列数据库*。如果你会运行更多的导出器,你可能会看到更多的文件夹,比如chunks 等。

    参考:https://prometheus.io/docs/prometheus/1.8/storage/

    【讨论】:

    • 就像我说的,我找不到 INSIDE 这个文件夹的数据。只有/prometheus/wal文件夹,在这个文件夹里面只有一个叫00000000的文件,里面有byte,但是我不知道怎么打开。
    • 首先prometheus需要拉取metrics。那么只有你能看到数据
    • 我可以通过 Web 前端和 Grafana 查询指标,因此 Prometheus 已经提取指标。
    • 编辑了我的答案,那是时间序列数据库,它是普罗米修斯的功能。解码即了解 Prometheus DB 的工作原理。
    • 你能检查一下并关闭吗?
    【解决方案2】:

    我现在已经解决了问题。文档中提到的结构需要几个小时来构建。

    ./data
    ├── 01BKGTZQ1HHWHV8FBJXW1Y3W0K
    │   └── meta.json
    ├── 01BKGV7JC0RY8A6MACW02A2PJD
    │   ├── chunks
    │   │   └── 000001
    │   ├── tombstones
    │   ├── index
    │   └── meta.json
    └── wal
        ├── 00000002
        └── checkpoint.000001
    

    第一个以01... 开头的文件夹在 4 小时后出现。下一个又花了2个小时。它似乎会根据您提取的指标数量而有所不同。


    旁注:正如 nischay goyal 在他的回答中所写,Prometheus TSDB 无法解码。你可以query the Prometheus API with a script to export metrics

    【讨论】:

    • 在哪里可以找到 ./data 目录?我似乎在我的 Prometheus 服务器上找不到它。
    • @fuzzi 通常在/prometheus/data 之下。也许你遇到了和我一样的问题,你只需要等待一段时间,直到收集到足够的数据。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-06
    • 2015-11-17
    • 2012-04-11
    • 2011-12-14
    • 2020-01-07
    • 2011-12-09
    相关资源
    最近更新 更多