{"id":1745,"date":"2025-12-29T15:19:00","date_gmt":"2025-12-29T07:19:00","guid":{"rendered":"https:\/\/eve2333.top\/?p=1745"},"modified":"2025-12-29T15:13:36","modified_gmt":"2025-12-29T07:13:36","slug":"%e5%8a%a8%e6%80%81%e7%ba%bf%e7%a8%8b%e6%b1%a0onethread%e7%b3%bb%e7%bb%9f-%e7%ac%ac%e5%8d%81%e4%b8%89%e9%83%a8%e5%88%86-prometheus%e9%85%8d%e7%bd%ae%e7%9b%91%e6%8e%a7%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/eve2333.top\/?p=1745","title":{"rendered":"\u52a8\u6001\u7ebf\u7a0b\u6c60oneThread\u7cfb\u7edf \u2014 \u7b2c\u5341\u4e09\u90e8\u5206 Prometheus\u914d\u7f6e\u76d1\u63a7\u6570\u636e\u91c7\u96c6\u548cGrafana\u770b\u677f"},"content":{"rendered":"\n<p>\u8fd9\u4efd\u6587\u6863\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5229\u7528 Prometheus \u76d1\u63a7\u7cfb\u7edf\u6765\u91c7\u96c6 <code>oneThread<\/code> \u52a8\u6001\u7ebf\u7a0b\u6c60\u6846\u67b6\u7684\u6307\u6807\u6570\u636e\u3002\u4e3a\u4e86\u8ba9\u4f60\u201c\u901a\u900f\u201d\u5730\u7406\u89e3\uff0c\u6211\u5c06\u5185\u5bb9\u62c6\u89e3\u4e3a\u4e09\u4e2a\u6838\u5fc3\u90e8\u5206\u8fdb\u884c\u8be6\u7ec6\u8bb2\u89e3\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u67b6\u6784\u4e0e\u539f\u7406<\/strong>\uff1a\u4e3a\u4ec0\u4e48\u9009 Prometheus\uff1f\u5b83\u662f\u600e\u4e48\u5de5\u4f5c\u7684\uff1f<\/li>\n\n\n\n<li><strong>\u5b9e\u6218\u90e8\u7f72\uff08\u96be\u70b9\u89e3\u6790\uff09<\/strong>\uff1a\u8be6\u7ec6\u62c6\u89e3\u90a3\u4e2a\u590d\u6742\u7684 Docker \u542f\u52a8\u547d\u4ee4\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u67e5\u8be2\u4e0e\u4ef7\u503c\uff08PromQL\uff09<\/strong>\uff1a\u5982\u4f55\u5199\u67e5\u8be2\u8bed\u53e5\u6765\u771f\u6b63\u901a\u8fc7\u6570\u636e\u53d1\u73b0\u95ee\u9898\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e00\u90e8\u5206\uff1a\u67b6\u6784\u4e0e\u539f\u7406 \u2014\u2014 \u4ece\u201c\u76f2\u4eba\u6478\u8c61\u201d\u5230\u201c\u4e0a\u5e1d\u89c6\u89d2\u201d<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u4e3a\u4ec0\u4e48\u8981\u5f15\u5165 Prometheus\uff1f<\/h4>\n\n\n\n<p>\u5728\u6ca1\u6709\u76d1\u63a7\u7cfb\u7edf\u4e4b\u524d\uff0c\u8fd0\u7ef4\u6216\u5f00\u53d1\u4eba\u5458\u4e86\u89e3\u7cfb\u7edf\u72b6\u6001\u901a\u5e38\u662f\u88ab\u52a8\u7684\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4f20\u7edf\u65b9\u5f0f<\/strong>\uff1a\u63a5\u5230\u7528\u6237\u6295\u8bc9 -&gt; \u767b\u5f55 Linux \u670d\u52a1\u5668 -&gt; \u67e5\u65e5\u5fd7 (<code>tail -f<\/code>) -&gt; \u5199\u811a\u672c\u7edf\u8ba1\u3002<\/li>\n\n\n\n<li><strong>\u75db\u70b9<\/strong>\uff1a\u8fd9\u662f\u201c\u4e8b\u540e\u8bf8\u845b\u4eae\u201d\uff0c\u800c\u4e14\u65e0\u6cd5\u770b\u5230\u5386\u53f2\u8d8b\u52bf\uff08\u6bd4\u5982\uff1a\u662f\u7a81\u7136\u53d8\u6162\u7684\uff0c\u8fd8\u662f\u8fc7\u53bb\u4e00\u5468\u90fd\u5728\u53d8\u6162\uff1f\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<p>Prometheus \u7684\u4e3b\u8981\u7279\u6027\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e00\u4e2a\u591a\u7ef4<a href=\"https:\/\/prometheus.ac.cn\/docs\/concepts\/data_model\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u6570\u636e\u6a21\u578b<\/a>\uff0c\u5176\u4e2d\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7531\u6307\u6807\u540d\u79f0\u548c\u952e\/\u503c\u5bf9\u6807\u8bc6\u3002<\/li>\n\n\n\n<li>PromQL\uff0c\u4e00\u79cd\u7075\u6d3b\u7684<a href=\"https:\/\/prometheus.ac.cn\/docs\/prometheus\/latest\/querying\/basics\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u67e5\u8be2\u8bed\u8a00<\/a>\uff0c\u7528\u4e8e\u5229\u7528\u8fd9\u79cd\u591a\u7ef4\u6027\u3002<\/li>\n\n\n\n<li>\u4e0d\u4f9d\u8d56\u5206\u5e03\u5f0f\u5b58\u50a8\uff1b\u5355\u4e2a\u670d\u52a1\u5668\u8282\u70b9\u662f\u81ea\u4e3b\u7684\u3002<\/li>\n\n\n\n<li>\u65f6\u95f4\u5e8f\u5217\u6536\u96c6\u901a\u8fc7 HTTP \u4e0a\u7684\u62c9\u53d6\u6a21\u578b\u8fdb\u884c\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7\u4e2d\u95f4\u7f51\u5173\u652f\u6301<a href=\"https:\/\/prometheus.ac.cn\/docs\/instrumenting\/pushing\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u63a8\u9001\u65f6\u95f4\u5e8f\u5217<\/a>\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7\u670d\u52a1\u53d1\u73b0\u6216\u9759\u6001\u914d\u7f6e\u53d1\u73b0\u76ee\u6807\u3002<\/li>\n\n\n\n<li>\u652f\u6301\u591a\u79cd\u56fe\u5f62\u548c\u4eea\u8868\u76d8\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Prometheus \u7684\u6838\u5fc3\u4ef7\u503c<\/strong>\u5728\u4e8e\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a<strong>\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u5e93\uff08TSDB\uff09<\/strong>\u3002\u5b83\u4e0d\u4ec5\u4ec5\u8bb0\u5f55\u201c\u73b0\u5728\u6709\u591a\u5c11\u4e2a\u7ebf\u7a0b\u201d\uff0c\u800c\u662f\u8bb0\u5f55\u201c\u8fc7\u53bb\u6bcf\u4e00\u79d2\u6709\u591a\u5c11\u4e2a\u7ebf\u7a0b\u201d\u3002\u8fd9\u8ba9\u4f60\u80fd\u770b\u5230<strong>\u8d8b\u52bf<\/strong>\u3002.<\/p>\n\n\n\n<p>\u6307\u6807\u5728\u901a\u4fd7\u610f\u4e49\u4e0a\u662f\u6570\u503c\u6d4b\u91cf\u3002\u672f\u8bed\u201c\u65f6\u95f4\u5e8f\u5217\u201d\u662f\u6307\u968f\u65f6\u95f4\u8bb0\u5f55\u7684\u53d8\u5316\u3002\u7528\u6237\u5e0c\u671b\u6d4b\u91cf\u7684\u5185\u5bb9\u56e0\u5e94\u7528\u7a0b\u5e8f\u800c\u5f02\u3002\u5bf9\u4e8e Web \u670d\u52a1\u5668\uff0c\u53ef\u80fd\u662f\u8bf7\u6c42\u65f6\u95f4\uff1b\u5bf9\u4e8e\u6570\u636e\u5e93\uff0c\u53ef\u80fd\u662f\u6d3b\u52a8\u8fde\u63a5\u6570\u6216\u6d3b\u52a8\u67e5\u8be2\u6570\u7b49\u7b49\u3002<\/p>\n\n\n\n<p>\u6307\u6807\u5728\u7406\u89e3\u5e94\u7528\u7a0b\u5e8f\u4e3a\u4f55\u4ee5\u67d0\u79cd\u65b9\u5f0f\u5de5\u4f5c\u65b9\u9762\u53d1\u6325\u7740\u91cd\u8981\u4f5c\u7528\u3002\u5047\u8bbe\u60a8\u6b63\u5728\u8fd0\u884c\u4e00\u4e2a Web \u5e94\u7528\u7a0b\u5e8f\u5e76\u53d1\u73b0\u5b83\u8fd0\u884c\u7f13\u6162\u3002\u8981\u4e86\u89e3\u5e94\u7528\u7a0b\u5e8f\u53d1\u751f\u4e86\u4ec0\u4e48\uff0c\u60a8\u9700\u8981\u4e00\u4e9b\u4fe1\u606f\u3002\u4f8b\u5982\uff0c\u5f53\u8bf7\u6c42\u6570\u91cf\u5f88\u9ad8\u65f6\uff0c\u5e94\u7528\u7a0b\u5e8f\u53ef\u80fd\u4f1a\u53d8\u6162\u3002\u5982\u679c\u60a8\u62e5\u6709\u8bf7\u6c42\u8ba1\u6570\u6307\u6807\uff0c\u5219\u53ef\u4ee5\u786e\u5b9a\u539f\u56e0\u5e76\u589e\u52a0\u670d\u52a1\u5668\u6570\u91cf\u4ee5\u5904\u7406\u8d1f\u8f7d\u3002<\/p>\n\n\n\n<p>Prometheus \u751f\u6001\u7cfb\u7edf\u7531\u591a\u4e2a\u7ec4\u4ef6\u7ec4\u6210\uff0c\u5176\u4e2d\u8bb8\u591a\u662f\u53ef\u9009\u7684<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e3b <a href=\"https:\/\/github.com\/prometheus\/prometheus\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >Prometheus \u670d\u52a1\u5668<\/a>\uff0c\u5b83\u6293\u53d6\u5e76\u5b58\u50a8\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002<\/li>\n\n\n\n<li>\u7528\u4e8e\u5bf9\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u8fdb\u884c\u57cb\u70b9\u7684<a href=\"https:\/\/prometheus.ac.cn\/docs\/instrumenting\/clientlibs\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u5ba2\u6237\u7aef\u5e93<\/a>\u3002<\/li>\n\n\n\n<li>\u4e00\u4e2a\u7528\u4e8e\u652f\u6301\u77ed\u751f\u547d\u5468\u671f\u4f5c\u4e1a\u7684<a href=\"https:\/\/github.com\/prometheus\/pushgateway\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u63a8\u9001\u7f51\u5173<\/a>\u3002<\/li>\n\n\n\n<li>\u7528\u4e8e HAProxy\u3001StatsD\u3001Graphite \u7b49\u670d\u52a1\u7684\u4e13\u7528<a href=\"https:\/\/prometheus.ac.cn\/docs\/instrumenting\/exporters\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u5bfc\u51fa\u5668<\/a>\u3002<\/li>\n\n\n\n<li>\u4e00\u4e2a\u7528\u4e8e\u5904\u7406\u544a\u8b66\u7684<a href=\"https:\/\/github.com\/prometheus\/alertmanager\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >\u544a\u8b66\u7ba1\u7406\u5668<\/a>\u3002<\/li>\n\n\n\n<li>\u5404\u79cd\u652f\u6301\u5de5\u5177\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5927\u591a\u6570 Prometheus \u7ec4\u4ef6\u90fd\u662f\u7528 <a href=\"https:\/\/golang.ac.cn\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >Go<\/a> \u7f16\u5199\u7684\uff0c\u8fd9\u4f7f\u5f97\u5b83\u4eec\u6613\u4e8e\u6784\u5efa\u5e76\u90e8\u7f72\u4e3a\u9759\u6001\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u201c\u62c9\u6a21\u5f0f\u201d\uff08Pull\uff09 vs \u201c\u63a8\u6a21\u5f0f\u201d\uff08Push\uff09<\/h4>\n\n\n\n<p>\u6587\u6863\u4e2d\u7279\u610f\u63d0\u5230\u4e86 Prometheus \u91c7\u7528\u7684\u662f <strong>Pull\uff08\u62c9\uff09\u6a21\u5f0f<\/strong>\u3002\u8fd9\u662f\u7406\u89e3\u5176\u67b6\u6784\u7684\u5173\u952e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Push\uff08\u63a8\uff09\u6a21\u5f0f<\/strong>\uff08\u5982 Cat\u3001Zipkin\uff09\uff1a\u5e94\u7528\u670d\u52a1\uff08Client\uff09\u4e3b\u52a8\u628a\u6570\u636e\u53d1\u9001\u7ed9\u76d1\u63a7\u670d\u52a1\u5668\u3002\n<ul class=\"wp-block-list\">\n<li><em>\u7f3a\u70b9<\/em>\uff1a\u5982\u679c\u76d1\u63a7\u670d\u52a1\u5668\u6302\u4e86\uff0c\u5e94\u7528\u53d1\u9001\u6570\u636e\u53ef\u80fd\u4f1a\u8d85\u65f6\u6216\u79ef\u538b\uff0c\u5f71\u54cd\u4e1a\u52a1\u3002\u5bf9\u4e8e\u5fc5\u987b\u63a8\u9001\u7684\u60c5\u51b5\uff0cPrometheus \u540c\u65f6\u4e5f\u63d0\u4f9b\u4e86 <a href=\"https:\/\/prometheus.io\/docs\/instrumenting\/pushing\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >Pushgateway<\/a> \u7ec4\u4ef6<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Pull\uff08\u62c9\uff09\u6a21\u5f0f<\/strong>\uff08Prometheus\uff09\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u5de5\u4f5c\u65b9\u5f0f<\/strong>\uff1a\u4f60\u7684\u5e94\u7528\uff08<code>oneThread<\/code>\uff09\u53ea\u9700\u8981\u5f00\u4e00\u4e2a HTTP \u63a5\u53e3\uff08\u4f8b\u5982 <code>\/actuator\/prometheus<\/code>\uff09\uff0c\u9759\u9759\u5730\u628a\u6570\u636e\u5c55\u793a\u5728\u90a3\u91cc\u3002Prometheus \u670d\u52a1\u5668\u50cf\u4e00\u4e2a\u201c\u5de1\u68c0\u5458\u201d\uff0c\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\uff08\u4f8b\u5982 15\u79d2\uff09\u8fc7\u6765\u8bbf\u95ee\u4e00\u4e0b\u8fd9\u4e2a\u63a5\u53e3\uff0c\u628a\u6570\u636e\u6284\u8d70\u3002<\/li>\n\n\n\n<li><em>\u4f18\u70b9<\/em>\uff1a\u5e94\u7528\u5b8c\u5168\u89e3\u8026\u3002\u5c31\u7b97 Prometheus \u6302\u4e86\uff0c\u4f60\u7684\u5e94\u7528\u4ec5\u4ec5\u662f\u5c11\u4e86\u4e00\u4e2a HTTP \u8bf7\u6c42\u800c\u5df2\uff0c\u4e1a\u52a1\u5b8c\u5168\u4e0d\u53d7\u5f71\u54cd\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u6838\u5fc3\u6d41\u7a0b<\/h4>\n\n\n\n<p>\u57fa\u4e8e\u6587\u6863\u4e2d\u7684\u67b6\u6784\u56fe\uff0c\u6570\u636e\u6d41\u5411\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>oneThread App<\/strong>\uff1a\u901a\u8fc7 Micrometer \u5c06\u7ebf\u7a0b\u6c60\u5185\u90e8\u6570\u636e\uff08\u6d3b\u8dc3\u6570\u3001\u961f\u5217\u5927\u5c0f\u7b49\uff09\u8f6c\u6362\u4e3a Prometheus \u53ef\u8bfb\u7684\u6587\u672c\u683c\u5f0f\u3002<\/li>\n\n\n\n<li><strong>Expose\uff08\u66b4\u9732\uff09<\/strong>\uff1a\u5728 <code>http:\/\/localhost:18080\/actuator\/prometheus<\/code> \u66b4\u9732\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>Scrape\uff08\u6293\u53d6\uff09<\/strong>\uff1aPrometheus \u6839\u636e\u914d\u7f6e\u6587\u4ef6\uff0c\u6bcf 15 \u79d2\u8bbf\u95ee\u4e00\u6b21\u4e0a\u8ff0 URL\uff0c\u62c9\u53d6\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>Storage\uff08\u5b58\u50a8\uff09<\/strong>\uff1aPrometheus \u5c06\u6570\u636e\u6253\u4e0a\u65f6\u95f4\u6233\uff0c\u5b58\u5165\u672c\u5730\u6570\u636e\u5e93\u3002<\/li>\n\n\n\n<li><strong>Query\uff08\u67e5\u8be2\uff09<\/strong>\uff1a\u7528\u6237\u5728 WebUI \u6216 Grafana \u4e2d\u4f7f\u7528 PromQL \u8bed\u8a00\u67e5\u8be2\u6570\u636e\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e8c\u90e8\u5206\uff1aDocker \u5b9e\u6218\u90e8\u7f72 \u2014\u2014 \u90a3\u4e2a\u201c\u9a9a\u64cd\u4f5c\u201d\u547d\u4ee4\u89e3\u6790<\/h3>\n\n\n\n<p>\u6587\u6863\u4e2d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u5e38\u201c\u6781\u5ba2\u201d\u7684 Docker \u542f\u52a8\u547d\u4ee4\uff0c\u76ee\u7684\u662f<strong>\u4e3a\u4e86\u4e0d\u6302\u8f7d\u672c\u5730\u6587\u4ef6\u4e5f\u80fd\u8fd0\u884c\u81ea\u5b9a\u4e49\u914d\u7f6e<\/strong>\u3002\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u88ab\u8fd9\u4e2a\u957f\u547d\u4ee4\u5413\u5230\uff0c\u6211\u4eec\u6765\u9010\u884c\u62c6\u89e3\uff1a<\/p>\n\n\n\n<p>\u6ce8\u610f\u4e0d\u8981\u590d\u5236\u7a7a\u767d\u533a\u57df\uff0c\u5982\u6709\u9519\u8bef\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u6765\u4e00\u904d\uff08\u89c1\u6587\u7ae0\u672b\u5c3e\u5904\uff09<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d \\\n  --name prometheus \\\n  -p 9090:9090 \\\n  --entrypoint sh \\\n  -e TZ=Asia\/Shanghai \\\n  prom\/prometheus:v2.51.1 \\\n  -c 'echo \"\nglobal:\n  scrape_interval: 15s\n  evaluation_interval: 15s\n\u200b\nscrape_configs:\n  - job_name: '\\''prometheus'\\''\n    static_configs:\n      - targets: &#91;'\\''localhost:9090'\\'']\n\u200b\n  - job_name: '\\''onethread-app'\\''\n    metrics_path: '\\''\/actuator\/prometheus'\\''\n    static_configs:\n      - targets: &#91;'\\''host.docker.internal:18080'\\'']\n    scrape_interval: 10s\n    scrape_timeout: 5s\n\" &gt; \/etc\/prometheus\/prometheus.yml &amp;&amp; \/bin\/prometheus --config.file=\/etc\/prometheus\/prometheus.yml'<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u6838\u5fc3\u547d\u4ee4\u62c6\u89e3<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d \\\n  --name prometheus \\\n  -p 9090:9090 \\\n  --entrypoint sh \\   # &lt;--- \u5173\u952e\u70b9 1\n  ...\n  -c 'echo \"...\" &gt; \/etc\/prometheus\/prometheus.yml &amp;&amp; \/bin\/prometheus ...' # &lt;--- \u5173\u952e\u70b9 2<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5e38\u89c4\u505a\u6cd5<\/strong>\uff1a\u901a\u5e38\u6211\u4eec\u9700\u8981\u5728\u5bbf\u4e3b\u673a\u5199\u597d <code>prometheus.yml<\/code>\uff0c\u7136\u540e\u7528 <code>-v \/my\/config:\/etc\/prometheus\/config<\/code> \u6302\u8f7d\u8fdb\u53bb\u3002<\/li>\n\n\n\n<li><strong>\u6587\u6863\u4e2d\u7684\u505a\u6cd5<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li><strong>\u5173\u952e\u70b9 1 (<code>--entrypoint sh<\/code>)<\/strong>\uff1a\u5b83\u544a\u8bc9 Docker\uff0c\u5bb9\u5668\u542f\u52a8\u65f6\u4e0d\u8981\u76f4\u63a5\u8fd0\u884c Prometheus \u7a0b\u5e8f\uff0c\u800c\u662f\u5148\u7ed9\u6211\u4e00\u4e2a Shell\uff08\u547d\u4ee4\u884c\u73af\u5883\uff09\u3002<\/li>\n\n\n\n<li><strong>\u5173\u952e\u70b9 2 (<code>echo \"...\" &gt; ...<\/code>)<\/strong>\uff1a\u5229\u7528\u8fd9\u4e2a Shell\uff0c\u5148\u7528 <code>echo<\/code> \u547d\u4ee4\u628a\u914d\u7f6e\u6587\u4ef6\u7684\u5185\u5bb9<strong>\u52a8\u6001\u5199\u5165<\/strong>\u5230\u5bb9\u5668\u5185\u7684 <code>\/etc\/prometheus\/prometheus.yml<\/code> \u6587\u4ef6\u4e2d\u3002<\/li>\n\n\n\n<li><strong>\u6700\u540e\u4e00\u6b65 (<code>&amp;&amp; \/bin\/prometheus ...<\/code>)<\/strong>\uff1a\u914d\u7f6e\u6587\u4ef6\u5199\u597d\u540e\uff0c\u7d27\u63a5\u7740\u542f\u52a8 Prometheus \u4e3b\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a\uff1f<\/strong><br>\u8fd9\u79cd\u5199\u6cd5\u975e\u5e38\u9002\u5408<strong>\u5feb\u901f\u6f14\u793a<\/strong>\u6216<strong>\u6d4b\u8bd5<\/strong>\u3002\u4f60\u4e0d\u9700\u8981\u5728\u7535\u8111\u4e0a\u521b\u5efa\u4efb\u4f55\u6587\u4ef6\uff0c\u76f4\u63a5\u590d\u5236\u7c98\u8d34\u8fd9\u4e00\u6761\u547d\u4ee4\uff0cPrometheus \u5c31\u5e26\u7740\u914d\u7f6e\u8dd1\u8d77\u6765\u4e86\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u7f51\u7edc\u901a\u4fe1\u7684\u5173\u952e\uff1a<code>host.docker.internal<\/code><\/h4>\n\n\n\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f60\u770b\u5230\u4e86\u8fd9\u4e2a\u5730\u5740\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>targets: &#91;'host.docker.internal:18080']<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u95ee\u9898<\/strong>\uff1aPrometheus \u8dd1\u5728 Docker \u5bb9\u5668\u91cc\uff0c\u4f60\u7684 Java \u5e94\u7528\u8dd1\u5728\u5bbf\u4e3b\u673a\uff08\u4f60\u7684\u7535\u8111\uff09\u4e0a\u3002\u5bb9\u5668\u60f3\u8bbf\u95ee\u5bbf\u4e3b\u673a\uff0c\u4e0d\u80fd\u7528 <code>localhost<\/code>\uff08\u56e0\u4e3a\u5bb9\u5668\u7684 localhost \u662f\u5bb9\u5668\u81ea\u5df1\uff09\u3002<\/li>\n\n\n\n<li><strong>\u89e3\u51b3<\/strong>\uff1aDocker \u63d0\u4f9b\u4e86\u4e00\u4e2a\u7279\u6b8a\u7684 DNS \u57df\u540d <code>host.docker.internal<\/code>\u3002\u5728\u5bb9\u5668\u5185\u90e8\u8bbf\u95ee\u8fd9\u4e2a\u57df\u540d\uff0c\u8bf7\u6c42\u5c31\u4f1a\u8f6c\u53d1\u7ed9\u5bbf\u4e3b\u673a\u7684 IP\u3002<\/li>\n\n\n\n<li><strong>\u6ce8\u610f<\/strong>\uff1a\u8fd9\u4e2a\u529f\u80fd\u5728 Docker Desktop (Windows\/Mac) \u4e0a\u662f\u9ed8\u8ba4\u652f\u6301\u7684\u3002\u5728\u7eaf Linux \u73af\u5883\u4e0b\u53ef\u80fd\u9700\u8981\u989d\u5916\u914d\u7f6e <code>--add-host<\/code>\uff0c\u4f46\u6587\u6863\u8fd9\u91cc\u7684\u6f14\u793a\u73af\u5883\u4e3b\u8981\u9762\u5411\u5f00\u53d1\u673a\u7684\u5feb\u901f\u9a8c\u8bc1\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u914d\u7f6e\u6587\u4ef6\u89e3\u8bfb<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>scrape_configs:\n  - job_name: 'onethread-app'       # \u4efb\u52a1\u540d\u79f0\uff0c\u4f5c\u4e3a\u6807\u7b7e\u5b58\u50a8\n    metrics_path: '\/actuator\/prometheus' # \u6293\u53d6\u7684\u8def\u5f84\n    static_configs:\n      - targets: &#91;'host.docker.internal:18080'] # \u76ee\u6807\u5730\u5740\n    scrape_interval: 10s            # \u53ea\u6709\u8fd9\u4e2a\u4efb\u52a1\u6bcf10\u79d2\u6293\u4e00\u6b21\uff08\u8986\u76d6\u5168\u5c40\uff09<\/code><\/pre>\n\n\n\n<p>\u8fd9\u544a\u8bc9 Prometheus\uff1a\u201c\u8bf7\u6bcf\u9694 10 \u79d2\uff0c\u53bb\u5bbf\u4e3b\u673a\u7684 18080 \u7aef\u53e3\uff0c\u8bbf\u95ee <code>\/actuator\/prometheus<\/code>\uff0c\u628a\u62ff\u5230\u7684\u6570\u636e\u90fd\u6253\u4e0a <code>job=onethread-app<\/code> \u7684\u6807\u7b7e\u5b58\u8d77\u6765\u3002\u201d---<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em><strong>\u5982\u679c\u60f3\u7b80\u6613\u5b9e\u73b0oneThread\u52a8\u6001\u7ebf\u7a0bMetric\u91c7\u96c6\uff0c\u4e0a\u9762\u8fd9\u6761\u547d\u4ee4\u8db3\u591f\u4e86\u3002\u4e0a\u8ff0\u914d\u7f6e\u6587\u4ef6\u91cd\u5199\u7b49\u540c\u4e8e\uff1a<code>yamlglobal:scrape_interval:15s#\u5168\u5c40\u91c7\u96c6\u95f4\u9694evaluation_interval:15s#\u544a\u8b66\u89c4\u5219\u8bc4\u4f30\u95f4\u9694\u200b#\u91c7\u96c6\u4efb\u52a1\u914d\u7f6escrape_configs:#Prometheus\u81ea\u8eab\u76d1\u63a7-job_name:'prometheus'static_configs:-targets:['localhost:9090']\u200b#oneThread\u5e94\u7528\u76d1\u63a7-job_name:'onethread-app'metrics_path:'\/actuator\/prometheus'static_configs:-targets:['host.docker.internal:18080','host.docker.internal:18081']#\u540c\u4e00\u4efb\u52a1\u9700\u8981\u91c7\u96c6\u591aIP\uff0c\u53ef\u4ee5\u9017\u53f7\u5206\u5272scrape_interval:10sscrape_timeout:5s<\/code>\u56e0\u4e3aDocker\u548c\u5bbf\u4e3b\u673a\u7684IP\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u5982\u679c\u5728Docker\u5bb9\u5668\u4e2d\u8fd0\u884cPrometheus\u65f6\uff0c<\/strong> \u8981\u8bbf\u95ee\u5bbf\u4e3b\u673a\u7684\u670d\u52a1\u6216\u7aef\u53e3<\/em>*\uff0c\u63a8\u8350\u4f7f\u7528\uff1a<code>host.docker.internal<\/code>\u3002\u5728<code>Linux\uff08Dockerv20.10+\uff09<\/code>\u3001<code>macOS<\/code>\u548c<code>Windows<\/code>\u4e2d\uff0cDocker\u63d0\u4f9b\u4e86\u7279\u6b8a\u7684\u4e3b\u673a\u540d\uff0c\u5b83\u53ef\u4ee5\u5728\u5bb9\u5668\u5185\u89e3\u6790\u4e3a\u5bbf\u4e3b\u673a\u7684IP\u3002<code>host.docker.internal:18080<\/code>\u8868\u793aPrometheus\u5bb9\u5668\u53bb\u8bbf\u95ee\u5bbf\u4e3b\u673a18080\u7aef\u53e3\u7684\u670d\u52a1\u3002###2.\u8fd0\u884c\u68c0\u67e5\u6d4f\u89c8\u5668\u8bbf\u95ee<a href=\"http:\/\/localhost:9090\/targets\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >http:\/\/localhost:9090\/targets<\/a>\u5982\u679c\u53ef\u4ee5\u51fa\u73b0\u4e0b\u8ff0\u9875\u9762\uff0c\u5373\u4e3a\u8fd0\u884c\u6210\u529f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"588\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766931749-image-1024x588.png\" alt=\"\" class=\"wp-image-1752\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766931749-image-1024x588.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766931749-image-300x172.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766931749-image-768x441.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766931749-image.png 1404w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5982\u679c\u51fa\u73b0\u5728\u8fd9\u79cd\u62a5\u9519\u600e\u4e48\u529e\uff1f<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"590\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766934921-image-1024x590.png\" alt=\"\" class=\"wp-image-1755\" style=\"aspect-ratio:1.7356492542132111;width:683px;height:auto\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766934921-image-1024x590.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766934921-image-300x173.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766934921-image-768x443.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766934921-image-1536x885.png 1536w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766934921-image-2048x1180.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u54ce\u54ce\uff0cidea\u542f\u52a8\u7a0b\u5e8f\u5373\u53ef<\/p>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u54b1\u4eec\u5728Prometheus\u914d\u7f6e\u6587\u4ef6\u4e2d\u52a0\u7684\u4e24\u4e2a\u91c7\u96c6\u4efb\u52a1\uff0c\u90fd\u5728\u5217\u8868\u4e0a\u5c55\u793a\uff0c\u5e76\u4e14State\u663e\u793a\u4e3a<code>UP<\/code>\u5065\u5eb7\u72b6\u6001\u3002&gt;\u5927\u5bb6\u8bb0\u5f97\u628aonethread-nacos-cloud-example\u9879\u76ee\u8fd0\u884c\u8d77\u6765\uff0c\u8981\u4e0d\u7136\u4e0a\u9762\u90a3\u4e2a\u4efb\u52a1\u72b6\u6001\u4f1a\u663e\u793a\u5931\u8d25\u3002##Prometheus\u63a7\u5236\u53f0\u64cd\u4f5c\u6307\u5357###1.WebUI\u754c\u9762\u6982\u89c8\u8bbf\u95ee<code>http:\/\/localhost:9090<\/code>\u8fdb\u5165PrometheusWeb\u63a7\u5236\u53f0\uff0c\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u529f\u80fd\u6a21\u5757\uff1a** Graph\uff08\u56fe\u8868\u67e5\u8be2\uff09**\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u529f\u80fd<\/strong> \uff1a\u6267\u884c PromQL \u67e5\u8be2\uff0c\u67e5\u770b\u6307\u6807\u6570\u636e\u548c\u56fe\u8868\u3002<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong> \uff1a\u6570\u636e\u63a2\u7d22\u3001\u95ee\u9898\u6392\u67e5\u3001\u8d8b\u52bf\u5206\u6790\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Alerts\uff08\u544a\u8b66\u7ba1\u7406\uff09<\/strong> \uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u529f\u80fd<\/strong> \uff1a\u67e5\u770b\u5f53\u524d\u544a\u8b66\u72b6\u6001\u548c\u5386\u53f2\u8bb0\u5f55\u3002<\/li>\n\n\n\n<li><strong>\u7528\u9014<\/strong> \uff1a\u544a\u8b66\u76d1\u63a7\u3001\u89c4\u5219\u8c03\u8bd5\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Status\uff08\u72b6\u6001\u4fe1\u606f\uff09<\/strong> \uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Targets<\/strong> \uff1a\u67e5\u770b\u91c7\u96c6\u76ee\u6807\u72b6\u6001\u3002<\/li>\n\n\n\n<li><strong>ServiceDiscovery<\/strong> \uff1a\u67e5\u770b\u670d\u52a1\u53d1\u73b0\u72b6\u6001\u3002<\/li>\n\n\n\n<li><strong>Configuration<\/strong> \uff1a\u67e5\u770b\u5f53\u524d\u914d\u7f6e\u3002<\/li>\n\n\n\n<li><strong>Rules<\/strong> \uff1a\u67e5\u770b\u544a\u8b66\u89c4\u5219\u72b6\u6001\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e09\u90e8\u5206\uff1aPromQL \u67e5\u8be2\u4e0e\u6570\u636e\u4ef7\u503c \u2014\u2014 \u8ba9\u6570\u636e\u8bf4\u8bdd<\/h3>\n\n\n\n<p>Prometheus \u7684\u5f3a\u5927\u4e4b\u5904\u5728\u4e8e <strong>PromQL (Prometheus Query Language)<\/strong>\u3002\u6587\u6863\u4e2d\u5217\u4e3e\u4e86\u5f88\u591a\u4f8b\u5b50\uff0c\u6211\u4eec\u6765\u5206\u6790\u51e0\u4e2a\u6700\u5177\u5b9e\u6218\u610f\u4e49\u7684\u573a\u666f\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u57fa\u7840\u67e5\u8be2\u4e0e\u6807\u7b7e\u8fc7\u6ee4<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u67e5\u8be2<\/strong>\uff1a<code>dynamic_thread_pool_active_size<\/code><\/li>\n\n\n\n<li><strong>\u89e3\u91ca<\/strong>\uff1a\u8fd9\u4f1a\u5217\u51fa<strong>\u6240\u6709<\/strong>\u88ab\u76d1\u63a7\u5b9e\u4f8b\u7684<strong>\u6240\u6709<\/strong>\u7ebf\u7a0b\u6c60\u7684\u6d3b\u8dc3\u7ebf\u7a0b\u6570\u3002<\/li>\n\n\n\n<li><strong>\u8fc7\u6ee4<\/strong>\uff1a<code>dynamic_thread_pool_active_size{application_name=\"order-service\"}<\/code><\/li>\n\n\n\n<li><strong>\u573a\u666f<\/strong>\uff1a\u5f53\u4f60\u6709 10 \u4e2a\u5fae\u670d\u52a1\u65f6\uff0c\u4f60\u53ea\u60f3\u770b\u201c\u8ba2\u5355\u670d\u52a1\u201d\u7684\u7ebf\u7a0b\u6c60\u72b6\u6001\uff0c\u5c31\u5fc5\u987b\u7528\u5927\u62ec\u53f7 <code>{}<\/code> \u8fdb\u884c\u6807\u7b7e\u8fc7\u6ee4\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u8ba1\u7b97\u4f7f\u7528\u7387\uff08\u6838\u5fc3\u76d1\u63a7\u6307\u6807\uff09<\/h4>\n\n\n\n<p>\u4ec5\u4ec5\u77e5\u9053\u201c\u6d3b\u8dc3\u7ebf\u7a0b\u6570\u662f 50\u201d\u6ca1\u6709\u610f\u4e49\uff0c\u5fc5\u987b\u77e5\u9053\u201c\u6700\u5927\u5141\u8bb8\u591a\u5c11\u201d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u516c\u5f0f<\/strong>\uff1a<br><code>promql dynamic_thread_pool_active_size \/ dynamic_thread_pool_maximum_size * 100<\/code><\/li>\n\n\n\n<li><strong>\u4ef7\u503c<\/strong>\uff1a\u8fd9\u662f\u505a<strong>\u544a\u8b66<\/strong>\u7684\u6700\u4f73\u6307\u6807\u3002\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u7ed3\u679c &gt; 80%\uff0c\u8bf4\u660e\u7ebf\u7a0b\u6c60\u5feb\u6ee1\u4e86\uff0c\u7cfb\u7edf\u53ef\u80fd\u5904\u7406\u4e0d\u8fc7\u6765\u4e86\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u7ed3\u679c\u957f\u671f &lt; 10%\uff0c\u8bf4\u660e\u7ebf\u7a0b\u6c60\u914d\u7f6e\u592a\u5927\uff0c\u6d6a\u8d39\u5185\u5b58\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u901f\u7387\u8ba1\u7b97\uff08Rate\uff09\u2014\u2014 \u5904\u7406\u201c\u8ba1\u6570\u5668\u201d<\/h4>\n\n\n\n<p>\u5bf9\u4e8e\u201c\u5df2\u5b8c\u6210\u4efb\u52a1\u6570\u201d\u8fd9\u79cd\u6307\u6807\uff0c\u5b83\u662f\u4e00\u4e2a<strong>Counter\uff08\u53ea\u589e\u4e0d\u51cf\u7684\u8ba1\u6570\u5668\uff09<\/strong>\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9519\u8bef\u67e5\u8be2<\/strong>\uff1a<code>dynamic_thread_pool_completed_task_count<\/code>\n<ul class=\"wp-block-list\">\n<li><em>\u7ed3\u679c<\/em>\uff1a\u4f60\u53ea\u4f1a\u770b\u5230\u4e00\u6761\u659c\u5411\u4e0a\u7684\u7ebf\uff08\u4f8b\u5982\uff1a\u6628\u5929 1\u4e07\uff0c\u4eca\u5929 2\u4e07\uff09\u3002\u8fd9\u770b\u4e0d\u51fa\u5f53\u524d\u7cfb\u7edf\u7684\u8d1f\u8f7d\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6b63\u786e\u67e5\u8be2<\/strong>\uff1a<br><code>promql rate(dynamic_thread_pool_completed_task_count[5m])<\/code><\/li>\n\n\n\n<li><strong>\u89e3\u91ca<\/strong>\uff1a<code>rate<\/code> \u51fd\u6570\u8ba1\u7b97\u7684\u662f<strong>\u589e\u957f\u901f\u7387<\/strong>\uff08\u6bcf\u79d2\u5b8c\u6210\u4e86\u591a\u5c11\u4e2a\u4efb\u52a1\uff09\u3002<code>[5m]<\/code> \u8868\u793a\u53d6\u8fc7\u53bb 5 \u5206\u949f\u7684\u5e73\u5747\u901f\u7387\u3002<\/li>\n\n\n\n<li><strong>\u573a\u666f<\/strong>\uff1a\u8fd9\u5c31\u662f\u6240\u8c13\u7684 <strong>QPS (Queries Per Second)<\/strong> \u6216 <strong>TPS<\/strong>\u3002\u5982\u679c\u8fd9\u4e2a\u66f2\u7ebf\u7a81\u7136\u8dcc\u96f6\uff0c\u8bf4\u660e\u7cfb\u7edf\u6302\u4e86\u6216\u5361\u6b7b\u4e86\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">4. \u805a\u5408\u67e5\u8be2\uff08Aggregation\uff09<\/h4>\n\n\n\n<p>\u5f53\u4f60\u6709 10 \u4e2a\u5b9e\u4f8b\uff08Pod\uff09\u5728\u8fd0\u884c\u540c\u4e00\u4e2a\u670d\u52a1\u65f6\uff0c\u4f60\u53ef\u80fd\u4e0d\u60f3\u770b 10 \u6761\u7ebf\uff0c\u53ea\u60f3\u770b\u603b\u548c\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u516c\u5f0f<\/strong>\uff1a<br><code>promql sum by (application_name) (dynamic_thread_pool_active_size)<\/code><\/li>\n\n\n\n<li><strong>\u89e3\u91ca<\/strong>\uff1a\u628a\u6240\u6709\u5b9e\u4f8b\u7684\u6570\u636e\uff0c\u6309 <code>application_name<\/code> \u5206\u7ec4\u540e\u76f8\u52a0\u3002<\/li>\n\n\n\n<li><strong>\u573a\u666f<\/strong>\uff1a\u8bc4\u4f30\u6574\u4e2a\u96c6\u7fa4\u7684\u8d1f\u8f7d\u80fd\u529b\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p>\u8fd9\u7bc7\u6587\u7ae0\u901a\u8fc7\u4e00\u5957\u5b8c\u6574\u7684\u6d41\u7a0b\uff0c\u5c55\u793a\u4e86 <code>oneThread<\/code> \u5982\u4f55\u5b8c\u6210\u201c\u53ef\u89c2\u6d4b\u6027\u201d\u95ed\u73af\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6570\u636e\u6e90<\/strong>\uff1a\u5e94\u7528\u901a\u8fc7 Micrometer \u51c6\u5907\u597d\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u91c7\u96c6<\/strong>\uff1aPrometheus \u901a\u8fc7 Docker \u90e8\u7f72\uff0c\u5229\u7528 Pull \u6a21\u5f0f\u6293\u53d6\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u5206\u6790<\/strong>\uff1a\u901a\u8fc7 PromQL \u8ba1\u7b97\u6d3b\u8dc3\u5ea6\u3001\u541e\u5410\u91cf\u7b49\u5173\u952e\u6307\u6807\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u8fd9\u4e00\u6b65\u5b8c\u6210\u540e\uff0c\u4f60\u7684\u7ebf\u7a0b\u6c60\u4e0d\u518d\u662f\u4e00\u4e2a\u9ed1\u76d2\u3002\u4e0b\u4e00\u6b65\uff08\u6587\u6863\u9884\u544a\u7684 Grafana\uff09\u5c31\u662f\u628a\u8fd9\u4e9b PromQL \u8bed\u53e5\u53d8\u6210\u6f02\u4eae\u7684\u53ef\u89c6\u5316\u4eea\u8868\u76d8\u3002<\/p>\n\n\n\n<p>\u8fd9\u4efd\u6587\u6863\u7d27\u63a5\u7740\u4e0a\u4e00\u7bc7 Prometheus \u7684\u6559\u7a0b\uff0c\u8865\u5168\u4e86\u76d1\u63a7\u7cfb\u7edf\u7684\u6700\u540e\u4e00\u5757\u62fc\u56fe\u2014\u2014<strong>\u53ef\u89c6\u5316\uff08Visualization\uff09<\/strong>\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4e0d\u52a0\u8fd9\u4e00\u6b65\uff0cPrometheus \u5c31\u50cf\u662f\u4e00\u4e2a\u6df1\u57cb\u5728\u5730\u4e0b\u7684\u5de8\u5927\u91d1\u77ff\uff08\u6570\u636e\uff09\uff0c\u867d\u7136\u6709\u4ef7\u503c\uff0c\u4f46\u4f60\u8981\u60f3\u770b\u4e00\u773c\uff0c\u8fd8\u5f97\u62ff\u94f2\u5b50\u6316\uff08\u5199 PromQL \u4ee3\u7801\uff09\u3002\u800c <strong>Grafana \u5c31\u662f\u628a\u91d1\u77ff\u53d8\u6210\u4e86\u7cbe\u7f8e\u7684\u9996\u9970\u5e97<\/strong>\uff0c\u8ba9\u4f60\u4e00\u773c\u5c31\u80fd\u770b\u6e05\u6570\u636e\u7684\u4ef7\u503c\u3002<\/p>\n\n\n\n<p>\u6211\u5c06\u4ece<strong>\u7f51\u7edc\u67b6\u6784\u3001\u90e8\u7f72\u6d41\u7a0b\u3001\u6838\u5fc3\u914d\u7f6e\u3001\u5927\u5c4f\u96c6\u6210<\/strong>\u56db\u4e2a\u7ef4\u5ea6\uff0c\u4e3a\u4f60\u201c\u901a\u900f\u201d\u5730\u8bb2\u89e3\u8fd9\u4e00\u7ae0\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e00\u90e8\u5206\uff1a\u7f51\u7edc\u67b6\u6784 \u2014\u2014 \u5bb9\u5668\u95f4\u7684\u201c\u5c40\u57df\u7f51\u201d<\/h3>\n\n\n\n<p>\u5728\u4e0a\u4e00\u7bc7\u4e2d\uff0c\u6211\u4eec\u542f\u52a8\u4e86 Prometheus\u3002\u5728\u8fd9\u4e00\u7bc7\uff0c\u6211\u4eec\u8981\u542f\u52a8 Grafana\u3002\u6700\u5173\u952e\u7684\u4e00\u70b9\u662f\uff1a<strong>Grafana \u9700\u8981\u53bb Prometheus \u90a3\u91cc\u62c9\u53d6\u6570\u636e\u3002<\/strong><\/p>\n\n\n\n<p>\u8fd9\u5c31\u6d89\u53ca\u5230\u4e86 Docker \u5bb9\u5668\u95f4\u7684\u901a\u4fe1\u95ee\u9898\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u4e3a\u4ec0\u4e48\u8981\u521b\u5efa <code>monitoring<\/code> \u7f51\u7edc\uff1f<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker network create monitoring<\/code><\/pre>\n\n\n\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cDocker \u5bb9\u5668\u867d\u7136\u4e5f\u80fd\u901a\u4fe1\uff0c\u4f46\u901a\u5e38\u9700\u8981\u4f9d\u8d56 IP \u5730\u5740\u3002\u5bb9\u5668\u91cd\u542f\u540e IP \u53ef\u80fd\u4f1a\u53d8\uff0c\u8fd9\u5f88\u9ebb\u70e6\u3002<br><strong>\u81ea\u5b9a\u4e49\u7f51\u7edc\uff08User-defined Bridge Network\uff09<\/strong> \u7684\u597d\u5904\u5728\u4e8e\uff1a<strong>\u7531\u4e8e Docker \u5185\u7f6e\u4e86 DNS \u89e3\u6790\uff0c\u540c\u4e00\u7f51\u7edc\u4e0b\u7684\u5bb9\u5668\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u201c\u5bb9\u5668\u540d\u201d\u4e92\u76f8\u8bbf\u95ee\u3002<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u201c\u8001\u201d\u5bb9\u5668\u52a0\u5165\u65b0\u7f51\u7edc<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker network connect monitoring prometheus<\/code><\/pre>\n\n\n\n<p>\u56e0\u4e3a Prometheus \u662f\u4e0a\u4e00\u7ae0\u542f\u52a8\u7684\uff0c\u5f53\u65f6\u53ef\u80fd\u6ca1\u6307\u5b9a\u8fd9\u4e2a\u7f51\u7edc\u3002\u8fd9\u6761\u547d\u4ee4\u76f8\u5f53\u4e8e\u628a\u6b63\u5728\u8fd0\u884c\u7684 Prometheus \u5bb9\u5668\u201c\u62c9\u201d\u5230\u4e86 <code>monitoring<\/code> \u8fd9\u4e2a\u5c40\u57df\u7f51\u91cc\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u542f\u52a8 Grafana \u5e76\u52a0\u5165\u7f51\u7edc<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d --name grafana --network monitoring ...<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u660e\u786e\u6307\u5b9a\u4e86 <code>--network monitoring<\/code>\u3002<br><strong>\u7ed3\u679c<\/strong>\uff1aGrafana \u548c Prometheus \u73b0\u5728\u5c31\u50cf\u4f4f\u5728\u540c\u4e00\u4e2a\u5c0f\u533a\u7684\u90bb\u5c45\u3002Grafana \u53ea\u8981\u558a\u4e00\u58f0\u201cprometheus\u201d\uff08\u5bb9\u5668\u540d\uff09\uff0c\u5bf9\u65b9\u5c31\u80fd\u542c\u5230\uff0c\u5b8c\u5168\u4e0d\u9700\u8981\u77e5\u9053\u5bf9\u65b9\u7684 IP \u662f\u591a\u5c11\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e8c\u90e8\u5206\uff1a\u914d\u7f6e\u6570\u636e\u6e90 \u2014\u2014 \u6253\u901a\u4efb\u7763\u4e8c\u8109<\/h3>\n\n\n\n<p>\u90e8\u7f72\u597d Grafana \u540e\uff08\u8bbf\u95ee <code>localhost:3000<\/code>\uff09\uff0c\u7b2c\u4e00\u4ef6\u4e8b\u662f\u544a\u8bc9\u5b83\uff1a<strong>\u6570\u636e\u4ece\u54ea\u6765\uff1f<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u6838\u5fc3\u914d\u7f6e\u70b9\uff1aURL<\/h4>\n\n\n\n<p>\u5728\u914d\u7f6e Prometheus \u6570\u636e\u6e90\u65f6\uff0c\u6587\u6863\u5f3a\u8c03\u586b\u5199\u7684 URL \u662f\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><code>http:\/\/prometheus:9090<\/code><\/p>\n<\/blockquote>\n\n\n\n<p><strong>\u8fd9\u91cc\u6709\u521d\u5b66\u8005\u6700\u5bb9\u6613\u72af\u7684\u9519\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9519\u8bef\u5199\u6cd5<\/strong>\uff1a<code>http:\/\/localhost:9090<\/code> \u6216 <code>http:\/\/127.0.0.1:9090<\/code>\u3002\n<ul class=\"wp-block-list\">\n<li><em>\u4e3a\u4ec0\u4e48\u9519\uff1f<\/em> \u56e0\u4e3a\u8fd9\u4e2a\u8bf7\u6c42\u662f\u7531 <strong>Grafana \u5bb9\u5668\u5185\u90e8<\/strong> \u53d1\u51fa\u7684\u3002\u5728 Grafana \u5bb9\u5668\u91cc\uff0c<code>localhost<\/code> \u6307\u7684\u662f Grafana \u81ea\u5df1\uff0c\u5b83\u91cc\u9762\u53ef\u6ca1\u8dd1 Prometheus\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u6b63\u786e\u5199\u6cd5<\/strong>\uff1a<code>http:\/\/prometheus:9090<\/code>\u3002\n<ul class=\"wp-block-list\">\n<li><em>\u539f\u7406<\/em>\uff1a\u5229\u7528\u4e86\u4e0a\u9762\u521b\u5efa\u7684 Docker \u7f51\u7edc DNS \u89e3\u6790\u3002<code>prometheus<\/code> \u8fd9\u4e2a\u4e3b\u673a\u540d\u4f1a\u81ea\u52a8\u89e3\u6790\u6210 Prometheus \u5bb9\u5668\u7684\u5185\u7f51 IP\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u4e09\u90e8\u5206\uff1a\u5bfc\u5165 Dashboard \u2014\u2014 \u7ad9\u5728\u5de8\u4eba\u7684\u80a9\u8180\u4e0a<\/h3>\n\n\n\n<p>\u624b\u52a8\u4e00\u4e2a\u4e00\u4e2a\u53bb\u914d\u56fe\u8868\uff08Panel\uff09\u662f\u975e\u5e38\u8017\u65f6\u7684\u3002oneThread \u5b98\u65b9\u63d0\u4f9b\u4e86\u4e00\u4e2a JSON \u6587\u4ef6\uff0c\u8fd9\u76f8\u5f53\u4e8e\u662f\u4e00\u4e2a<strong>\u6a21\u677f\u5305<\/strong>\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. JSON \u6a21\u677f\u91cc\u6709\u4ec0\u4e48\uff1f<\/h4>\n\n\n\n<p>\u8fd9\u4e2a JSON \u6587\u4ef6\u91cc\u5305\u542b\u4e86\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5e03\u5c40\u4fe1\u606f<\/strong>\uff1a\u54ea\u4e2a\u56fe\u5728\u5de6\u8fb9\uff0c\u54ea\u4e2a\u5728\u53f3\u8fb9\u3002<\/li>\n\n\n\n<li><strong>PromQL \u8bed\u53e5<\/strong>\uff1a\u4e0a\u4e00\u7ae0\u54b1\u4eec\u5b66\u7684\u90a3\u4e9b <code>rate(...)<\/code>\u3001<code>sum(...)<\/code> \u8bed\u53e5\uff0c\u90fd\u5df2\u7ecf\u9884\u8bbe\u5728\u91cc\u9762\u4e86\u3002<\/li>\n\n\n\n<li><strong>\u53d8\u91cf\uff08Variables\uff09<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u6587\u6863\u622a\u56fe\u91cc\u663e\u793a\u7684 <code>application_name<\/code> \u548c <code>dynamic_thread_pool_id<\/code> \u4e0b\u62c9\u6846\u3002<\/li>\n\n\n\n<li>\u8fd9\u5229\u7528\u4e86 Grafana \u7684\u53d8\u91cf\u529f\u80fd\uff0c\u5141\u8bb8\u4f60\u5728\u4e00\u5957\u5927\u5c4f\u91cc\uff0c\u901a\u8fc7\u5207\u6362\u4e0b\u62c9\u6846\u6765\u67e5\u770b\u4e0d\u540c\u670d\u52a1\u3001\u4e0d\u540c\u7ebf\u7a0b\u6c60\u7684\u6570\u636e\uff0c\u5b9e\u73b0\u4e86<strong>\u590d\u7528<\/strong>\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u6548\u679c\u89e3\u8bfb<\/h4>\n\n\n\n<p>\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f60\u4f1a\u770b\u5230\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6d3b\u8dc3\u7ebf\u7a0b\u6570<\/strong>\uff1a\u5b9e\u65f6\u6ce2\u52a8\u7684\u66f2\u7ebf\uff0c\u5c55\u793a\u8d1f\u8f7d\u60c5\u51b5\u3002<\/li>\n\n\n\n<li><strong>\u961f\u5217\u79ef\u538b<\/strong>\uff1a\u5982\u679c\u6709\u6ce2\u5cf0\uff0c\u8bf4\u660e\u5904\u7406\u4e0d\u8fc7\u6765\u4e86\u3002<\/li>\n\n\n\n<li><strong>IP \u5206\u7ec4<\/strong>\uff1a\u5982\u679c\u4f60\u90e8\u7f72\u4e86\u96c6\u7fa4\uff08\u6bd4\u5982\u542f\u52a8\u4e86 3 \u4e2a\u670d\u52a1\u5b9e\u4f8b\uff09\uff0cGrafana \u4f1a\u81ea\u52a8\u6309 IP \u5206\u7ec4\u5c55\u793a\uff0c\u8ba9\u4f60\u770b\u51fa\u662f\u4e0d\u662f\u67d0\u4e00\u53f0\u673a\u5668\u8d1f\u8f7d\u7279\u522b\u9ad8\uff08\u5355\u70b9\u6545\u969c\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b2c\u56db\u90e8\u5206\uff1a\u96c6\u6210\u5230\u4e1a\u52a1\u7cfb\u7edf \u2014\u2014 \u95ed\u73af\u7684\u6700\u540e\u4e00\u6b65<\/h3>\n\n\n\n<p>\u8fd9\u4e00\u6b65\u662f\u5f88\u591a\u6559\u7a0b\u91cc\u4e0d\u5177\u5907\u7684\uff0c\u662f oneThread \u6846\u67b6\u7684\u5de5\u7a0b\u5316\u4f53\u73b0\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u573a\u666f\u63cf\u8ff0<\/h4>\n\n\n\n<p>\u901a\u5e38\uff0c\u5f00\u53d1\u4eba\u5458\u4f7f\u7528 <code>oneThread<\/code> \u81ea\u5e26\u7684 Admin \u7ba1\u7406\u540e\u53f0\u6765\u52a8\u6001\u8c03\u6574\u7ebf\u7a0b\u6c60\u53c2\u6570\u3002\u5982\u679c\u6b64\u65f6\u60f3\u770b\u76d1\u63a7\uff0c\u8fd8\u9700\u8981\u5355\u72ec\u6253\u5f00 Grafana \u7f51\u9875\uff0c\u4f53\u9a8c\u662f\u5272\u88c2\u7684\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u89e3\u51b3\u65b9\u6848<\/h4>\n\n\n\n<p>\u5728 <code>onethread-dashboard-dev<\/code> \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>onethread:\n  grafana:\n    url: http:\/\/grafana.nageoffer.com\/d\/gxBvKxYNz\/...?var-application_name=...&amp;kiosk=true<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>url<\/code> \u53c2\u6570<\/strong>\uff1a\u8fd9\u91cc\u586b\u5165\u4f60\u90e8\u7f72\u597d\u7684 Grafana \u5177\u4f53 Dashboard \u7684\u94fe\u63a5\u3002<\/li>\n\n\n\n<li><strong><code>kiosk=true<\/code><\/strong>\uff1a\u8fd9\u662f\u4e00\u4e2a Grafana \u7684 URL \u53c2\u6570\uff0c\u610f\u601d\u662f<strong>\u4ee5\u201c\u7535\u89c6\u6a21\u5f0f\/\u5d4c\u5165\u6a21\u5f0f\u201d\u6253\u5f00<\/strong>\uff0c\u4f1a\u9690\u85cf Grafana \u9876\u90e8\u7684\u83dc\u5355\u680f\u548c\u4fa7\u8fb9\u680f\uff0c\u53ea\u7559\u4e0b\u56fe\u8868\u3002\u8fd9\u975e\u5e38\u9002\u5408\u5d4c\u5165\u5230\u5176\u4ed6\u7cfb\u7edf\u4e2d\u3002<\/li>\n\n\n\n<li><strong>\u8054\u52a8\u6548\u679c<\/strong>\uff1a\u914d\u7f6e\u597d\u540e\uff0c\u4f60\u5728 oneThread \u7684\u7ba1\u7406\u540e\u53f0\u70b9\u51fb\u201c\u76d1\u63a7\u201d\u6309\u94ae\uff0c\u5b83\u4f1a\u76f4\u63a5\u901a\u8fc7 iframe \u6216\u8df3\u8f6c\u7684\u65b9\u5f0f\u6253\u5f00\u8fd9\u4e2a\u94fe\u63a5\uff0c\u5e76\u4e14\u81ea\u52a8\u5e26\u4e0a\u53c2\u6570\uff0c\u76f4\u63a5\u5c55\u793a\u5f53\u524d\u7ebf\u7a0b\u6c60\u7684\u56fe\u8868\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p>\u81f3\u6b64\uff0c\u6574\u4e2a <strong>oneThread \u52a8\u6001\u7ebf\u7a0b\u6c60\u6846\u67b6<\/strong> \u7684\u5b66\u4e60\u4e4b\u65c5\u5c31\u753b\u4e0a\u4e86\u4e00\u4e2a\u5b8c\u7f8e\u7684\u53e5\u53f7\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u6838\u5fc3\u539f\u7406<\/strong>\uff1a\u7406\u89e3\u4e86\u7ebf\u7a0b\u6c60\u4e3a\u4ec0\u4e48\u8981\u52a8\u6001\u5316\uff08\u89e3\u51b3\u786c\u7f16\u7801\u75db\u70b9\uff09\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u66b4\u9732<\/strong>\uff1a\u901a\u8fc7 Micrometer \u5c06 Java \u5185\u90e8\u6307\u6807\u8f6c\u4e3a\u6807\u51c6\u683c\u5f0f\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u91c7\u96c6<\/strong>\uff1a\u4f7f\u7528 Docker \u90e8\u7f72 Prometheus \u8fdb\u884c\u201c\u62c9\u6a21\u5f0f\u201d\u5b58\u50a8\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5c55\u793a<\/strong>\uff1a\u4f7f\u7528 Docker \u90e8\u7f72 Grafana\uff0c\u901a\u8fc7\u5185\u90e8\u7f51\u7edc\u8fde\u63a5\uff0c\u5e76\u5229\u7528 JSON \u6a21\u677f\u5b9e\u73b0\u4e00\u952e\u53ef\u89c6\u5316\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>\uff08\u70b9\u51fb\u67e5\u770b\uff09\u6709\u4e00\u70b9\u4e1c\u897f\u6211\u611a\u949d\u6ca1\u770b\u51fa\u6765\u6709\u4ec0\u4e48\u7528\uff1f\u8fd9\u79cd\u4e1c\u897f\u4e5f\u6709myplus\u8fd9\u79cd\u6c9f\u901a\u7528\u7684\u4e2d\u95f4\u4ef6\u5417\uff1f<\/summary>\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h3 class=\"wp-block-heading\" id=\"3-configuration\">Configuration \u9875\u9762<\/h3>\n\n\n\n<p><strong>\u67e5\u770b\u5f53\u524d\u914d\u7f6e<\/strong> \uff1a<\/p>\n\n\n\n<p>Status \u2192 Configuration \u9875\u9762\u663e\u793a\u5f53\u524d\u751f\u6548\u7684\u5b8c\u6574\u914d\u7f6e\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5168\u5c40\u914d\u7f6e<\/strong> \uff1a\u91c7\u96c6\u95f4\u9694\u3001\u8bc4\u4f30\u95f4\u9694\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u91c7\u96c6\u4efb\u52a1\u914d\u7f6e<\/strong> \uff1a\u6240\u6709 scrape_configs \u7684\u8be6\u7ec6\u914d\u7f6e\u3002<\/li>\n\n\n\n<li><strong>\u544a\u8b66\u89c4\u5219\u914d\u7f6e<\/strong> \uff1arule_files \u4e2d\u5b9a\u4e49\u7684\u89c4\u5219\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u914d\u7f6e\u70ed\u91cd\u8f7d<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u65b9\u6cd51\uff1a\u53d1\u9001 HTTP \u8bf7\u6c42\ncurl -X POST http:\/\/localhost:9090\/-\/reload\n\u200b\n# \u65b9\u6cd52\uff1a\u53d1\u9001\u7cfb\u7edf\u4fe1\u53f7\ndocker exec prometheus kill -HUP 1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prom-ql\">PromQL \u67e5\u8be2\u8bed\u8a00\u5b9e\u8df5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-prom-ql\">1. PromQL \u57fa\u7840\u8bed\u6cd5<\/h3>\n\n\n\n<p><strong>\u5373\u65f6\u67e5\u8be2<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u67e5\u8be2\u5f53\u524d\u65f6\u523b\u7684\u6307\u6807\u503c\ndynamic_thread_pool_active_size<\/code><\/pre>\n\n\n\n<p><strong>\u8303\u56f4\u67e5\u8be2<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u67e5\u8be2\u8fc7\u53bb5\u5206\u949f\u7684\u6307\u6807\u503c\ndynamic_thread_pool_active_size&#91;5m]<\/code><\/pre>\n\n\n\n<p><strong>\u6807\u7b7e\u5339\u914d<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u7cbe\u786e\u5339\u914d\ndynamic_thread_pool_active_size{job=\"onethread-app\"}\n\u200b\n# \u6b63\u5219\u5339\u914d\ndynamic_thread_pool_active_size{application_name=~\".*example.*\"}\n\u200b\n# \u4e0d\u7b49\u5339\u914d\ndynamic_thread_pool_active_size{dynamic_thread_pool_id!=\"onethread-producer\"}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-one-thread\">2. oneThread \u6307\u6807\u67e5\u8be2\u5b9e\u4f8b<\/h3>\n\n\n\n<p><strong>\u7ebf\u7a0b\u6c60\u6d3b\u8dc3\u5ea6\u76d1\u63a7<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u67e5\u770b\u6240\u6709\u7ebf\u7a0b\u6c60\u7684\u6d3b\u8dc3\u7ebf\u7a0b\u6570\ndynamic_thread_pool_active_size\n\u200b\n# \u67e5\u770b\u7279\u5b9a\u5e94\u7528\u7684\u7ebf\u7a0b\u6c60\u6d3b\u8dc3\u5ea6\ndynamic_thread_pool_active_size{application_name=\"xxx\"}\n\u200b\n# \u8ba1\u7b97\u7ebf\u7a0b\u6c60\u4f7f\u7528\u7387\ndynamic_thread_pool_active_size \/ dynamic_thread_pool_maximum_size * 100<\/code><\/pre>\n\n\n\n<p><strong>\u961f\u5217\u72b6\u6001\u76d1\u63a7<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u67e5\u770b\u961f\u5217\u5f53\u524d\u957f\u5ea6\ndynamic_thread_pool_queue_size\n\u200b\n# \u8ba1\u7b97\u961f\u5217\u4f7f\u7528\u7387\ndynamic_thread_pool_queue_size \/ dynamic_thread_pool_queue_capacity * 100\n\u200b\n# \u67e5\u770b\u961f\u5217\u5269\u4f59\u5bb9\u91cf\ndynamic_thread_pool_queue_remaining_capacity<\/code><\/pre>\n\n\n\n<p><strong>\u4efb\u52a1\u6267\u884c\u7edf\u8ba1<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u67e5\u770b\u5df2\u5b8c\u6210\u4efb\u52a1\u6570\ndynamic_thread_pool_completed_task_count\n\u200b\n# \u8ba1\u7b97\u4efb\u52a1\u5b8c\u6210\u901f\u7387\uff08\u6bcf\u79d2\uff09\nrate(dynamic_thread_pool_completed_task_count&#91;5m])\n\u200b\n# \u67e5\u770b\u62d2\u7edd\u4efb\u52a1\u6570\ndynamic_thread_pool_reject_count<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u805a\u5408\u51fd\u6570\u5e94\u7528<\/h3>\n\n\n\n<p><strong>\u6309\u5e94\u7528\u805a\u5408<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8ba1\u7b97\u6bcf\u4e2a\u5e94\u7528\u7684\u603b\u6d3b\u8dc3\u7ebf\u7a0b\u6570\nsum by (application_name) (dynamic_thread_pool_active_size)\n\u200b\n# \u8ba1\u7b97\u6bcf\u4e2a\u5e94\u7528\u7684\u5e73\u5747\u961f\u5217\u957f\u5ea6\navg by (application_name) (dynamic_thread_pool_queue_size)\n\u200b\n# \u67e5\u627e\u6bcf\u4e2a\u5e94\u7528\u4e2d\u6d3b\u8dc3\u7ebf\u7a0b\u6570\u6700\u591a\u7684\u7ebf\u7a0b\u6c60\nmax by (application_name) (dynamic_thread_pool_active_size)<\/code><\/pre>\n\n\n\n<p><strong>\u65f6\u95f4\u7a97\u53e3\u805a\u5408<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8fc7\u53bb5\u5206\u949f\u7684\u5e73\u5747\u6d3b\u8dc3\u7ebf\u7a0b\u6570\navg_over_time(dynamic_thread_pool_active_size&#91;5m])\n\u200b\n# \u8fc7\u53bb1\u5c0f\u65f6\u7684\u6700\u5927\u961f\u5217\u957f\u5ea6\nmax_over_time(dynamic_thread_pool_queue_size&#91;1h])\n\u200b\n# \u8fc7\u53bb10\u5206\u949f\u7684\u4efb\u52a1\u5b8c\u6210\u589e\u957f\u91cf\nincrease(dynamic_thread_pool_completed_task_count&#91;10m])<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4\">4. \u590d\u6742\u67e5\u8be2\u793a\u4f8b<\/h3>\n\n\n\n<p><strong>\u7ebf\u7a0b\u6c60\u5065\u5eb7\u5ea6\u8bc4\u4f30<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u7ebf\u7a0b\u6c60\u538b\u529b\u6307\u6570\uff08\u6d3b\u8dc3\u7ebf\u7a0b\u6570 + \u961f\u5217\u957f\u5ea6\uff09\n(dynamic_thread_pool_active_size + dynamic_thread_pool_queue_size) \/ dynamic_thread_pool_maximum_size\n\u200b\n# \u8bc6\u522b\u9ad8\u8d1f\u8f7d\u7ebf\u7a0b\u6c60\uff08\u4f7f\u7528\u7387\u8d85\u8fc780%\uff09\ndynamic_thread_pool_active_size \/ dynamic_thread_pool_maximum_size &gt; 0.8\n\u200b\n# \u68c0\u6d4b\u961f\u5217\u5806\u79ef\u4e25\u91cd\u7684\u7ebf\u7a0b\u6c60\ndynamic_thread_pool_queue_size \/ dynamic_thread_pool_queue_capacity &gt; 0.7<\/code><\/pre>\n\n\n\n<p><strong>\u591a\u7ef4\u5ea6\u5bf9\u6bd4\u67e5\u8be2<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5bf9\u6bd4\u4e0d\u540c\u7ebf\u7a0b\u6c60\u7684\u6027\u80fd\u8868\u73b0\ntopk(5, dynamic_thread_pool_active_size)\n\u200b\n# \u67e5\u627e\u6700\u7e41\u5fd9\u7684\u5e94\u7528\ntopk(3, sum by (application_name) (dynamic_thread_pool_active_size))\n\u200b\n# \u8bc6\u522b\u5f02\u5e38\u7ebf\u7a0b\u6c60\uff08\u6d3b\u8dc3\u7ebf\u7a0b\u6570\u7a81\u7136\u4e0b\u964d\uff09\ndynamic_thread_pool_active_size &lt; \n  avg_over_time(dynamic_thread_pool_active_size&#91;1h]) * 0.5<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-prom-ql\">5. PromQL \u67e5\u8be2\u4f18\u5316\u6280\u5de7<\/h3>\n\n\n\n<p><strong>\u67e5\u8be2\u6027\u80fd\u4f18\u5316<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u907f\u514d\uff1a\u67e5\u8be2\u5927\u65f6\u95f4\u8303\u56f4\u7684\u539f\u59cb\u6570\u636e\ndynamic_thread_pool_active_size&#91;24h]\n\u200b\n# \u63a8\u8350\uff1a\u4f7f\u7528\u805a\u5408\u51fd\u6570\u51cf\u5c11\u6570\u636e\u91cf\navg_over_time(dynamic_thread_pool_active_size&#91;24h])<\/code><\/pre>\n\n\n\n<p><strong>\u6807\u7b7e\u9009\u62e9\u4f18\u5316<\/strong> \uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u907f\u514d\uff1a\u4f7f\u7528\u6b63\u5219\u5339\u914d\u5927\u91cf\u6807\u7b7e\n{__name__=~\"dynamic_thread_pool_.*\"}\n\u200b\n# \u63a8\u8350\uff1a\u4f7f\u7528\u7cbe\u786e\u7684\u6807\u7b7e\u5339\u914d\ndynamic_thread_pool_active_size{application_name=\"xxx\"}<\/code><\/pre>\n<\/blockquote>\n\n\n\n<p><\/p>\n<\/details>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u6709\u4e24\u70b9\u975e\u5e38\u91cd\u8981\u7684<strong>\u751f\u4ea7\u73af\u5883\u5efa\u8bae<\/strong>\u9700\u8981\u8865\u5145\u3002<\/p>\n\n\n\n<p>\u76ee\u524d\u7684\u6559\u7a0b\u4e3a\u4e86\u6f14\u793a\u65b9\u4fbf\uff0c\u4f7f\u7528\u7684\u662f\u201c\u5373\u7528\u5373\u6254\u201d\u7684 Docker \u5bb9\u5668\u914d\u7f6e\u3002\u5982\u679c\u4f60\u8981\u5728<strong>\u751f\u4ea7\u73af\u5883<\/strong>\u4f7f\u7528\uff0c\u5fc5\u987b\u6ce8\u610f\u4ee5\u4e0b\u4e24\u70b9\uff0c\u5426\u5219\u53ef\u80fd\u4f1a\u4e22\u6570\u636e\u6216\u6536\u4e0d\u5230\u62a5\u8b66\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u6570\u636e\u6301\u4e45\u5316\uff08\u5fc5\u505a\uff09<\/h3>\n\n\n\n<p>\u6559\u7a0b\u4e2d\u7684 Docker \u547d\u4ee4\u6ca1\u6709\u6302\u8f7d\u78c1\u76d8\u5377\uff08Volume\uff09\u3002\u8fd9\u610f\u5473\u7740\uff0c\u5982\u679c\u4f60\u7684 Prometheus \u6216 Grafana \u5bb9\u5668\u88ab\u5220\u9664\u6216\u91cd\u65b0\u521b\u5efa\uff0c<strong>\u6240\u6709\u7684\u76d1\u63a7\u5386\u53f2\u6570\u636e\u3001\u914d\u7f6e\u7684\u4eea\u8868\u76d8\u8d26\u6237\u4fe1\u606f\u90fd\u4f1a\u4e22\u5931<\/strong>\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Prometheus \u6539\u8fdb<\/strong>\uff1a\u9700\u8981\u901a\u8fc7 <code>-v<\/code> \u5c06\u5bbf\u4e3b\u673a\u7684\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 <code>\/prometheus<\/code>\uff08\u6570\u636e\u5b58\u50a8\u76ee\u5f55\uff09\u3002<\/li>\n\n\n\n<li><strong>Grafana \u6539\u8fdb<\/strong>\uff1a\u9700\u8981\u901a\u8fc7 <code>-v<\/code> \u5c06\u5bbf\u4e3b\u673a\u7684\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u5185\u7684 <code>\/var\/lib\/grafana<\/code>\uff08\u6570\u636e\u5b58\u50a8\u76ee\u5f55\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u544a\u8b66\u901a\u77e5\uff08\u8fdb\u9636\uff09<\/h3>\n\n\n\n<p>\u76ee\u524d\u7684\u914d\u7f6e\u5b9e\u73b0\u4e86\u201c\u6211\u4eec\u4e3b\u52a8\u53bb\u770b\u76d1\u63a7\uff08Pull\/Look\uff09\u201d\uff0c\u4f46\u751f\u4ea7\u73af\u5883\u9700\u8981\u201c\u76d1\u63a7\u4e3b\u52a8\u544a\u8bc9\u6211\u4eec\u51fa\u95ee\u9898\u4e86\uff08Push\/Alert\uff09\u201d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Prometheus \u751f\u6001\u4e2d\u6709\u4e00\u4e2a\u7ec4\u4ef6\u53eb <strong>Alertmanager<\/strong>\u3002<\/li>\n\n\n\n<li>\u4f60\u9700\u8981\u914d\u7f6e\u5b83\uff0c\u5f53 <code>dynamic_thread_pool_active_size<\/code> \u8d85\u8fc7\u9608\u503c\uff08\u6bd4\u5982 80%\uff09\u65f6\uff0c\u81ea\u52a8\u53d1\u9001\u6d88\u606f\u5230<strong>\u9489\u9489\u3001\u4f01\u4e1a\u5fae\u4fe1\u3001\u98de\u4e66\u6216\u90ae\u4ef6<\/strong>\uff0c\u8fd9\u6837\u8fd0\u7ef4\u4eba\u5458\u534a\u591c\u624d\u80fd\u7761\u5f97\u7740\u89c9\u3002<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>docker\u62a5\u9519\u600e\u4e48\u529e\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. \u5148\u5f7b\u5e95\u5220\u9664\u5931\u8d25\u7684\u5bb9\u5668\ndocker rm -f prometheus\n\n# 2. \u8fd0\u884c\u6e05\u6d17\u540e\u7684\u547d\u4ee4\ndocker run -d \\\n  --name prometheus \\\n  -p 9090:9090 \\\n  -u root \\\n  --add-host=host.docker.internal:host-gateway \\\n  --entrypoint sh \\\n  -e TZ=Asia\/Shanghai \\\n  prom\/prometheus:v2.51.1 \\\n  -c 'echo \"\nglobal:\n  scrape_interval: 15s\n  evaluation_interval: 15s\n\nscrape_configs:\n  - job_name: '\\''prometheus'\\''\n    static_configs:\n      - targets: &#91;'\\''localhost:9090'\\'']\n\n  - job_name: '\\''onethread-app'\\''\n    metrics_path: '\\''\/actuator\/prometheus'\\''\n    static_configs:\n      - targets: &#91;'\\''host.docker.internal:18080'\\'']\n    scrape_interval: 10s\n    scrape_timeout: 5s\n\" &gt; \/etc\/prometheus\/prometheus.yml &amp;&amp; \/bin\/prometheus --config.file=\/etc\/prometheus\/prometheus.yml'<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Grafana\u770b\u677f\u5f00\u53d1<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-docker\">1. \u521b\u5efa Docker \u7f51\u7edc<\/h3>\n\n\n\n<p>\u4e3a\u4e86\u8ba9 Grafana \u80fd\u591f\u901a\u8fc7\u5bb9\u5668\u540d\u8bbf\u95ee Prometheus\uff0c\u6211\u4eec\u5148\u521b\u5efa\u4e00\u4e2a\u5171\u4eab\u7f51\u7edc <code>monitoring<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker network create monitoring<\/code><\/pre>\n\n\n\n<p>\u8be5\u7f51\u7edc\u5c06\u4f5c\u4e3a Prometheus \u4e0e Grafana \u7684\u901a\u4fe1\u6865\u6881\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-prometheus\">2. Prometheus \u52a0\u5165\u7f51\u7edc<\/h3>\n\n\n\n<p>\u5c06\u5df2\u8fd0\u884c\u7684 <code>prometheus<\/code> \u5bb9\u5668\u8fde\u63a5\u5230 <code>monitoring<\/code> \u7f51\u7edc\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker network connect monitoring prometheus<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-grafana\">3. \u521b\u5efa Grafana<\/h3>\n\n\n\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8\u6307\u5b9a\u7248\u672c\u7684 Grafana \u5e76\u52a0\u5165\u540c\u4e00\u7f51\u7edc\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -d\\--name grafana \\--network monitoring \\-p3000:3000 \\\n  grafana\/grafana:9.0.5<\/code><\/pre>\n\n\n\n<p>\u8bbf\u95ee <a href=\"http:\/\/127.0.0.1:3000\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >http:\/\/127.0.0.1:3000<\/a> \u767b\u5f55 Grafana \u63a7\u5236\u53f0\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u5206\u522b\u662f admin\/admin\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"519\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990330-image-1024x519.png\" alt=\"\" class=\"wp-image-1763\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990330-image-1024x519.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990330-image-300x152.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990330-image-768x389.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990330-image-1536x778.png 1536w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990330-image-2048x1037.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"603\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990825-image-1024x603.png\" alt=\"\" class=\"wp-image-1767\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990825-image-1024x603.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990825-image-300x177.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990825-image-768x452.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990825-image.png 1255w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>HTTP URL \u5904\u586b\u5199 <a href=\"http:\/\/prometheus:9090\/\" target=\"_blank\" rel=\"noreferrer noopener\" rel=\"nofollow\" >http:\/\/prometheus:9090<\/a> \u5373\u53ef\uff0c\u901a\u8fc7 Docker \u5185\u90e8\u7f51\u7edc\u8fdb\u884c\u901a\u4fe1\uff0c\u4f1a\u81ea\u52a8\u5c06 prometheus \u89e3\u6790\u4e3a\u5bf9\u5e94\u7684 IP \u5730\u5740\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"585\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990833-image-1024x585.png\" alt=\"\" class=\"wp-image-1768\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990833-image-1024x585.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990833-image-300x171.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990833-image-768x439.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990833-image.png 1194w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5212\u5230\u6700\u4e0b\u9762\uff0c\u70b9\u51fb <code>Save % test<\/code> \u6309\u94ae\uff0c\u51fa\u73b0\u4e0a\u8ff0\u7eff\u8272\u5f39\u6846\uff0c\u5373\u53ef\u521b\u5efa\u6210\u529f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"552\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990846-image-1024x552.png\" alt=\"\" class=\"wp-image-1770\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990846-image-1024x552.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990846-image-300x162.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990846-image-768x414.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990846-image.png 1218w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-dash-board\">2. \u5bfc\u5165 DashBoard \u6a21\u677f<\/h3>\n\n\n\n<p>\u70b9\u51fb Dashboard-Browse \u6309\u94ae\u8fdb\u5165\u63a7\u5236\u53f0\u9875\u9762\uff0c\u5e76\u70b9\u51fb Import \u6309\u94ae\u8fdb\u884c\u5bfc\u5165\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u4e0b\u8ff0\u767e\u5ea6\u7f51\u76d8\u5206\u4eab\u7684\u6587\u4ef6\u4e0b\u8f7d oneThread Grafana \u7684\u5927\u5c4f JSON \u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u4e0a\u4f20 JSON \u6587\u4ef6\u5e76\u9009\u62e9 Prometheus \u6570\u636e\u6e90\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"915\" height=\"885\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990859-image.png\" alt=\"\" class=\"wp-image-1771\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990859-image.png 915w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990859-image-300x290.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990859-image-768x743.png 768w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/figure>\n\n\n\n<p><strong>\u5982\u679c\u4f60\u7684 onethread Nacos \u9879\u76ee\u4e00\u76f4\u5728\u4ea7\u51fa\u6307\u6807\u6570\u636e\uff0c\u5e76\u4e14 Prometheus \u4e5f\u5728\u8fdb\u884c\u91c7\u96c6\uff0c\u90a3\u4e48\u5bfc\u5165\u540e\u5c31\u4f1a\u5f97\u5230\u7c7b\u4f3c\u4e8e\u4e0b\u8ff0\u7684\u76d1\u63a7\u5927\u76d8\u3002<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990867-image-1024x558.png\" alt=\"\" class=\"wp-image-1772\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990867-image-1024x558.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990867-image-300x164.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990867-image-768x419.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766990867-image.png 1220w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5982\u679c\u5b58\u5728\u76d1\u63a7\u591a\u4e2a\u9879\u76ee\u548c\u591a\u4e2a\u7ebf\u7a0b\u6c60\uff0c\u4e0a\u9762\u7684 <code>application_name<\/code> \u548c <code>dynamic_thread_pool_id<\/code> \u53ef\u4ee5\u8fdb\u884c\u9009\u62e9\u3002\u5982\u679c\u5355\u4e2a\u5e94\u7528\u8d77\u4e86\u591a\u4e2a\u5b9e\u4f8b\uff08\u96c6\u7fa4\u90e8\u7f72\uff09\uff0c\u8fd9\u4e2a\u76d1\u63a7\u56fe\u8868\u4f1a\u6709\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u8fd9\u79cd\u6548\u679c\uff0cIP \u5c55\u793a\u4f1a\u53d8\u6210\u591a\u4e2a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"589\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992368-image-1024x589.png\" alt=\"\" class=\"wp-image-1776\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992368-image-1024x589.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992368-image-300x173.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992368-image-768x442.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992368-image.png 1233w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"onethread-dashboard-dev-grafana\">onethread-dashboard-dev Grafana \u5730\u5740\u66ff\u6362<\/h2>\n\n\n\n<p>\u5728 dashboard-dev \u9879\u76ee\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6709\u8fd9\u4e48\u4e00\u4e2a\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>onethread:grafana:# \u5982\u679c\u672c\u5730\u6709\u5b89\u88c5 Grafana \u5c55\u793a\uff0c\u53ef\u4ee5\u66ff\u6362\u4e3a\u672c\u5730\u8def\u5f84\n &nbsp;  url: http:\/\/grafana.nageoffer.com\/d\/gxBvKxYNz\/7adffa3?orgId=1&amp;from=now-6h&amp;to=now&amp;timezone=browser&amp;var-application_name=nacos-cloud-example&amp;var-dynamic_thread_pool_id=onethread-consumer&amp;refresh=5s&amp;theme=light&amp;kiosk=true<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u6253\u7b97\u5c06\u9879\u76ee\u90e8\u7f72\u5230\u516c\u7f51\u73af\u5883\uff0c\u53ef\u4ee5\u5c06\u4e0a\u8ff0 URL \u66ff\u6362\u4e3a\u4f60\u81ea\u5df1\u90e8\u7f72\u7684 Grafana \u5730\u5740\u3002\u524d\u7aef\u5c55\u793a\u7684\u7ebf\u7a0b\u6c60\u76d1\u63a7\u9875\u9762\uff0c\u5c31\u662f\u901a\u8fc7\u63a5\u53e3\u52a8\u6001\u83b7\u53d6\u8be5\u53c2\u6570\u6765\u5b8c\u6210\u8df3\u8f6c\u4e0e\u5c55\u793a\u7684\u3002\u6839\u636e\u56fe\u7247\u7684\u7f51\u7ad9\uff0c\u6211\u5199\u4e0b\u5982\u6b64\u5185\u5bb9<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"199\" src=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992336-image-1024x199.png\" alt=\"\" class=\"wp-image-1774\" srcset=\"https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992336-image-1024x199.png 1024w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992336-image-300x58.png 300w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992336-image-768x150.png 768w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992336-image-1536x299.png 1536w, https:\/\/eve2333.top\/wp-content\/uploads\/2025\/12\/1766992336-image-2048x399.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>onethread:\n  grafana:\n    # \u683c\u5f0f: http:\/\/&lt;\u4f60\u7684IP:\u7aef\u53e3>\/d\/&lt;\u4f60\u7684DashboardID>\/&lt;\u540d\u79f0>?&lt;\u4fdd\u7559\u539f\u6709\u53c2\u6570>\n    url: http:\/\/192.168.111.131:3000\/d\/gxBvKxYNz\/na-ge-offershe-qun-onethreaddong-tai-xian-cheng-chi?orgId=1&amp;from=now-6h&amp;to=now&amp;timezone=browser&amp;var-application_name=nacos-cloud-example&amp;var-dynamic_thread_pool_id=onethread-consumer&amp;refresh=5s&amp;theme=light&amp;kiosk=true<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4efd\u6587\u6863\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5229\u7528 Prometheus \u76d1\u63a7\u7cfb\u7edf\u6765\u91c7\u96c6 oneThread \u52a8\u6001\u7ebf\u7a0b\u6c60\u6846\u67b6\u7684\u6307\u6807\u6570\u636e\u3002\u4e3a\u4e86\u8ba9\u4f60\u201c\u901a\u900f\u201d\u5730 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-1745","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/1745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1745"}],"version-history":[{"count":19,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/1745\/revisions"}],"predecessor-version":[{"id":1777,"href":"https:\/\/eve2333.top\/index.php?rest_route=\/wp\/v2\/posts\/1745\/revisions\/1777"}],"wp:attachment":[{"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eve2333.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}