Prometheus 在哪里存储指标数据(在容器中)?

Where does Prometheus store metrics data (in container)?

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

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

您可以在 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

Ref: https://prometheus.io/docs/prometheus/1.8/storage/

我现在想通了。文档中提到的结构需要几个小时来构建。

./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.