{"id":1552,"date":"2021-09-19T10:20:33","date_gmt":"2021-09-19T10:20:33","guid":{"rendered":"https:\/\/www.ipcpu.com\/?p=1552"},"modified":"2021-10-08T10:21:01","modified_gmt":"2021-10-08T10:21:01","slug":"prometheus-data-model","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2021\/09\/prometheus-data-model\/","title":{"rendered":"prometheus\u6570\u636e\u6a21\u578b\u548c\u5b58\u50a8\u673a\u5236"},"content":{"rendered":"

\u4e00\u3001\u6982\u8ff0<\/h2>\n

\u672c\u6587\u6574\u7406\u4e86Prometheus\u7684\u4e00\u4e9b\u6570\u636e\u6a21\u578b\u548c\u5b58\u50a8\u673a\u5236\uff0c\u6d89\u53ca\u5230metric names\uff0clabels\uff0csamples\uff0cSeries\uff0cChunk\u3001HeadChunk\u3001Block\u7b49\u6982\u5ff5\u3002
\n\u5bf9\u4e8e\u7406\u89e3Prometheus\u8fd0\u884c\u673a\u5236\uff0c\u7406\u89e3\u5e38\u89c1\u7684Prometheus\u76d1\u63a7\u6307\u6807\u6709\u4e00\u5b9a\u5e2e\u52a9\u3002
\n\u672c\u6587\u8d44\u6599\u5168\u90e8\u6765\u6e90\u4e8e\u5176\u4ed6\u7f51\u7ad9\uff0c\u82e5\u6709\u9519\u8bef\uff0c\u8bf7\u5927\u5bb6\u6307\u51fa\u3002<\/p>\n

\u4e8c\u3001\u6570\u636e\u6a21\u578b DataModel<\/h2>\n

Prometheus \u7684\u76d1\u63a7\u6570\u636e\u4ee5\u6307\u6807\uff08metric\uff09\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u5185\u7f6e\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u5e93\uff08TSDB\uff09\u5f53\u4e2d\u3002<\/p>\n

\u6307\u6807\u540d\u79f0\u548c\u6807\u7b7e(metric names, labels)<\/h4>\n

\u6bcf\u4e00\u6761\u65f6\u95f4\u5e8f\u5217\u7531\u6307\u6807\u540d\u79f0\uff08Metrics Name\uff09\u4ee5\u53ca\u4e00\u7ec4\u6807\u7b7elabels\uff08\u952e\u503cKV\u5bf9\uff09\u552f\u4e00\u6807\u8bc6\u3002
\nTIPS: \u6539\u53d8\u6807\u7b7e\u4e2d\u7684K\u6216\u8005V\u503c\uff08\u5305\u62ec\u6dfb\u52a0\u6216\u5220\u9664\uff09\uff0c\u90fd\u4f1a\u521b\u5efa\u65b0\u7684\u65f6\u95f4\u5e8f\u5217\u3002<\/p>\n

\u6837\u672cSamples<\/h4>\n

\u5728\u65f6\u95f4\u5e8f\u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a\u70b9\u79f0\u4e3a\u4e00\u4e2a\u6837\u672c\uff08sample\uff09\uff0c\u6837\u672c\u7531\u4ee5\u4e0b\u4e09\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n

\n

\u6307\u6807\uff08metric\uff09\uff1a\u6307\u6807\u540d\u79f0Metric names\u548c\u6807\u7b7elabels\uff1b
\n \u65f6\u95f4\u6233\uff08timestamp\uff09\uff1a\u4e00\u4e2a\u7cbe\u786e\u5230\u6beb\u79d2\u7684\u65f6\u95f4\u6233\uff1b
\n \u6837\u672c\u503c\uff08value\uff09\uff1a \u4e00\u4e2a folat64 \u7684\u6d6e\u70b9\u578b\u6570\u636e\u8868\u793a\u5f53\u524d\u6837\u672c\u7684\u503c\u3002<\/p>\n<\/blockquote>\n

\u5982\u4e0b\u5c31\u662f\u4e09\u4e2a\u6837\u672c\u6570\u636e\uff0c\u5f88\u597d\u7684\u89e3\u91ca\u4e86\u8fd9\u51e0\u4e2a\u540d\u8bcd\u7684\u5206\u5e03<\/p>\n

\n
<-------------------- metric ------------------><-----timestamp-----><--value-->\n<--- metric name---><--------labels------------><-----timestamp-----><--value-->\nhttp_request_total{status=\"200\", method=\"GET\"}@1434417560938 => 94355\nhttp_request_total{status=\"200\", method=\"GET\"}@1434417561287 => 94334\nhttp_request_total{status=\"200\", method=\"POST\"}@1434417561287 => 93656<\/code><\/pre>\n<\/div>\n

\u5f53\u6211\u4eec\u6839\u636e\u65f6\u95f4\u987a\u5e8f\uff0c\u628a\u6837\u672c\u6570\u636e\u7edf\u4e00\u653e\u5728\u4e00\u8d77\uff0c\u5c31\u53ef\u4ee5\u5f62\u6210\u4e00\u6761\u76d1\u63a7\u66f2\u7ebf\uff0c\u5982\u4e0b
\n
\n\u8fd9\u6837\u7684\u7279\u5b9a\u7684metric\u3001timestamp\u3001value\u6784\u6210\u7684\u65f6\u95f4\u5e8f\u5217(TimeSeries) \u5728Prometheus\u4e2d\u88ab\u79f0\u4f5cSeries\u3002
\n\u6240\u4ee5\u6211\u4eec\u603b\u7ed3\u4ee5\u4e0a\u51e0\u4e2a\u6982\u5ff5\uff1a<\/p>\n

\n

Metric names \u6307\u6807\u540d\u79f0
\n labels \u6307\u6807\u6807\u7b7e\uff0c\u4e0e\u6307\u6807\u540d\u79f0\u4e00\u540c\u6784\u6210\u552f\u4e00\u6807\u8bc6\u9879
\n Samples \u4e00\u4e2a\u65f6\u95f4\u70b9\u7684 Metric names\uff0clabels\uff0c\u6837\u672c\u503c(value)\uff0c
\n Series \u7531\u5f88\u591a\u76f8\u5173\u7684samples\u7ec4\u6210\u7684\u65f6\u95f4\u5e8f\u5217<\/p>\n<\/blockquote>\n

TIPS\uff1a\u65f6\u95f4\u5e8f\u5217 (Time Series) \u6307\u7684\u662f\u67d0\u4e2a\u6307\u6807\u968f\u65f6\u95f4\u53d8\u5316\u7684\u6240\u6709\u5386\u53f2\u6570\u636e\uff0c\u800c\u6837\u672c (Sample) \u6307\u7684\u662f\u5386\u53f2\u6570\u636e\u4e2d\u8be5\u53d8\u91cf\u7684\u77ac\u65f6\u503c\u3002
\n\u5f53\u6211\u4eec\u6709\u5f88\u591a\u7684Series\uff0c\u5c31\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u793a\u610f\u56fe\u8868\u793a\u4e86\uff0c\u56fe\u4e0a\u6bcf\u4e00\u4e2a\u70b9\u90fd\u662f\u4e00\u4e2aSample\u3002
\n<\/p>\n

\u4e09\u3001Prometheus\u4e2dSamples\u548cSeries\u7684\u76d1\u63a7<\/h2>\n

\u7406\u89e3\u4e86Samples\u548cSeries\uff0c\u6211\u4eec\u6765\u770b\u4e0bPrometheus\u81ea\u8eab\u7684\u76d1\u63a7\u6570\u636e<\/p>\n

<\/p>\n

\n
rate(prometheus_tsdb_head_samples_appended_total{instance=\"localhost:9090\"}[5m])<\/code><\/pre>\n<\/div>\n

Prometheus\u6bcf\u79d2\u949f\u6536\u5230\u7684Samples\u6570\u91cf\uff0c\u6b64\u503c\u7684\u5927\u5c0f\u53cd\u6620\u4e86Prometheus\u7684\u5f53\u524d\u7684\u7e41\u5fd9\u7a0b\u5ea6\uff0c\u7c7b\u4f3c\u4e8ezabbix\u4e2d\u7684new value per second \uff0c\u5f53\u6b64\u503c\u8d85\u8fc710\u4e07\uff0c\u53ef\u4ee5\u8003\u8651\u8fdb\u884c\u5206\u7247\u62c6\u5206\u4ee5\u51cf\u8f7b\u538b\u529b\u3002<\/p>\n

\n
prometheus_tsdb_head_series{instance=\"localhost:9090\",job=\"prometheus\"}<\/code><\/pre>\n<\/div>\n

Prometheus\u5185\u5b58\u4e2d\u6700\u65b0\u7684\u4e00\u6b21\u7684series\u6570\u91cf\uff0c\u6b64\u503c\u53cd\u5e94\u7684Prometheus\u5f53\u524d\u6536\u5230\u7684\u76d1\u63a7\u5bf9\u8c61Series\uff08\u4e5f\u53ef\u4ee5\u76f4\u63a5\u7406\u89e3\u4e3a\u65f6\u95f4\u5e8f\u5217\uff09\u6570\u91cf\u3002<\/p>\n

\u8fd9\u91cc\u6211\u4eec\u7ed9\u51fa\u67e5\u8be2\u6240\u6709\u65f6\u95f4\u5e8f\u5217\u7684\u65b9\u6cd5\uff1a<\/p>\n

\n
#\u67e5\u8be2\u6240\u6709\u65f6\u95f4\u5e8f\u5217Series\n{__name__=~\".+\"}\n#\u7edf\u8ba1\u6240\u6709\u65f6\u95f4\u5e8f\u5217Series\u7684\u6570\u91cf\ncount({__name__=~\".+\"})<\/code><\/pre>\n<\/div>\n

\u56db\u3001Prometheus\u7684\u7684\u5b58\u50a8\u673a\u5236<\/h2>\n

4.1 \u5b58\u50a8\u6982\u89c8<\/h4>\n

Prometheus\u5c06\u6700\u8fd1\u7684\u6570\u636e\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u8fd9\u6837\u67e5\u8be2\u6700\u8fd1\u7684\u6570\u636e\u4f1a\u53d8\u5f97\u975e\u5e38\u5feb\uff0c\u7136\u540e\u901a\u8fc7\u4e00\u4e2acompactor\u5b9a\u65f6\u5c06\u6570\u636e\u6253\u5305\u5230\u78c1\u76d8\u3002\u6570\u636e\u5728\u5185\u5b58\u4e2d\u6700\u5c11\u4fdd\u75592\u4e2a\u5c0f\u65f6(storage.tsdb.min-block-duration\u3002\u81f3\u4e8e\u4e3a\u4ec0\u4e48\u8bbe\u7f6e2\u5c0f\u65f6\u8fd9\u4e2a\u503c\uff0c\u662fGorilla\u90a3\u7bc7\u8bba\u6587\u4e2d\u89c2\u5bdf\u5f97\u51fa\u7684\u7ed3\u8bba\uff0c\u5373\u538b\u7f29\u7387\u57282\u5c0f\u65f6\u65f6\u5019\u8fbe\u5230\u6700\u5927\u503c\u3002
\n\u4e3a\u4e86\u9632\u6b62\u7a0b\u5e8f\u5d29\u6e83\u5bfc\u81f4\u6570\u636e\u4e22\u5931\uff0c\u5b9e\u73b0\u4e86WAL\uff08write-ahead-log\uff09\u673a\u5236\uff0c\u542f\u52a8\u65f6\u4f1a\u4ee5\u5199\u5165\u65e5\u5fd7(WAL)\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u91cd\u64ad\uff0c\u4ece\u800c\u6062\u590d\u6570\u636e\u3002<\/p>\n

<\/p>\n

\u5728\u4e0a\u56fe\u4e2d\uff0cHeadBlock\u662f\u6570\u636e\u5e93\u7684\u5185\u5b58\u90e8\u5206\uff0c\u7070\u8272\u5757\u662f\u5b58\u5728\u78c1\u76d8\u4e0a\u7684\u4e0d\u53ef\u66f4\u6539\u7684\u6301\u4e45\u5757Block\u3002 \u6211\u4eec\u6709\u4e00\u4e2a\u9884\u5199\u65e5\u5fd7\uff08WAL\uff09\u7528\u4e8e\u6301\u4e45\u5199\u5165\u3002 \u4f20\u5165\u7684\u6837\u672c\uff08\u7c89\u7ea2\u8272\u65b9\u6846\uff09\u9996\u5148\u8fdb\u5165HeadBlock\u5e76\u5728\u5185\u5b58\u4e2d\u505c\u7559\u4e00\u4f1a\u513f\uff0c\u7136\u540e\u5237\u65b0\u5230\u78c1\u76d8\u5e76\u6620\u5c04\u5230\u5185\u5b58\uff08\u84dd\u8272\u7684\u65b9\u6846\uff09\u3002\u5f53\u8fd9\u4e9b\u5185\u5b58\u6620\u5c04 chunks \u6216\u5185\u5b58\u4e2d\u7684 chunks \u53d8\u65e7\u5230\u4e00\u5b9a\u7a0b\u5ea6\u65f6\uff0c\u5b83\u4eec\u5c06\u4f5c\u4e3a\u6301\u4e45\u5757Block\u5237\u65b0\u5230\u78c1\u76d8\u3002 <\/p>\n

4.2 \u6570\u636e\u5757chunk<\/h4>\n

\u8bfb\u5230\u8fd9\u91cc\uff0c\u5927\u5bb6\u80af\u5b9a\u4f1a\u6709\u4e00\u4e2a\u7591\u60d1\uff1fBlock\u8fd8\u53ef\u4ee5\u7406\u89e3\uff0c\u6bcf\u4e24\u4e2a\u5c0f\u65f6\u6570\u636e\u5207\u4e00\u4e2a\u5757\uff0c\u5c31\u662f\u4e00\u4e2aBlock\uff0cchunk\u8fd9\u4e2a\u6982\u5ff5\u662f\u54ea\u91cc\u6765\u7684\uff1f<\/p>\n

\u5728Prometheus\u5185\u90e8\uff0cchunk\u662f\u7528\u6765\u5b58\u50a8\u538b\u7f29\u540e\u7684\u6837\u672csample\u6570\u636e\u7684\u6700\u5c0f\u5355\u4f4d\u3002chunk\u7684\u5927\u5c0f1KB\uff0c\u6bcf\u4e2achunk\u53ef\u4ee5\u5b58\u50a8\u6700\u591a120\u4e2a\u6837\u672c\uff0c\u5f53chunk\u5b58\u6ee1120\u4e2a\u6837\u672c\u6216\u8d85\u8fc7\u4e86chunkRange\u7684\u65f6\u95f4\u8303\u56f4\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e3a 2h\uff09\uff0c\u5c31\u4f1a\u5199\u5230\u65b0\u7684chunk\u91cc\u3002
\n<\/p>\n

\u5982\u4e0a\u56fe\uff0c\u6bcf\u4e00\u4e2aSeries\u7684\u6837\u672c\u6570\u636e\uff0c\u7531\u591a\u4e2achunk\u6765\u8fdb\u884c\u5b58\u50a8\uff0c\u6309\u7167\u4e0a\u9762\u6240\u8bf4\u7684\u5b58\u6ee1120\u4e2a\u6216\u8005\u8d85\u8fc7chunkRange\u65f6\u95f4\uff0c\u5c31\u4f1a\u5199\u5230\u65b0\u7684\u91cc\u9762\u3002<\/p>\n

chunk\u5b58\u50a8\u7684\u662f\u7ecf\u8fc7\u538b\u7f29\u540e\u7684sample\u6570\u636e\uff0c\u538b\u7f29\u7684\u65b9\u6cd5\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u56fe\u7247\u5c55\u793a\u7684\uff0c\u4f7f\u7528\u6570\u636e\u53d8\u5316\u6765\u5b58\u50a8\uff0c\u7ecf\u8fc7\u538b\u7f29\u4ee5\u540e\u6bcf\u4e2asample\u5927\u7ea6\u5360\u75281.3-1.8\u5b57\u8282\u5927\u5c0f\u3002
\n
\n\u8fd9\u91cc\u8fd8\u6709\u4e00\u4e2a\u77e5\u8bc6\u70b9\u8981\u8bf4\u4e0b\uff0cchunk\u5199\u6ee1\u4ee5\u540e\uff0cPrometheus\u4f1a\u5b58\u5165\u5230\u78c1\u76d8\uff0c\u5e76\u4f7f\u7528MMAP\u505a\u6620\u5c04\u5173\u7cfb\uff0c\u6765\u8282\u7701\u5185\u5b58\u7684\u6d88\u8017\u3002\u5982\u4e0b\u3002
\n<\/p>\n

4.3 \u78c1\u76d8\u5b58\u50a8\u7ed3\u6784<\/h4>\n

Prometheus\u78c1\u76d8\u5b58\u50a8\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c
\n<\/p>\n

\u5728\u78c1\u76d8\u4e2d\u6bcf\u4e00\u4e2a\u5757(Block)\u53c8\u5206\u4e3a<\/p>\n

\n

chunk\u5b58\u50a8\u76ee\u5f55\uff0c\u91cc\u9762\u7684chunk\u6587\u4ef6(chunk\u6587\u4ef6\u6700\u5927512M)\u5b58\u50a8\u4e86\u5177\u4f53\u7684\u76d1\u63a7\u6570\u636e
\n index \u7d22\u5f15\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u76d1\u63a7\u6307\u6807\u5bf9\u5e94\u7684\u76d1\u63a7\u503c\uff0c
\n \u5143\u6570\u636e\u6587\u4ef6(meta.json)\u6807\u8bc6\u4e86\u4e00\u4e9b\u57fa\u672c\u4fe1\u606f\uff0c
\n tombstones \u6807\u8bc6\u4e86\u4e00\u4e9b\u5220\u9664\u6587\u4ef6\u3002
\n \u6211\u4eec\u770b\u4e00\u4e2ameta.json\u4fe1\u606f<\/p>\n<\/blockquote>\n

\n
{\n    \"ulid\": \"01FDG3DA4W3X7A107X4TQ5NM27\",\n    \"minTime\": 1629396000000,\n    \"maxTime\": 1629403200000,\n    \"stats\": {\n        \"numSamples\": 145786877,\n        \"numSeries\": 516895,\n        \"numChunks\": 1218908\n    },\n    \"compaction\": {\n        \"level\": 1,\n        \"sources\": [\n            \"01FDG3DA4W3X7A107X4TQ5NM27\"\n        ]\n    },\n    \"version\": 1\n}<\/code><\/pre>\n<\/div>\n

Prometheus\u9ed8\u8ba4\u4f1a\u5bf9\u65e7\u7684Block\u6570\u636e\u8fdb\u884c\u5408\u5e76\u548c\u538b\u7f29\uff0c\u4ee5\u51cf\u5c11\u6587\u4ef6\u7684\u6570\u91cf\uff0c\u4f46\u662f\u5b98\u65b9\u4ecd\u7136\u4e0d\u5efa\u8bae\u5b58\u50a8\u8fc7\u957f\u65f6\u95f4\u7684\u6570\u636e\u3002\u6211\u4eec\u66fe\u7ecf\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u5b58\u50a8\u4e863T\u5de6\u53f3\u7684\u5927\u7ea61\u5e74\u7684\u76d1\u63a7\u6570\u636e\uff0c\u5e76\u6ca1\u6709\u53d1\u73b0\u4ec0\u4e48\u95ee\u9898\uff0c\u4f46\u662f\u91cd\u542fprometheus\u5b9e\u4f8b\u52a0\u8f7d\u5386\u53f2\u6570\u636e\uff08\u5e76\u975eWAL\u6570\u636e\uff09\u9700\u8981\u5c06\u8fd130-50\u5206\u949f\uff0c\u8ba9\u6211\u4eec\u65e0\u6cd5\u63a5\u53d7\uff0c\u6700\u540e\u6211\u4eec\u8fd8\u662f\u6295\u5165\u4e86Thanos\u7684\u6000\u62b1\uff0c\u5c06\u76d1\u63a7\u6570\u636e\u5b58\u5728\u963f\u91cc\u4e91OSS\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002<\/p>\n

\u4e94\u3001Prometheus\u4e2dChunk\u548cBlock\u7684\u76d1\u63a7<\/h2>\n
\n
# HELP prometheus_tsdb_blocks_loaded Number of currently loaded data blocks\n# TYPE prometheus_tsdb_blocks_loaded gauge\nprometheus_tsdb_blocks_loaded 85\n#\u88abPrometheus\u7ba1\u7406\u7684Block\u6570\u91cf\uff0c\u7f51\u4e0a\u6709\u89e3\u91ca\u6210\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u7684\u5757\u6570\u91cf\uff0c\u662f\u9519\u8bef\u7684\uff0c\u53ea\u6709HeadBlock\u5728\u5185\u5b58\u4e2d\u3002\n# HELP prometheus_tsdb_storage_blocks_bytes The number of bytes that are currently used for local storage by all blocks.\n# TYPE prometheus_tsdb_storage_blocks_bytes gauge\nprometheus_tsdb_storage_blocks_bytes 2.9467243543e+10\n#\u6240\u6709Block\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\uff0c\u7531\u4e8eWAL\u8f83\u5c0f\uff0c\u6b64\u503c\u53ef\u4ee5\u7b49\u4ef7\u4e8ePrometheus\u78c1\u76d8\u4f7f\u7528\u7a7a\u95f4\n# HELP prometheus_tsdb_head_chunks Total number of chunks in the head block.\n# TYPE prometheus_tsdb_head_chunks gauge\nprometheus_tsdb_head_chunks 1.128714e+06\n#\u5185\u5b58\u4e2dchunk\u6570\u91cf<\/code><\/pre>\n<\/div>\n

\u516d\u3001Prometheus\u5bb9\u91cf\u89c4\u5212<\/h2>\n

6.1 \u78c1\u76d8\u5bb9\u91cf\u89c4\u5212<\/h4>\n

\u901a\u8fc7\u5bf9Prometheus\u4f7f\u7528\u78c1\u76d8\u76ee\u5f55\u7684\u5206\u6790\uff0c\u6211\u4eec\u53d1\u73b0\uff0c\u6bcf\u4e2aBlock\u5360\u7528\u78c1\u76d8\u7a7a\u95f4\u4e3b\u8981\u6709\u4e09\u90e8\u5206\uff1a<\/p>\n

\n

Chunk\u6570\u636e \uff0c241M
\n index\u6570\u636e\uff0c87M
\n WAL\u6570\u636e\uff0c3913M<\/p>\n<\/blockquote>\n

\u7531\u4e8ePrometheus\u6bcf2\u5c0f\u65f6\u751f\u6210\u4e00\u4e2aBlock\uff0c\u6211\u4eec\u5148\u8ba1\u7b97\u4e0b\u6bcf\u4e2aBlock\u5927\u5c0f\uff0c\u6bcf\u4e2aBlock\u6709\u4e3b\u8981\u7531Chunk\u6570\u636e\uff0cindex\u6570\u636e\u6784\u6210\uff0c\u6211\u4eec\u6839\u636e\u4ee5\u524d\u5386\u53f2\u6570\u636e\uff0c\u5f97\u51faindex\u6570\u636e\u91cf\u6bd4chunk\u603b\u6570\u636e\u91cf\u6bd4\u4f8b\u662f 35:100\u3002
\n\u7136\u540e\u6211\u4eec\u67e5\u8be2Prometheus\u5f97\u51fa\uff0c2\u5c0f\u65f6\u5185\u65b0\u589esample\u6570\u91cf\uff0c\u6211\u5f97\u5230\u7ed3\u679c\u662f145394292\u3002<\/p>\n

\n
increase(prometheus_tsdb_head_samples_appended_total[2h])<\/code><\/pre>\n<\/div>\n

sample\u5e73\u5747\u5927\u5c0f, \u5f97\u5230\u7ed3\u679c\u7ea6\u4e3a1.8 Bytes<\/p>\n

\n
  rate(prometheus_tsdb_compaction_chunk_size_bytes_sum[1d])\n\/\n  rate(prometheus_tsdb_compaction_chunk_samples_sum[1d])<\/code><\/pre>\n<\/div>\n

chunk\u6570\u636e\u5360\u7528\u5b58\u50a8\u7a7a\u95f4=\u4e24\u5c0f\u65f6\u5185\u65b0\u589esample\u6570\u91cf * \u6bcf\u4e2asample\u5e73\u5747\u5927\u5c0f = 145394292 * 1.8 = 261M
\nindex\u6570\u636e\u5b58\u50a8\u7a7a\u95f4 = chunk\u6570\u636e\u5360\u7528\u5b58\u50a8\u7a7a\u95f4* 35% = 91M
\n\u603b\u78c1\u76d8\u5360\u7528\u91cf= \uff08chunk\u6570\u636e\u5360\u7528\u5b58\u50a8\u7a7a\u95f4 + index\u6570\u636e\u5b58\u50a8\u7a7a\u95f4\uff09*Block\u6570\u91cf + WAL\u78c1\u76d8\u5b58\u50a8\u7a7a\u95f4\uff08\u5386\u53f2\u6570\u636e\uff09<\/p>\n

6.2 \u5185\u5b58\u5bb9\u91cf\u89c4\u5212<\/h4>\n

https:\/\/www.jianshu.com\/p\/93412a925da2<\/a>
\n\u5c3d\u7ba1\u6211\u4eec\u6709\u4e00\u4e9b\u5de5\u5177\u53ef\u4ee5\u6d4b\u7b97\u51fa\u5185\u5b58\u5360\u7528\u60c5\u51b5\uff0c\u4f8b\u5982
\n
https:\/\/www.robustperception.io\/how-much-ram-does-prometheus-2-x-need-for-cardinality-and-ingestion<\/a>
\n\u4f46\u662f\uff0c\u5b9e\u9645\u60c5\u51b5\u662f\u6211\u4eec\u4ec5\u80fd\u591f\u6d4b\u7b97\u51fa<\/p>\n

\n
go tool pprof -symbolize=remote -inuse_space http:\/\/172.28.9.46:9090\/debug\/pprof\/heap<\/code><\/pre>\n<\/div>\n

\u53c2\u8003\u8d44\u6599<\/h2>\n

(\u524d3\u4e2a\u662f\u5b98\u65b9\u4f5c\u8005\u6587\u7ae0)
\n
https:\/\/prometheus.io\/docs\/concepts\/data_model\/<\/a>
\n
https:\/\/ganeshvernekar.com\/blog\/prometheus-tsdb-the-head-block<\/a>
\n
https:\/\/www.youtube.com\/watch?v=b_pEevMAC3I<\/a>
\n
https:\/\/yunlzheng.gitbook.io\/prometheus-book\/parti-prometheus-ji-chu\/promql\/what-is-prometheus-metrics-and-labels<\/a>
\n
https:\/\/zhuanlan.zhihu.com\/p\/353670507<\/a>
\n
https:\/\/www.cnblogs.com\/vovlie\/p\/7709312.html<\/a><\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » prometheus\u6570\u636e\u6a21\u578b\u548c\u5b58\u50a8\u673a\u5236<\/a><\/p>","protected":false},"excerpt":{"rendered":"

\u4e00\u3001\u6982\u8ff0 \u672c\u6587\u6574\u7406\u4e86Prometheus\u7684\u4e00\u4e9b\u6570\u636e\u6a21\u578b\u548c\u5b58\u50a8\u673a\u5236\uff0c\u6d89\u53ca\u5230metric names\uff0clabels\uff0csamples\uff0cSeries\uff0cChunk\u3001HeadChunk\u3001Block\u7b49\u6982\u5ff5\u3002 \u5bf9\u4e8e\u7406\u89e3Prometheus\u8fd0\u884c\u673a\u5236\uff0c\u7406\u89e3\u5e38\u89c1\u7684Prometheus\u76d1\u63a7\u6307\u6807\u6709\u4e00\u5b9a\u5e2e\u52a9\u3002 \u672c\u6587\u8d44\u6599\u5168\u90e8\u6765\u6e90\u4e8e\u5176\u4ed6\u7f51\u7ad9\uff0c\u82e5\u6709\u9519\u8bef\uff0c\u8bf7\u5927\u5bb6\u6307\u51fa\u3002 \u4e8c\u3001\u6570\u636e\u6a21\u578b DataModel Prometheus \u7684\u76d1\u63a7\u6570\u636e\u4ee5\u6307\u6807\uff08metric\uff09\u7684\u5f62\u5f0f\u4fdd\u5b58\u5728\u5185\u7f6e\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u5e93\uff08TSDB\uff09\u5f53\u4e2d\u3002 \u6307\u6807\u540d\u79f0\u548c\u6807\u7b7e(metric names, labels) \u6bcf\u4e00\u6761\u65f6\u95f4\u5e8f\u5217\u7531\u6307\u6807\u540d\u79f0\uff08Metrics Name\uff09\u4ee5\u53ca\u4e00\u7ec4\u6807\u7b7elabels\uff08\u952e\u503cKV\u5bf9\uff09\u552f\u4e00\u6807\u8bc6\u3002 TIPS: \u6539\u53d8\u6807\u7b7e\u4e2d\u7684K\u6216\u8005V\u503c\uff08\u5305\u62ec\u6dfb\u52a0\u6216\u5220\u9664\uff09\uff0c\u90fd\u4f1a\u521b\u5efa\u65b0\u7684\u65f6\u95f4\u5e8f\u5217\u3002 \u6837\u672cSamples \u5728\u65f6\u95f4\u5e8f\u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a\u70b9\u79f0\u4e3a\u4e00\u4e2a\u6837\u672c\uff08sample\uff09\uff0c\u6837\u672c\u7531\u4ee5\u4e0b\u4e09\u90e8\u5206\u7ec4\u6210\uff1a \u6307\u6807\uff08metric\uff09\uff1a\u6307\u6807\u540d\u79f0Metric names\u548c\u6807\u7b7elabels\uff1b \u65f6\u95f4\u6233\uff08timestamp\uff09\uff1a\u4e00\u4e2a\u7cbe\u786e\u5230\u6beb\u79d2\u7684\u65f6\u95f4\u6233\uff1b \u6837\u672c\u503c\uff08value\uff09\uff1a \u4e00\u4e2a folat64 \u7684\u6d6e\u70b9\u578b\u6570\u636e\u8868\u793a\u5f53\u524d\u6837\u672c\u7684\u503c\u3002 \u5982\u4e0b\u5c31\u662f\u4e09\u4e2a\u6837\u672c\u6570\u636e\uff0c\u5f88\u597d\u7684\u89e3\u91ca\u4e86\u8fd9\u51e0\u4e2a\u540d\u8bcd\u7684\u5206\u5e03 <——————– metric ——————><—–timestamp—–><–value–> <— metric name—><——–labels————><—–timestamp—–><–value–> http_request_total{status=”200″, method=”GET”}@1434417560938 => 94355 http_request_total{status=”200″, method=”GET”}@1434417561287 => 94334 http_request_total{status=”200″, method=”POST”}@1434417561287 => 93656 \u5f53\u6211\u4eec\u6839\u636e\u65f6\u95f4\u987a\u5e8f\uff0c\u628a\u6837\u672c\u6570\u636e\u7edf\u4e00\u653e\u5728\u4e00\u8d77\uff0c\u5c31\u53ef\u4ee5\u5f62\u6210\u4e00\u6761\u76d1\u63a7\u66f2\u7ebf\uff0c\u5982\u4e0b \u8fd9\u6837\u7684\u7279\u5b9a\u7684metric\u3001timestamp\u3001value\u6784\u6210\u7684\u65f6\u95f4\u5e8f\u5217(TimeSeries) \u5728Prometheus\u4e2d\u88ab\u79f0\u4f5cSeries\u3002 \u6240\u4ee5\u6211\u4eec\u603b\u7ed3\u4ee5\u4e0a\u51e0\u4e2a\u6982\u5ff5\uff1a Metric names \u6307\u6807\u540d\u79f0 labels \u6307\u6807\u6807\u7b7e\uff0c\u4e0e\u6307\u6807\u540d\u79f0\u4e00\u540c\u6784\u6210\u552f\u4e00\u6807\u8bc6\u9879 Samples \u4e00\u4e2a\u65f6\u95f4\u70b9\u7684 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[190],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1552"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1552"}],"version-history":[{"count":1,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1552\/revisions"}],"predecessor-version":[{"id":1553,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1552\/revisions\/1553"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}