{"id":23409,"date":"2025-01-09T18:53:25","date_gmt":"2025-01-09T10:53:25","guid":{"rendered":"https:\/\/www.yunshan.net\/blog\/?p=23409"},"modified":"2025-01-09T18:53:25","modified_gmt":"2025-01-09T10:53:25","slug":"prometheus%e7%9a%84exporter%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yunshan.net\/blog\/archives\/23409.html","title":{"rendered":"Prometheus\u7684Exporter\u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u4f7f\u7528\uff1f"},"content":{"rendered":"<p>\t\t\t\t<![CDATA[\n                \n\n<p style=\"text-align: center;\">\n\n<p><img decoding=\"async\" src=\"https:\/\/pic.zadbj010.com\/2025\/c9df4449ecdaf34.jpg\" alt=\"Prometheus\u7684Exporter\u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u4f7f\u7528\uff1f\" ><\/p>\n\n<\/p>\n\n\n\n<p>\u5728\u73b0\u4ee3\u7684\u76d1\u63a7\u7cfb\u7edf\u4e2d\uff0c<strong>Prometheus<\/strong> \u5df2\u7ecf\u6210\u4e3a\u4e86\u4e00\u4e2a\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002\u5b83\u4ee5\u5176\u5f3a\u5927\u7684\u6570\u636e\u91c7\u96c6\u3001\u5b58\u50a8\u548c\u67e5\u8be2\u80fd\u529b\uff0c\u8d62\u5f97\u4e86\u5e7f\u5927\u5f00\u53d1\u8005\u548c\u8fd0\u7ef4\u4eba\u5458\u7684\u9752\u7750\u3002\u7136\u800c\uff0cPrometheus \u672c\u8eab\u5e76\u4e0d\u76f4\u63a5\u652f\u6301\u6240\u6709\u7c7b\u578b\u7684\u76d1\u63a7\u6570\u636e\u91c7\u96c6\uff0c\u8fd9\u5c31\u9700\u8981\u501f\u52a9 <strong>Exporter<\/strong> \u6765\u5b9e\u73b0\u3002\u90a3\u4e48\uff0c<strong>Prometheus \u7684 Exporter \u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u4f7f\u7528\u5b83\u5462\uff1f<\/strong> \u672c\u6587\u5c06\u4e3a\u4f60\u8be6\u7ec6\u89e3\u7b54\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n\n\n\n\n<h3>\u4ec0\u4e48\u662f Prometheus \u7684 Exporter\uff1f<\/h3>\n\n\n\n\n<p><strong>Exporter<\/strong> \u662f Prometheus \u751f\u6001\u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u7ec4\u4ef6\uff0c\u5b83\u7684\u4e3b\u8981\u4f5c\u7528\u662f\u5c06\u5404\u79cd\u7cfb\u7edf\u3001\u670d\u52a1\u6216\u5e94\u7528\u7a0b\u5e8f\u7684\u76d1\u63a7\u6570\u636e\u8f6c\u6362\u4e3a Prometheus \u80fd\u591f\u8bc6\u522b\u7684\u683c\u5f0f\u3002\u7b80\u5355\u6765\u8bf4\uff0cExporter \u5c31\u50cf\u4e00\u4e2a\u201c\u7ffb\u8bd1\u5b98\u201d\uff0c\u5c06\u4e0d\u540c\u6765\u6e90\u7684\u76d1\u63a7\u6570\u636e\u201c\u7ffb\u8bd1\u201d\u6210 Prometheus \u80fd\u591f\u7406\u89e3\u7684\u683c\u5f0f\uff0c\u4ece\u800c\u4f7f\u5f97 Prometheus \u80fd\u591f\u91c7\u96c6\u3001\u5b58\u50a8\u548c\u67e5\u8be2\u8fd9\u4e9b\u6570\u636e\u3002<\/p>\n\n\n\n\n<p>Prometheus \u672c\u8eab\u652f\u6301\u901a\u8fc7 HTTP \u534f\u8bae\u62c9\u53d6\u76d1\u63a7\u6570\u636e\uff0c\u800c Exporter \u901a\u5e38\u4ee5 HTTP \u670d\u52a1\u5668\u7684\u5f62\u5f0f\u8fd0\u884c\uff0c\u66b4\u9732\u4e00\u4e2a\u6216\u591a\u4e2a HTTP \u7aef\u70b9\uff0c\u4f9b Prometheus \u5b9a\u671f\u6293\u53d6\u6570\u636e\u3002\u8fd9\u4e9b\u7aef\u70b9\u8fd4\u56de\u7684\u6570\u636e\u683c\u5f0f\u901a\u5e38\u662f <strong>Prometheus \u6587\u672c\u683c\u5f0f<\/strong>\uff0c\u8fd9\u662f\u4e00\u79cd\u7b80\u5355\u7684\u6587\u672c\u683c\u5f0f\uff0c\u6613\u4e8e\u89e3\u6790\u548c\u5b58\u50a8\u3002<\/p>\n\n\n\n\n<h3>\u5e38\u89c1\u7684 Exporter \u7c7b\u578b<\/h3>\n\n\n\n\n<p>Prometheus \u793e\u533a\u63d0\u4f9b\u4e86\u5927\u91cf\u7684 Exporter\uff0c\u51e0\u4e4e\u6db5\u76d6\u4e86\u6240\u6709\u5e38\u89c1\u7684\u76d1\u63a7\u573a\u666f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 Exporter \u7c7b\u578b\uff1a<\/p>\n\n\n\n\n<ol>\n\n\n<li><strong>Node Exporter<\/strong>\uff1a\u7528\u4e8e\u76d1\u63a7 Linux \u7cfb\u7edf\u7684\u786c\u4ef6\u548c\u64cd\u4f5c\u7cfb\u7edf\u7ea7\u522b\u7684\u6307\u6807\uff0c\u5982 CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3001\u78c1\u76d8 I\/O \u7b49\u3002<\/li>\n\n\n\n\n<li><strong>Blackbox Exporter<\/strong>\uff1a\u7528\u4e8e\u76d1\u63a7\u7f51\u7edc\u670d\u52a1\u7684\u53ef\u7528\u6027\uff0c\u652f\u6301 HTTP\u3001HTTPS\u3001DNS\u3001TCP \u7b49\u534f\u8bae\u7684\u63a2\u6d4b\u3002<\/li>\n\n\n\n\n<li><strong>MySQL Exporter<\/strong>\uff1a\u7528\u4e8e\u76d1\u63a7 MySQL \u6570\u636e\u5e93\u7684\u6027\u80fd\u6307\u6807\uff0c\u5982\u67e5\u8be2\u901f\u7387\u3001\u8fde\u63a5\u6570\u3001\u9501\u7b49\u5f85\u65f6\u95f4\u7b49\u3002<\/li>\n\n\n\n\n<li><strong>Redis Exporter<\/strong>\uff1a\u7528\u4e8e\u76d1\u63a7 Redis \u6570\u636e\u5e93\u7684\u6027\u80fd\u6307\u6807\uff0c\u5982\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3001\u547d\u4e2d\u7387\u3001\u8fde\u63a5\u6570\u7b49\u3002<\/li>\n\n\n\n\n<li><strong>Kafka Exporter<\/strong>\uff1a\u7528\u4e8e\u76d1\u63a7 Apache Kafka \u96c6\u7fa4\u7684\u6027\u80fd\u6307\u6807\uff0c\u5982\u6d88\u606f\u541e\u5410\u91cf\u3001\u5206\u533a\u72b6\u6001\u3001\u6d88\u8d39\u8005\u5ef6\u8fdf\u7b49\u3002<\/li>\n\n\n<\/ol>\n\n\n\n\n<h3>\u5982\u4f55\u4f7f\u7528 Exporter\uff1f<\/h3>\n\n\n\n\n<p>\u4f7f\u7528 Exporter \u7684\u8fc7\u7a0b\u901a\u5e38\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n\n\n\n\n<h4>1. \u5b89\u88c5 Exporter<\/h4>\n\n\n\n\n<p>\u9996\u5148\uff0c\u4f60\u9700\u8981\u6839\u636e\u4f60\u7684\u76d1\u63a7\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684 Exporter\uff0c\u5e76\u5c06\u5176\u5b89\u88c5\u5230\u76ee\u6807\u7cfb\u7edf\u4e0a\u3002\u5927\u591a\u6570 Exporter \u90fd\u63d0\u4f9b\u4e86\u9884\u7f16\u8bd1\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u4ece GitHub \u6216 Prometheus \u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u3002<\/p>\n\n\n\n\n<p>\u4ee5 <strong>Node Exporter<\/strong> \u4e3a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5728 Linux \u7cfb\u7edf\u4e0a\u5b89\u88c5\u5b83\uff1a<\/p>\n\n\n\n\n<pre><code class=\"language-bash\">wget https:\/\/github.com\/prometheus\/node_exporter\/releases\/download\/v1.3.1\/node_exporter-1.3.1.linux-amd64.tar.gz<br \/>\ntar xvfz node_exporter-1.3.1.linux-amd64.tar.gz<br \/>\ncd node_exporter-1.3.1.linux-amd64<br \/>\n.\/node_exporter<br \/>\n<\/code><\/pre>\n\n\n\n\n<h4>2. \u914d\u7f6e Exporter<\/h4>\n\n\n\n\n<p>\u5927\u591a\u6570 Exporter \u90fd\u652f\u6301\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u6216\u914d\u7f6e\u6587\u4ef6\u8fdb\u884c\u914d\u7f6e\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574 Exporter \u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u6307\u5b9a\u76d1\u542c\u7684\u7aef\u53e3\u3001\u542f\u7528\u6216\u7981\u7528\u67d0\u4e9b\u6307\u6807\u7b49\u3002<\/p>\n\n\n\n\n<p>\u4ee5 <strong>Node Exporter<\/strong> \u4e3a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u6307\u5b9a\u76d1\u542c\u7684\u7aef\u53e3\uff1a<\/p>\n\n\n\n\n<pre><code class=\"language-bash\">.\/node_exporter --web.listen-address=&quot;:9100&quot;<br \/>\n<\/code><\/pre>\n\n\n\n\n<h4>3. \u542f\u52a8 Exporter<\/h4>\n\n\n\n\n<p>\u5b89\u88c5\u548c\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u542f\u52a8 Exporter\u3002\u542f\u52a8\u540e\uff0cExporter \u4f1a\u5f00\u59cb\u76d1\u542c\u6307\u5b9a\u7684\u7aef\u53e3\uff0c\u5e76\u66b4\u9732\u76d1\u63a7\u6570\u636e\u7684 HTTP \u7aef\u70b9\u3002<\/p>\n\n\n\n\n<p>\u4ee5 <strong>Node Exporter<\/strong> \u4e3a\u4f8b\uff0c\u542f\u52a8\u540e\u4f60\u53ef\u4ee5\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee <code>http:\/\/localhost:9100\/metrics<\/code> \u6765\u67e5\u770b\u66b4\u9732\u7684\u76d1\u63a7\u6570\u636e\u3002<\/p>\n\n\n\n\n<h4>4. \u914d\u7f6e Prometheus \u6293\u53d6 Exporter \u6570\u636e<\/h4>\n\n\n\n\n<p>\u6700\u540e\uff0c\u4f60\u9700\u8981\u5728 Prometheus \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2a <strong>job<\/strong>\uff0c\u7528\u4e8e\u5b9a\u671f\u6293\u53d6 Exporter \u66b4\u9732\u7684\u76d1\u63a7\u6570\u636e\u3002<\/p>\n\n\n\n\n<p>\u4ee5 <strong>Node Exporter<\/strong> \u4e3a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u5728 Prometheus \u7684\u914d\u7f6e\u6587\u4ef6 <code>prometheus.yml<\/code> \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n\n<pre><code class=\"language-yaml\">scrape_configs:<br \/>\n  - job_name: 'node_exporter'<br \/>\n    static_configs:<br \/>\n      - targets: ['localhost:9100']<br \/>\n<\/code><\/pre>\n\n\n\n\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u91cd\u542f Prometheus \u670d\u52a1\uff0cPrometheus \u5c31\u4f1a\u5f00\u59cb\u5b9a\u671f\u6293\u53d6 Node Exporter \u66b4\u9732\u7684\u76d1\u63a7\u6570\u636e\u3002<\/p>\n\n\n\n\n<h3>Exporter \u7684\u9ad8\u7ea7\u7528\u6cd5<\/h3>\n\n\n\n\n<p>\u9664\u4e86\u57fa\u672c\u7684\u5b89\u88c5\u548c\u914d\u7f6e\uff0cExporter \u8fd8\u652f\u6301\u4e00\u4e9b\u9ad8\u7ea7\u7528\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u6ee1\u8db3\u590d\u6742\u7684\u76d1\u63a7\u9700\u6c42\u3002<\/p>\n\n\n\n\n<h4>1. \u81ea\u5b9a\u4e49\u6307\u6807<\/h4>\n\n\n\n\n<p>\u67d0\u4e9b Exporter \u5141\u8bb8\u4f60\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u6216\u547d\u4ee4\u884c\u53c2\u6570\u81ea\u5b9a\u4e49\u66b4\u9732\u7684\u6307\u6807\u3002\u4f8b\u5982\uff0c<strong>Node Exporter<\/strong> \u652f\u6301\u901a\u8fc7 <code>--collector.textfile.directory<\/code> \u53c2\u6570\u6307\u5b9a\u4e00\u4e2a\u76ee\u5f55\uff0c\u7528\u4e8e\u52a0\u8f7d\u81ea\u5b9a\u4e49\u7684\u6587\u672c\u6587\u4ef6\u6307\u6807\u3002<\/p>\n\n\n\n\n<h4>2. \u591a\u5b9e\u4f8b\u76d1\u63a7<\/h4>\n\n\n\n\n<p>\u5982\u679c\u4f60\u9700\u8981\u76d1\u63a7\u591a\u4e2a\u76f8\u540c\u7c7b\u578b\u7684\u5b9e\u4f8b\uff08\u4f8b\u5982\u591a\u4e2a MySQL \u6570\u636e\u5e93\uff09\uff0c\u4f60\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u5b9e\u4f8b\u90e8\u7f72\u4e00\u4e2a Exporter\uff0c\u5e76\u5728 Prometheus \u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u4e3a\u6bcf\u4e2a\u5b9e\u4f8b\u914d\u7f6e\u4e00\u4e2a\u72ec\u7acb\u7684 <strong>job<\/strong>\u3002<\/p>\n\n\n\n\n<h4>3. \u5b89\u5168\u914d\u7f6e<\/h4>\n\n\n\n\n<p>\u4e3a\u4e86\u786e\u4fdd\u76d1\u63a7\u6570\u636e\u7684\u5b89\u5168\u6027\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7 TLS \u52a0\u5bc6\u3001HTTP \u8ba4\u8bc1\u7b49\u65b9\u5f0f\u4fdd\u62a4 Exporter \u7684 HTTP \u7aef\u70b9\u3002\u5927\u591a\u6570 Exporter \u90fd\u652f\u6301\u8fd9\u4e9b\u5b89\u5168\u914d\u7f6e\u9009\u9879\u3002<\/p>\n\n\n\n\n<h3>\u603b\u7ed3<\/h3>\n\n\n\n\n<p><strong>Prometheus \u7684 Exporter<\/strong> \u662f Prometheus \u751f\u6001\u7cfb\u7edf\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u4f7f\u5f97 Prometheus \u80fd\u591f\u8f7b\u677e\u5730\u91c7\u96c6\u5404\u79cd\u7cfb\u7edf\u3001\u670d\u52a1\u548c\u5e94\u7528\u7a0b\u5e8f\u7684\u76d1\u63a7\u6570\u636e\u3002\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u5e94\u8be5\u5df2\u7ecf\u4e86\u89e3\u4e86 Exporter \u7684\u57fa\u672c\u6982\u5ff5\u3001\u5e38\u89c1\u7c7b\u578b\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u4eec\u3002\u65e0\u8bba\u662f\u76d1\u63a7 Linux \u7cfb\u7edf\u3001\u6570\u636e\u5e93\u8fd8\u662f\u7f51\u7edc\u670d\u52a1\uff0cExporter \u90fd\u80fd\u4e3a\u4f60\u63d0\u4f9b\u5f3a\u5927\u7684\u652f\u6301\u3002<\/p>\n\n\n\n\n<p>\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u7684\u76d1\u63a7\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684 Exporter\uff0c\u5e76\u901a\u8fc7\u914d\u7f6e\u548c\u4f18\u5316\uff0c\u5145\u5206\u53d1\u6325 Prometheus \u7684\u76d1\u63a7\u80fd\u529b\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528 Prometheus \u7684 Exporter\uff0c\u4e3a\u4f60\u7684\u76d1\u63a7\u7cfb\u7edf\u589e\u6dfb\u4e00\u4efd\u5f3a\u5927\u7684\u52a9\u529b\u3002<\/p>\n\n\n                ]]>\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\t\t\t\t<![CDATA[]]>\t\t<\/p>\n","protected":false},"author":5,"featured_media":23410,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-23409","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-discussion"],"_links":{"self":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/23409","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=23409"}],"version-history":[{"count":0,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/23409\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media\/23410"}],"wp:attachment":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media?parent=23409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/categories?post=23409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/tags?post=23409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}