{"id":38453,"date":"2025-04-24T01:57:11","date_gmt":"2025-04-23T17:57:11","guid":{"rendered":"https:\/\/www.yunshan.net\/blog\/?p=38453"},"modified":"2025-04-24T01:57:11","modified_gmt":"2025-04-23T17:57:11","slug":"prometheus%e7%9a%84%e7%9b%91%e6%8e%a7%e6%95%b0%e6%8d%ae%e5%ad%98%e5%82%a8%e5%92%8c%e6%8c%81%e4%b9%85%e5%8c%96%e7%ad%96%e7%95%a5%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/www.yunshan.net\/blog\/archives\/38453.html","title":{"rendered":"Prometheus\u7684\u76d1\u63a7\u6570\u636e\u5b58\u50a8\u548c\u6301\u4e45\u5316\u7b56\u7565\u662f\u4ec0\u4e48"},"content":{"rendered":"<p style=\"text-align: center;\">\n<p><img decoding=\"async\" src=\"https:\/\/www.yunshan.net\/blog\/wp-content\/uploads\/2025\/04\/gT86wiE3Y.png\" alt=\"Prometheus\u7684\u76d1\u63a7\u6570\u636e\u5b58\u50a8\u548c\u6301\u4e45\u5316\u7b56\u7565\u662f\u4ec0\u4e48\" ><\/p>\n<\/p>\n<p>Prometheus 2.x \u9ed8\u8ba4\u5c06\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u5e93\u4fdd\u5b58\u5728\u672c\u5730\u78c1\u76d8\u4e2d\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u5c06\u6570\u636e\u4fdd\u5b58\u5230\u4efb\u610f\u7b2c\u4e09\u65b9\u7684\u5b58\u50a8\u670d\u52a1\u4e2d\u3002<\/p>\n<h2>\u672c\u5730\u5b58\u50a8<\/h2>\n<p>Prometheus \u91c7\u7528\u81ea\u5b9a\u4e49\u7684\u5b58\u50a8\u683c\u5f0f\u5c06\u6837\u672c\u6570\u636e\u4fdd\u5b58\u5728\u672c\u5730\u78c1\u76d8\u5f53\u4e2d\u3002<\/p>\n<p>1. <strong>\u5b58\u50a8\u683c\u5f0f<\/strong><\/p>\n<li>Prometheus \u6309\u7167\u4e24\u4e2a\u5c0f\u65f6\u4e3a\u4e00\u4e2a\u65f6\u95f4\u7a97\u53e3\uff0c\u5c06\u4e24\u5c0f\u65f6\u5185\u4ea7\u751f\u7684\u6570\u636e\u5b58\u50a8\u5728\u4e00\u4e2a\u5757\uff08Block\uff09\u4e2d\u3002\u6bcf\u4e2a\u5757\u90fd\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u76ee\u5f55\uff0c\u91cc\u9762\u5305\u542b\u8be5\u65f6\u95f4\u7a97\u53e3\u5185\u7684\u6240\u6709\u6837\u672c\u6570\u636e\uff08chunks\uff09\u3001\u5143\u6570\u636e\u6587\u4ef6\uff08meta.json\uff09\u4ee5\u53ca\u7d22\u5f15\u6587\u4ef6\uff08index\uff09\u3002\u5176\u4e2d\u7d22\u5f15\u6587\u4ef6\u4f1a\u5c06\u6307\u6807\u540d\u79f0\u548c\u6807\u7b7e\u7d22\u5f15\u5230\u6837\u677f\u6570\u636e\u7684\u65f6\u95f4\u5e8f\u5217\u4e2d\u3002\u6b64\u671f\u95f4\u5982\u679c\u901a\u8fc7 API \u5220\u9664\u65f6\u95f4\u5e8f\u5217\uff0c\u5220\u9664\u8bb0\u5f55\u4f1a\u4fdd\u5b58\u5728\u5355\u72ec\u7684\u903b\u8f91\u6587\u4ef6 tombstone \u5f53\u4e2d\u3002<\/li>\n<li>\u5f53\u524d\u6837\u672c\u6570\u636e\u6240\u5728\u7684\u5757\u4f1a\u88ab\u76f4\u63a5\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u4e0d\u4f1a\u6301\u4e45\u5316\u5230\u78c1\u76d8\u4e2d\u3002\u4e3a\u4e86\u786e\u4fdd Prometheus \u53d1\u751f\u5d29\u6e83\u6216\u91cd\u542f\u65f6\u80fd\u591f\u6062\u590d\u6570\u636e\uff0cPrometheus \u542f\u52a8\u65f6\u4f1a\u901a\u8fc7\u9884\u5199\u65e5\u5fd7\uff08write\n<li>ahead &#8211; log(WAL)\uff09\u91cd\u65b0\u8bb0\u5f55\uff0c\u4ece\u800c\u6062\u590d\u6570\u636e\u3002\u9884\u5199\u65e5\u5fd7\u6587\u4ef6\u4fdd\u5b58\u5728 wal \u76ee\u5f55\u4e2d\uff0c\u6bcf\u4e2a\u6587\u4ef6\u5927\u5c0f\u4e3a 128MB\u3002wal \u6587\u4ef6\u5305\u62ec\u8fd8\u6ca1\u6709\u88ab\u538b\u7f29\u7684\u539f\u59cb\u6570\u636e\uff0c\u6240\u4ee5\u6bd4\u5e38\u89c4\u7684\u5757\u6587\u4ef6\u5927\u5f97\u591a\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0cPrometheus \u4f1a\u4fdd\u7559\u4e09\u4e2a wal \u6587\u4ef6\uff0c\u4f46\u5982\u679c\u6709\u4e9b\u9ad8\u8d1f\u8f7d\u670d\u52a1\u5668\u9700\u8981\u4fdd\u5b58\u4e24\u4e2a\u5c0f\u65f6\u4ee5\u4e0a\u7684\u539f\u59cb\u6570\u636e\uff0cwal \u6587\u4ef6\u7684\u6570\u91cf\u5c31\u4f1a\u5927\u4e8e 3 \u4e2a\u3002<\/li>\n<\/li>\n<li>Prometheus \u4fdd\u5b58\u5757\u6570\u636e\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\u6240\u793a\uff1a<\/li>\n<p>\/data<\/p>\n<li>01BKGV7JBM69T2G1BGBGM6KB12  \u5757<\/li>\n<li>meta.json  \u5143\u6570\u636e<\/li>\n<li>wal  \u5199\u5165\u65e5\u5fd7<\/li>\n<li>000002<\/li>\n<li>000001<\/li>\n<li>01BKGTZQ1SYQJTR4PB43C8PD98  \u5757<\/li>\n<li>meta.json \u5143\u6570\u636e<\/li>\n<li>index  \u7d22\u5f15\u6587\u4ef6<\/li>\n<li>chunks  \u6837\u672c\u6570\u636e<\/li>\n<li>000001<\/li>\n<li>tombstones  \u903b\u8f91\u6570\u636e<\/li>\n<li>01BKGTZQ1HHWHV8FBJXW1Y3W0K<\/li>\n<li>meta.json<\/li>\n<li>wal<\/li>\n<p>|-000001<\/p>\n<li>\u6700\u521d\u4e24\u4e2a\u5c0f\u65f6\u7684\u5757\u6700\u7ec8\u4f1a\u5728\u540e\u53f0\u88ab\u538b\u7f29\u6210\u66f4\u957f\u7684\u5757\u3002<\/li>\n<p>2. <strong>\u672c\u5730\u5b58\u50a8\u914d\u7f6e<\/strong><\/p>\n<li>Prometheus \u63d0\u4f9b\u4e86\u51e0\u4e2a\u53c2\u6570\u6765\u4fee\u6539\u672c\u5730\u5b58\u50a8\u7684\u914d\u7f6e\uff0c\u6700\u4e3b\u8981\u7684\u6709\uff1a<\/li>\n<li>`&#8211;storage.tsdb.path`\uff1a\u6570\u636e\u5b58\u50a8\u8def\u5f84\uff0c\u9ed8\u8ba4\u4e3a`\/data`\u3002<\/li>\n<li>`&#8211;storage.tsdb.retention.time`\uff1a\u6837\u672c\u6570\u636e\u5728\u5b58\u50a8\u4e2d\u4fdd\u5b58\u7684\u65f6\u95f4\uff0c\u8d85\u8fc7\u8be5\u65f6\u95f4\u9650\u5236\u7684\u6570\u636e\u5c31\u4f1a\u88ab\u5220\u9664\uff0c\u9ed8\u8ba4\u4e3a15\u5929\u3002<\/li>\n<li>`&#8211;storage.tsdb.retention.size`\uff1a\u6bcf\u4e2a\u5757\u7684\u6700\u5927\u5b57\u8282\u6570\uff08\u4e0d\u5305\u62ec wal \u6587\u4ef6\uff09\u3002\u5982\u679c\u8d85\u8fc7\u9650\u5236\uff0c\u6700\u65e9\u7684\u6837\u672c\u6570\u636e\u4f1a\u88ab\u4f18\u5148\u5220\u9664\u3002\u652f\u6301\u7684\u5355\u4f4d\u6709 KB, MB, GB, PB\uff0c\u4f8b\u5982\uff1a\u201c512MB\u201d\u3002\u8be5\u53c2\u6570\u53ea\u662f\u8bd5\u9a8c\u6027\u7684\uff0c\u53ef\u80fd\u4f1a\u5728\u672a\u6765\u7684\u7248\u672c\u4e2d\u88ab\u79fb\u9664\u3002<\/li>\n<h2>\u76d1\u63a7\u6570\u636e\u6301\u4e45\u5316\u7b56\u7565<\/h2>\n<p>Prometheus \u7684\u6570\u636e\u6301\u4e45\u5316\u7b56\u7565\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n<p>1. <strong>\u672c\u5730\u5b58\u50a8<\/strong><\/p>\n<li>\u6570\u636e\u4ee5\u65f6\u95f4\u5e8f\u5217\u7684\u5f62\u5f0f\u5b58\u50a8\u5728\u672c\u5730\u78c1\u76d8\u4e2d\uff0c\u6bcf\u4e2a\u65f6\u95f4\u5e8f\u5217\u7531\u4e00\u4e2a\u6307\u6807\u540d\u79f0\u548c\u4e00\u7ec4\u6807\u7b7e\u7ec4\u6210\u3002\u6570\u636e\u7684\u5b58\u50a8\u683c\u5f0f\u662f\u9ad8\u6548\u7684\uff0c\u5e76\u4e14\u652f\u6301\u5feb\u901f\u67e5\u8be2\u548c\u68c0\u7d22\u3002<\/li>\n<li>\u672c\u5730\u5b58\u50a8\u4e0d\u53ef\u590d\u5236\uff0c\u65e0\u6cd5\u6784\u5efa\u96c6\u7fa4\uff0c\u5982\u679c\u672c\u5730\u78c1\u76d8\u6216\u8282\u70b9\u51fa\u73b0\u6545\u969c\uff0c\u5b58\u50a8\u5c06\u65e0\u6cd5\u6269\u5c55\u548c\u8fc1\u79fb\u3002\u56e0\u6b64\u672c\u5730\u5b58\u50a8\u53ef\u89c6\u4e3a\u8fd1\u671f\u6570\u636e\u7684\u77ed\u6682\u6ed1\u52a8\u7a97\u53e3\u3002\u5982\u679c\u5bf9\u6570\u636e\u6301\u4e45\u5316\u8981\u6c42\u4e0d\u662f\u5f88\u4e25\u683c\uff0c\u53ef\u4ee5\u4f7f\u7528\u672c\u5730\u78c1\u76d8\u5b58\u50a8\u591a\u8fbe\u6570\u5e74\u7684\u6570\u636e\u3002<\/li>\n<p>2. <strong>\u8fdc\u7a0b\u5b58\u50a8<\/strong><\/p>\n<li>Prometheus \u5f00\u653e\u4e86\u8fdc\u7a0b\u5199\u5165\u534f\u8bae\u63a5\u53e3\uff0c\u53ef\u4ee5\u5c06\u62a5\u544a\u7684\u6307\u6807\u6570\u636e\u63a8\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u4ee5\u8fdb\u884c\u957f\u671f\u4fdd\u5b58\u3002\u8fdc\u7a0b\u670d\u52a1\u5668\u8d1f\u8d23\u5b58\u50a8 Prometheus \u7684\u6240\u6709\u957f\u671f\u6570\u636e\uff0c\u5f53\u4e0b\u6e38\u7684\u6d88\u8d39\u8005\u9700\u8981\u67e5\u8be2\u6570\u636e\u6765\u751f\u6210\u62a5\u8868\u65f6\uff0c\u4e0b\u6e38\u5b58\u50a8\u670d\u52a1\u5c06\u63d0\u4f9b\u957f\u671f\u6570\u636e\u3002<\/li>\n<li>\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528 VictoriaMetrics \u4f5c\u4e3a\u8fdc\u7a0b\u5b58\u50a8\u3002VictoriaMetrics \u53ef\u901a\u8fc7\u96c6\u7fa4\u90e8\u7f72\u5b9e\u73b0\u9ad8\u53ef\u7528\uff0c\u5e76\u4e14\u652f\u6301\u4e0e Prometheus \u7684\u96c6\u6210\u3002\u5728\u914d\u7f6e Prometheus \u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7`remote_write`\u914d\u7f6e\u9879\u5c06\u6570\u636e\u5199\u5165 VictoriaMetrics\uff0c\u540c\u65f6\u5728 Grafana \u4e2d\u914d\u7f6e VictoriaMetrics \u4f5c\u4e3a\u6570\u636e\u6e90\u6765\u67e5\u8be2\u76d1\u63a7\u6570\u636e\u3002<\/li>\n<p>3. <strong>\u6570\u636e\u538b\u7f29\u548c\u8fc7\u671f\u5904\u7406<\/strong><\/p>\n<li>Prometheus \u7684\u5b58\u50a8\u4f18\u5316\u4e3b\u8981\u96c6\u4e2d\u5728\u51cf\u5c11\u78c1\u76d8\u5360\u7528\u548c\u8fc7\u671f\u6570\u636e\u5904\u7406\u3002\u6570\u636e\u4f1a\u88ab\u5b9a\u65f6\u4ece\u7f13\u5b58\u6301\u4e45\u5316\u5230\u78c1\u76d8\u4e0a\u7684\u5757\u6587\u4ef6\u4e2d\uff0c\u8fc7\u671f\u7684\u6570\u636e\u4f1a\u88ab\u5b9a\u671f\u6e05\u7406\u3002<\/li>\n<p>\u6700\u521d\u7684\u4e24\u4e2a\u5c0f\u65f6\u7684\u5757\u6700\u7ec8\u5728\u540e\u53f0\u538b\u7f29\u6210\u66f4\u957f\u7684\u5757\uff0c\u538b\u7f29\u5c06\u521b\u5efa\u66f4\u5927\u7684\u5757\uff0c\u5176\u4e2d\u5305\u542b\u8de8\u5ea6\u6700\u591a\u4e3a\u4fdd\u7559\u65f6\u95f4\u7684 10% \u6216 31 \u5929\u7684\u6570\u636e\uff0c\u4ee5\u8f83\u5c0f\u8005\u4e3a\u51c6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prometheus 2.x \u9ed8\u8ba4\u5c06\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u5e93\u4fdd\u5b58\u5728\u672c\u5730\u78c1\u76d8\u4e2d\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u5c06\u6570\u636e\u4fdd\u5b58\u5230\u4efb\u610f\u7b2c\u4e09\u65b9\u7684\u5b58\u50a8\u670d\u52a1\u4e2d\u3002 \u672c\u5730\u5b58\u50a8 Prometheus \u91c7\u7528\u81ea\u5b9a\u4e49\u7684\u5b58\u50a8\u683c\u5f0f\u5c06\u6837\u672c\u6570\u636e\u4fdd\u5b58\u5728\u672c\u5730\u78c1\u76d8\u5f53\u4e2d\u3002 1. \u5b58\u50a8\u683c\u5f0f Prometheus \u6309\u7167\u4e24\u4e2a\u5c0f\u65f6\u4e3a\u4e00\u4e2a\u65f6\u95f4\u7a97\u53e3\uff0c\u5c06\u4e24\u5c0f\u65f6\u5185\u4ea7\u751f\u7684\u6570\u636e\u5b58\u50a8\u5728\u4e00\u4e2a\u5757\uff08Block\uff09\u4e2d\u3002\u6bcf\u4e2a\u5757\u90fd\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u76ee\u5f55\uff0c\u91cc\u9762\u5305\u542b\u8be5\u65f6\u95f4\u7a97\u53e3\u5185\u7684\u6240\u6709\u6837\u672c\u6570\u636e\uff08chunks\uff09\u3001\u5143\u6570\u636e\u6587\u4ef6\uff08meta.json\uff09\u4ee5\u53ca\u7d22\u5f15\u6587\u4ef6\uff08index\uff09\u3002\u5176\u4e2d\u7d22\u5f15\u6587\u4ef6\u4f1a\u5c06\u6307\u6807\u540d\u79f0\u548c\u6807\u7b7e\u7d22\u5f15\u5230\u6837\u677f\u6570\u636e\u7684\u65f6\u95f4\u5e8f\u5217\u4e2d\u3002\u6b64\u671f\u95f4\u5982\u679c\u901a\u8fc7 API \u5220\u9664\u65f6\u95f4\u5e8f\u5217\uff0c\u5220\u9664\u8bb0\u5f55\u4f1a\u4fdd\u5b58\u5728\u5355\u72ec\u7684\u903b\u8f91\u6587\u4ef6 tombstone \u5f53\u4e2d\u3002 \u5f53\u524d\u6837\u672c\u6570\u636e\u6240\u5728\u7684\u5757\u4f1a\u88ab\u76f4\u63a5\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u4e0d\u4f1a\u6301\u4e45\u5316\u5230\u78c1\u76d8\u4e2d\u3002\u4e3a\u4e86\u786e\u4fdd Prometheus \u53d1\u751f\u5d29\u6e83\u6216\u91cd\u542f\u65f6\u80fd\u591f\u6062\u590d\u6570\u636e\uff0cPrometheus \u542f\u52a8\u65f6\u4f1a\u901a\u8fc7\u9884\u5199\u65e5\u5fd7\uff08write ahead &#8211; log(WAL)\uff09\u91cd\u65b0\u8bb0\u5f55\uff0c\u4ece\u800c\u6062\u590d\u6570\u636e\u3002\u9884\u5199\u65e5\u5fd7\u6587\u4ef6\u4fdd\u5b58\u5728 wal \u76ee\u5f55\u4e2d\uff0c\u6bcf\u4e2a\u6587\u4ef6\u5927\u5c0f\u4e3a 128MB\u3002wal \u6587\u4ef6\u5305\u62ec\u8fd8\u6ca1\u6709\u88ab\u538b\u7f29\u7684\u539f\u59cb\u6570\u636e\uff0c\u6240\u4ee5\u6bd4\u5e38\u89c4\u7684\u5757\u6587\u4ef6\u5927\u5f97\u591a\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0cPrometheus \u4f1a\u4fdd\u7559\u4e09\u4e2a wal \u6587\u4ef6\uff0c\u4f46\u5982\u679c\u6709\u4e9b\u9ad8\u8d1f\u8f7d\u670d\u52a1\u5668\u9700\u8981\u4fdd\u5b58\u4e24\u4e2a\u5c0f\u65f6\u4ee5\u4e0a\u7684\u539f\u59cb\u6570\u636e\uff0cwal \u6587\u4ef6\u7684\u6570\u91cf\u5c31\u4f1a\u5927\u4e8e 3 \u4e2a\u3002 Prometheus \u4fdd\u5b58\u5757\u6570\u636e\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\u6240\u793a\uff1a \/data 01BKGV7JBM69T2G1BGBGM6KB12 \u5757 meta.json \u5143\u6570\u636e wal \u5199\u5165\u65e5\u5fd7 000002 000001 01BKGTZQ1SYQJTR4PB43C8PD98 \u5757 meta.json \u5143\u6570\u636e index \u7d22\u5f15\u6587\u4ef6 chunks \u6837\u672c\u6570\u636e 000001 tombstones \u903b\u8f91\u6570\u636e 01BKGTZQ1HHWHV8FBJXW1Y3W0K meta.json [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-38453","post","type-post","status-publish","format-standard","hentry","category-discussion"],"_links":{"self":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/38453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/comments?post=38453"}],"version-history":[{"count":1,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/38453\/revisions"}],"predecessor-version":[{"id":38455,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/38453\/revisions\/38455"}],"wp:attachment":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media?parent=38453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/categories?post=38453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/tags?post=38453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}