{"id":175,"date":"2021-12-30T21:26:15","date_gmt":"2021-12-30T13:26:15","guid":{"rendered":"https:\/\/www.osvlabs.com\/blog\/?p=175"},"modified":"2021-12-31T11:15:36","modified_gmt":"2021-12-31T03:15:36","slug":"prometheusalertmanagergrafana%e5%ae%9e%e7%8e%b0%e4%b8%bb%e6%9c%ba%e7%9b%91%e6%8e%a7%e5%8f%8a%e5%91%8a%e8%ad%a6","status":"publish","type":"post","link":"https:\/\/blog.osvlabs.com\/?p=175","title":{"rendered":"Prometheus+AlertManager+Grafana\u5b9e\u73b0\u4e3b\u673a\u76d1\u63a7\u53ca\u544a\u8b66"},"content":{"rendered":"<h2>\u524d\u8a00<\/h2>\n<p>\u76d1\u63a7\u662f\u6574\u4e2a\u8fd0\u7ef4\u4e43\u81f3\u6574\u4e2a\u4ea7\u54c1\u751f\u547d\u5468\u671f\u4e2d\u6700\u91cd\u8981\u7684\u4e00\u73af\uff0c\u4e8b\u524d\u53ca\u65f6\u9884\u8b66\u53d1\u73b0\u6545\u969c\uff0c\u4e8b\u540e\u63d0\u4f9b\u8be6\u5b9e\u7684\u6570\u636e\u7528\u4e8e\u8ffd\u67e5\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n<p>\u4f7f\u7528Prometheus\u4f5c\u4e3a\u76d1\u63a7\u89e3\u51b3\u65b9\u6848\uff0c\u4e3b\u8981\u57fa\u4e8e\u4ee5\u4e0b\u539f\u56e0\uff1a<\/p>\n<ul>\n<li>\u4e91\u539f\u751f\u65f6\u4ee3\uff0c2016 \u5e74 Prometheus \u6210\u4e3a\u7ee7 k8s \u540e\uff0c\u662f\u7b2c\u4e8c\u540d CNCF(Cloud Native Computing Foundation) \u6210\u5458\u3002<\/li>\n<li>Kubeshpere\u81ea\u5e26\uff0c\u5b89\u88c5\u914d\u7f6e\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>Prometheus\u81ea\u5e26\u7684web\u754c\u9762\u5f88\u7b80\u6d01\uff0cGrafana\u652f\u6301\u6dfb\u52a0Prometheus\u4f5c\u4e3a\u6570\u636e\u6e90\uff0c\u914d\u5408\u540e\u53ef\u4ee5\u5c55\u793a\u6f02\u4eae\u7684\u76d1\u63a7\u5927\u5c4f<\/li>\n<\/ul>\n<h2>\u5927\u81f4\u6d41\u7a0b\uff1a<\/h2>\n<ul>\n<li>\u88ab\u76d1\u63a7\u4e3b\u673a\u5b89\u88c5node_exporter\uff0c\u8fd0\u884c\u540e\u66b4\u9732\u51fa\u4e00\u4e2a\u4f9b\u91c7\u96c6\u5404\u4e2a\u6307\u6807(\u5982\u57fa\u672cCPU\uff0c\u5185\u5b58\uff0c\u78c1\u76d8\u5bb9\u91cf\uff0c\u7f51\u7edc\u60c5\u51b5\u7b49)\u7684http\u5730\u5740<\/li>\n<li>\u5b89\u88c5AlertManager\uff0c\u914d\u7f6e\u544a\u8b66\u901a\u77e5\u7b56\u7565\uff0c\u5982\u5b9a\u4e49\u4e86CPU\uff0c\u5185\u5b58\u548c\u786c\u76d8\u4e09\u4e2a\u89c4\u5219\uff0c\u5f53\u89e6\u53d1CPU\u62a5\u8b66\u89c4\u5219\u8d70SMTP\u90ae\u7bb1\uff0c\u5176\u4f59\u8d70webhook\uff0cslack\uff0c\u6bcf\u4e00\u5c0f\u65f6\u6700\u591a\u63d0\u9192\u4e00\u6b21<\/li>\n<li>\u5b89\u88c5Prometheus\uff0c\u914d\u7f6e\u76d1\u63a7\u91c7\u96c6\u7684\u5177\u4f53\u4fe1\u606f\uff0c\u5982\u91c7\u96c6\u9891\u7387\uff0c\u91c7\u96c6\u5730\u5740\uff0c\u5f53\u89e6\u53d1\u62a5\u8b66\u89c4\u5219\u901a\u77e5\u7ed9AlertManager<\/li>\n<li>Grafana\u5c06\u6570\u636e\u53ef\u89c6\u5316\uff0c\u66f4\u76f4\u89c2\u7684\u67e5\u770b\u88ab\u76d1\u63a7\u4e3b\u673a\u5404\u4e2a\u6307\u6807\u4fe1\u606f\uff0c\u5305\u542b\u76f4\u65b9\u56fe\uff0c\u66f2\u7ebf\u56fe\u56fe\uff0c\u997c\u56fe\u7b49\uff0c\u9700\u8981\u5c06\u6570\u636e\u6e90\u914d\u7f6e\u4e3aPrometheus<\/li>\n<\/ul>\n<h2>\u73af\u5883<\/h2>\n<p>\u4e24\u53f0Linux\u4e3b\u673a<br \/>\n127.0.0.10 \u88ab\u76d1\u63a7\u4e3b\u673a\uff0c\u8fd0\u884cnode_exporter<br \/>\n127.0.0.11 \u8fd0\u884cPrometheus\uff0cAlertManager\uff0cGrafana<\/p>\n<p>\u6d4b\u8bd5\u65f6\u53ef\u4ee5\u7528\u81ea\u5df1\u7684\u4e00\u53f0\u4e3b\u673a\uff0c\u81ea\u5df1\u76d1\u63a7\u81ea\u5df1..<\/p>\n<h2>Prometheus<\/h2>\n<p>\u9996\u5148\u4ecb\u7ecdPrometheus\uff0c\u5b98\u65b9\u67b6\u6784\u56fe<\/p>\n<p><a href=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/image.png\"><img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/image.png\" alt=\"\" \/><\/a><\/p>\n<p>Prometheus\u7684\u7279\u70b9<br \/>\n\u25cf \u591a\u7ef4\u5ea6\u6570\u636e\u6a21\u578b\u3002<br \/>\n\u25cf \u63d0\u4f9b\u81ea\u5df1\u7684\u7075\u6d3b\u7684\u67e5\u8be2\u8bed\u8a00\u3002PromQL<br \/>\n\u25cf \u4e0d\u4f9d\u8d56\u5206\u5e03\u5f0f\u5b58\u50a8\uff0c\u5355\u4e2a\u670d\u52a1\u5668\u8282\u70b9\u662f\u81ea\u4e3b\u7684\u3002<br \/>\n\u25cf \u901a\u8fc7\u57fa\u4e8eHTTP\u7684pull\u65b9\u5f0f\u91c7\u96c6\u65f6\u5e8f\u6570\u636e\u3002<br \/>\n\u25cf \u53ef\u4ee5\u901a\u8fc7\u4e2d\u95f4\u7f51\u5173\u8fdb\u884c\u65f6\u5e8f\u5217\u6570\u636e\u63a8\u9001\u3002<br \/>\n\u25cf \u901a\u8fc7\u670d\u52a1\u53d1\u73b0\u6216\u8005\u9759\u6001\u914d\u7f6e\u6765\u53d1\u73b0\u76ee\u6807\u670d\u52a1\u5bf9\u8c61\u3002<br \/>\n\u25cf \u652f\u6301\u591a\u79cd\u591a\u6837\u7684\u56fe\u8868\u548c\u754c\u9762\u5c55\u793a\uff0c\u6bd4\u5982Grafana\u7b49\u3002<\/p>\n<p>Prometheus\u5305\u542b\u7684\u529f\u80fd\u6a21\u5757\uff1a<br \/>\n\u25cf \u5185\u7f6e\u4e86\u4e00\u4e2aHTTP server\uff0c\u7528\u6765\u63d0\u4f9b\u4e86Web\u754c\u9762<br \/>\n\u25cf TSDB\uff1a\u65f6\u5e8f\u6570\u636e\u5e93\uff0c\u7528\u6765\u5b58\u50a8\u6293\u53d6\u5230\u7684\u6570\u636e\uff0c\u4f9b\u67e5\u8be2\u548c\u56fe\u8868\u5c55\u793a<br \/>\n\u25cf \u91c7\u96c6\u7a0b\u5e8f\uff0c\u6839\u636e\u914d\u7f6e\u6587\u4ef6\u7684\u76ee\u6807\u5730\u5740\u53bb\u6293\u53d6\u6307\u6807<br \/>\n\u25cf PromQL\uff1aPromQL\u662fPrometheus\u5185\u7f6e\u7684\u6570\u636e\u67e5\u8be2\u8bed\u8a00\uff0c\u5176\u63d0\u4f9b\u5bf9\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u4e30\u5bcc\u7684\u67e5\u8be2\uff0c\u805a\u5408\u4ee5\u53ca\u903b\u8f91\u8fd0\u7b97\u80fd\u529b\u7684\u652f\u6301<br \/>\n\u25cf Push Gateway\uff1a \u9ed8\u8ba4\u60c5\u51b5\u4e0bPrometheus\u662f\u53bb\u76ee\u6807pull\u62c9\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u8ba9\u76ee\u6807\u4e3b\u52a8push\u63a8\u6570\u636e\uff0c\u8fd9\u4e2a\u4e0d\u5e38\u7528<br \/>\n\u25cf Service discovery\uff1a \u670d\u52a1\u53d1\u73b0\uff0c\u6bd4\u5982k8s\u96c6\u7fa4\u6709N\u53f0\u4e3b\u673a\uff0cIP\u5730\u5740\u548c\u6570\u91cf\u53ef\u80fd\u4e0d\u662f\u56fa\u5b9a\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba9Prometheus\u81ea\u52a8\u53d1\u73b0\u96c6\u7fa4\u4e2d\u6240\u6709\u7684\u8282\u70b9\uff0c\u964d\u4f4e\u7ef4\u62a4\u6210\u672c\u3002<\/p>\n<h2>\u90e8\u7f72node_exporter\u5230\u76d1\u6d4b\u8282\u70b9<\/h2>\n<p>node_exporter\u4e3b\u8981\u7528\u6765\u76d1\u63a7\u670d\u52a1\u5668\u7684\u57fa\u7840\u4fe1\u606f\uff0c\u5982: cpu\u3001\u5185\u5b58\u3001\u78c1\u76d8\u3001\u7f51\u5361<br \/>\n\u7c7b\u4f3c\u7684\uff1a<br \/>\nmysql_exporter: Prometheus \u5b98\u65b9\u9879\u76ee\uff0c\u53ef\u4ee5\u91c7\u96c6mysql\u5404\u9879\u8fd0\u884c\u6307\u6807<br \/>\nblackbox_exporter: Prometheus \u5b98\u65b9\u9879\u76ee\uff0c\u7f51\u7edc\u63a2\u6d4b\uff0cdns\u3001ping\u3001http\u76d1\u63a7<br \/>\nprocess-exporter: \u91c7\u96c6\u8fdb\u7a0b\u6307\u6807<\/p>\n<p>exporter\u6709\u5b98\u65b9\u7684\u548c\u7b2c\u4e09\u65b9\u7684\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5df1\u5236\u4f5cexporter<\/p>\n<p>\u7531\u4e8ePrometheus+AlertManager+NodeExporter\u90fd\u662fgo\u8bed\u8a00\u5f00\u53d1\u7684\uff0c\u7f16\u8bd1\u5b8c\u5c31\u662f\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u653e\u5230\u7cfb\u7edf\u73af\u5883\u76ee\u5f55\u5373\u53ef\uff0c\u6216\u8005\u4f7f\u7528docker\u8fd0\u884c<\/p>\n<p><a href=\"https:\/\/hub.docker.com\/r\/prom\/node-exporter\">https:\/\/hub.docker.com\/r\/prom\/node-exporter<\/a><br \/>\n<a href=\"https:\/\/hub.docker.com\/r\/prom\/prometheus\">https:\/\/hub.docker.com\/r\/prom\/prometheus<\/a><br \/>\n<a href=\"https:\/\/hub.docker.com\/r\/prom\/alertmanager\">https:\/\/hub.docker.com\/r\/prom\/alertmanager<\/a><\/p>\n<p>\u7531\u4e8e\u6211\u4eec\u8981\u4f7f\u7528NodeExporter\u91c7\u96c6\u4e3b\u673a\u4fe1\u606f\uff0c\u8fd9\u91cc\u76f4\u63a5\u5b89\u88c5\u5230\u4e3b\u673a\u4e0a\u9762<\/p>\n<pre><code>wget https:\/\/github.com\/prometheus\/node_exporter\/releases\/download\/v1.3.1\/node_exporter-1.3.1.linux-amd64.tar.gz\ntar -xzvf node_exporter-1.3.1.linux-amd64.tar.gz\nmv node_exporter \/usr\/local\/bin<\/code><\/pre>\n<h3>\u505a\u6210\u7cfb\u7edf\u670d\u52a1<\/h3>\n<p>\u65b9\u4fbf\u968f\u7cfb\u7edf\u542f\u52a8<\/p>\n<p><code>vi \/etc\/systemd\/system\/node_exporter.service<\/code><\/p>\n<pre><code>[Unit]\nDescription=node_exporter\nDocumentation=https:\/\/prometheus.io\/\nAfter=network.target\n[Service]\nType=simple\nUser=ubuntu\nExecStart=\/usr\/local\/bin\/node_exporter --web.listen-address=&quot;:9100&quot;\nRestart=on-failure\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<pre><code>systemctl enable node_exporter\nsystemctl start node_exporter<\/code><\/pre>\n<p>\u6d4f\u89c8\u5668\u6253\u5f00 127.0.0.1:9100 \u5c31\u4f1a\u770b\u5230\u5404\u4e2a\u6307\u6807\u4fe1\u606f\u7684\u9875\u9762<\/p>\n<p>\u5217\u51fa\u4e00\u4e9bCPU\u76f8\u5173\u7684<\/p>\n<pre><code># HELP node_cpu_seconds_total Seconds the CPUs spent in each mode.\n# #\u5f53\u524d\u4e3b\u673a\u7684CPU\uff0c0,1\u4e24\u6838\n# TYPE node_cpu_seconds_total counter\n# CPU0 \u7684 \u7a7a\u95f2CPU\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;idle&quot;} 2.28999034e+06 \n# #CPU0 \u7684 io\u4f7f\u7528\u91cf\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;iowait&quot;} 15581.96\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;irq&quot;} 0\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;nice&quot;} 15.26\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;softirq&quot;} 7405.25\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;steal&quot;} 0\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;system&quot;} 566896.41\nnode_cpu_seconds_total{cpu=&quot;0&quot;,mode=&quot;user&quot;} 1.22605032e+06\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;idle&quot;} 2.28415856e+06\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;iowait&quot;} 10769.86\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;irq&quot;} 0\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;nice&quot;} 17.36\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;softirq&quot;} 7074.85\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;steal&quot;} 0\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;system&quot;} 565591.15\nnode_cpu_seconds_total{cpu=&quot;1&quot;,mode=&quot;user&quot;} 1.2386354e+06\n......<\/code><\/pre>\n<p>\u5982\u679cnode_exoporter\u8dd1\u5728\u670d\u52a1\u5668\uff0c\u6ce8\u610f\u9632\u706b\u5899\u5f00\u653e\u76f8\u5173\u7aef\u53e3<\/p>\n<h2>\u90e8\u7f72alertManager<\/h2>\n<p>\u4e0b\u8f7d\uff0c\u5b89\u88c5\u548cnode_exporter\u4e00\u6837\uff0c\u7565\u8fc7<\/p>\n<p>\u65b0\u5efaalertmanager\u914d\u7f6e\u6587\u4ef6, alertmanaget.yaml<\/p>\n<pre><code>global:\n  # \u6bcf\u4e00\u5206\u949f\u68c0\u67e5\u4e00\u6b21\u662f\u5426\u6062\u590d\n  resolve_timeout: 1m\n  smtp_from: &#039;yourname@qq.com&#039;&#039;\n  # The default hostname to identify to the SMTP server.\n  smtp_hello: &#039;yourname@qq.com&#039;&#039;\n  smtp_smarthost: &#039;smtp.exmail.qq.com:465&#039;\n  smtp_auth_username: &#039;yourname@qq.com&#039;\n  smtp_auth_password: &#039;xxx&#039;\n  smtp_require_tls: false\n# \u6240\u6709\u62a5\u8b66\u4fe1\u606f\u8fdb\u5165\u540e\u7684\u6839\u8def\u7531\uff0c\u7528\u6765\u8bbe\u7f6e\u62a5\u8b66\u7684\u5206\u53d1\u7b56\u7565\nroute:\n  # \u8fdb\u6765\u7684\u62a5\u8b66\u4fe1\u606f\u4f1a\u5e26\u6709\u6807\u7b7e\uff0c\u6307\u5b9a\u6839\u636e\u54ea\u4e9b\u6807\u7b7e\u8fdb\u884c\u5206\u7ec4\n  group_by: [alertname]\n  # \u7ec4\u544a\u8b66\u7b49\u5f85\u65f6\u95f4\u3002\u4e5f\u5c31\u662f\u544a\u8b66\u4ea7\u751f\u540e\u7b49\u5f8510s\uff0c\u5982\u679c\u6709\u540c\u7ec4\u544a\u8b66\u4e00\u8d77\u53d1\u51fa\n  group_wait: 10s\n  # \u4e24\u7ec4\u544a\u8b66\u7684\u95f4\u9694\u65f6\u95f4\n  group_interval: 10s\n  # \u91cd\u590d\u544a\u8b66\u7684\u95f4\u9694\u65f6\u95f4\uff0c\u51cf\u5c11\u76f8\u540c\u544a\u8b66\u7684\u53d1\u9001\u9891\u7387\n  repeat_interval: 1h\n  #\u8bbe\u7f6e\u9ed8\u8ba4\u63a5\u6536\u4eba\n  receiver: &#039;webhook&#039;\n  # \u5b50\u8def\u7531, \u7528\u6765\u8986\u76d6\u914d\u7f6e\n  routes:\n  - receiver: webhook\n    continue: true\n    group_wait: 10s\n    match:\n      team: node\nreceivers:\n- name: &#039;email&#039;\n  email_configs:\n  - to: &#039;receiver@qq.com&#039;\n    send_resolved: true<\/code><\/pre>\n<p>\u8fd0\u884c\u65f6\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6<code>--config.file=\/etc\/alertmanager\/alertmanager.yml<\/code><br \/>\n\u9ed8\u8ba4\u7aef\u53e3\u662f9093<\/p>\n<h2>\u90e8\u7f72prometheus<\/h2>\n<p>\u4e0b\u8f7d\uff0c\u5b89\u88c5\u548cnode_exporter\u4e00\u6837\uff0c\u7565\u8fc7<\/p>\n<p>\u91c7\u96c6\u7684\u6570\u636e\u53ea\u4fdd\u7559\u6700\u8fd17\u5929<br \/>\n&#8211;storage.tsdb.retention.time=7d<br \/>\n\u6570\u636e\u4fdd\u5b58\u7684\u76ee\u5f55<br \/>\n&#8211;storage.tsdb.path<\/p>\n<pre><code>[Unit]\nDescription=Prometheus\nDocumentation=https:\/\/prometheus.io\/\nAfter=network.target\n[Service]\nType=simple\nExecStart=\/usr\/local\/bin\/prometheus --config.file=&quot;main.yaml&quot; --storage.tsdb.retention.time=7d --web.enable-admin-api --web.enable-lifecycle\nRestart=on-failure\n[Install]\nWantedBy=multi-user.target<\/code><\/pre>\n<p>\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\uff0c\u5e76\u68c0\u67e5\u670d\u52a1\u5f00\u542f\u72b6\u6001<\/p>\n<pre><code>sudo systemctl enable prometheus\nsudo systemctl start prometheus\nsudo systemctl status prometheus<\/code><\/pre>\n<p>Prometheus\u8fd0\u884c\u524d\uff0c\u6211\u4eec\u8981\u63d0\u524d\u5199\u597d\u89c4\u5219\uff0c\u5f53\u89c4\u5219\u6ee1\u8db3\uff0c\u6211\u4eec\u53ef\u4ee5\u89e6\u53d1\u62a5\u8b66\uff0cAlertmanager\u5c31\u662f\u4e13\u95e8\u5904\u7406\u5404\u79cd\u62a5\u8b66\u7684\uff0c\u652f\u6301\u5982email\uff0cwebhook\uff0cslack\u7b49\u63d0\u9192<\/p>\n<p>\u65b0\u5efa rules\/cpu_over.yml, \u6ce8\u610fexpr\uff0c\u5c31\u662f\u4e0a\u8ff0\u63d0\u5230\u7684PromQL<\/p>\n<pre><code>groups:\n- name: CPU\u62a5\u8b66\u89c4\u5219\n  rules:\n  - alert: CPU\u4f7f\u7528\u7387\u544a\u8b66 # \u8b66\u544a\u540d\n    # \u89e6\u53d1\u89c4\u5219\n    expr: 100 - (avg by(instance) (irate(node_cpu_seconds_total{mode=&quot;idle&quot;}[1m]))) * 100 &gt; 80\n    # \u89c4\u5219\u89e6\u53d1\u6301\u7eed\u591a\u957f\u65f6\u95f4\u53d1\u9001\u544a\u8b66\n    for: 30m\n    # \u544a\u8b66\u9644\u52a0\u6807\u7b7e\n    labels:\n      severity: warning\n    # \u544a\u8b66\u9644\u52a0\u6ce8\u91ca\n    annotations:\n      summary: &quot;CPU\u4f7f\u7528\u7387\u6b63\u5728\u98d9\u5347\u3002&quot;\n      description: &quot;CPU\u4f7f\u7528\u7387\u8d85\u8fc780%\uff08\u5f53\u524d\u503c\uff1a{{ humanize $value }}%\uff09&quot;<\/code><\/pre>\n<p>\u5173\u4e8emain.yaml\u4e3b\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre><code># my global config\nglobal:\n  scrape_interval: 15s #15s\u6293\u53d6\u4e00\u6b21\u76ee\u6807\u6307\u6807\uff0c\u9ed8\u8ba41\u5206\u949f.\n  evaluation_interval: 15s # 15\u662f\u8bc4\u4f30\u4e00\u6b21\u662f\u5426\u89e6\u53d1\u89c4\u5219\uff0c\u9ed8\u8ba41\u5206\u949f.\n  # scrape_timeout is set to the global default (10s).\n\n# Alertmanager configuration\nalerting:\n  alertmanagers:\n    - static_configs:\n      - targets: [&#039;127.0.0.11:9093&#039;]\n\n# Load rules once and periodically evaluate them according to the global &#039;evaluation_interval&#039;.\n\nrule_files:\n  - \/etc\/prometheus\/rules\/*.yml\n\n# A scrape configuration containing exactly one endpoint to scrape:\n# \u8fd9\u91cc\u8868\u793a\u6293\u53d6\u5bf9\u8c61\u7684\u914d\u7f6e\n# Here it&#039;s Prometheus itself.\n# \u8fd9\u91cc\u662f\u6293\u53d6promethues\u81ea\u8eab\u7684\u914d\u7f6e\nscrape_configs:\n  # The job name is added as a label `job=&lt;job_name&gt;` to any timeseries scraped from this config.\n  # \u8fd9\u4e2a\u914d\u7f6e\u662f\u8868\u793a\u5728\u8fd9\u4e2a\u914d\u7f6e\u5185\u7684\u65f6\u95f4\u5e8f\u4f8b\uff0c\u6bcf\u4e00\u6761\u90fd\u4f1a\u81ea\u52a8\u6dfb\u52a0\u4e0a\u8fd9\u4e2a{job_name:&quot;prometheus&quot;}\u7684\u6807\u7b7e\u3002\n  - job_name: &quot;node1&quot;\n    scrape_interval: 15s\n    static_configs:\n      - targets: [&quot;127.0.0.10:9100&quot;]<\/code><\/pre>\n<h2>Grafana \u5b89\u88c5<\/h2>\n<p>\u6211\u4eec\u7528Docker\u5b89\u88c5 <a href=\"https:\/\/hub.docker.com\/r\/grafana\/grafana\">https:\/\/hub.docker.com\/r\/grafana\/grafana<\/a><br \/>\n\u9996\u5148\u6dfb\u52a0\u6570\u636e\u6e90<\/p>\n<p><a href=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/1640870241894.jpg\"><img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/1640870241894.jpg\" alt=\"\" \/><\/a><\/p>\n<p><a href=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/1640870306391.jpg\"><img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/1640870306391.jpg\" alt=\"\" \/><\/a><\/p>\n<p>\u76f4\u63a5\u5bfc\u5165\u522b\u4eba\u5236\u4f5c\u597d\u7684dashboard\uff0c\u6240\u8c13dashboard\uff0c\u7531\u5f88\u591a\u56fe\u8868\u6784\u6210\uff0c\u6bcf\u4e2a\u56fe\u8868\u7531\u5750\u6807\u8f74\uff0c\u9ad8\u5bbd\u548cPromQL\u67e5\u8be2\u8868\u8fbe\u5f0f\u7b49\u4fe1\u606f\u7ec4\u6210<\/p>\n<p><a href=\"https:\/\/grafana.com\/grafana\/dashboards\/8919\">https:\/\/grafana.com\/grafana\/dashboards\/8919<\/a><br \/>\n<a href=\"https:\/\/grafana.com\/api\/dashboards\/8919\/revisions\/24\/download\">https:\/\/grafana.com\/api\/dashboards\/8919\/revisions\/24\/download<\/a><\/p>\n<p><a href=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/WechatIMG1327.png\"><img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/WechatIMG1327.png\" alt=\"\" \/><\/a><\/p>\n<p>\u6700\u7ec8\u6548\u679c\u5982\u56fe<\/p>\n<p><a href=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/1640870747725-scaled.jpg\"><img src=\"https:\/\/blog.osvlabs.com\/wp-content\/uploads\/2021\/12\/1640870747725-scaled.jpg\" alt=\"\" \/><\/a><\/p>\n<h2>\u53c2\u8003<\/h2>\n<p><a href=\"https:\/\/songjiayang.gitbooks.io\/prometheus\/content\/\">https:\/\/songjiayang.gitbooks.io\/prometheus\/content\/<\/a><\/p>\n<p><a href=\"https:\/\/www.yuque.com\/mafeifan\/qo2a9q\/\">https:\/\/www.yuque.com\/mafeifan\/qo2a9q\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u76d1\u63a7\u662f\u6574\u4e2a\u8fd0\u7ef4\u4e43\u81f3\u6574\u4e2a\u4ea7\u54c1\u751f\u547d\u5468\u671f\u4e2d\u6700\u91cd\u8981\u7684\u4e00\u73af\uff0c\u4e8b\u524d\u53ca\u65f6\u9884\u8b66\u53d1\u73b0\u6545\u969c\uff0c\u4e8b\u540e\u63d0\u4f9b\u8be6\u5b9e\u7684\u6570\u636e\u7528\u4e8e\u8ffd\u67e5\u5b9a\u4f4d\u95ee\u9898\u3002 \u4f7f\u7528Prometheus\u4f5c\u4e3a\u76d1\u63a7\u89e3\u51b3\u65b9\u6848\uff0c\u4e3b\u8981\u57fa\u4e8e\u4ee5\u4e0b\u539f\u56e0\uff1a \u4e91\u539f\u751f\u65f6\u4ee3\uff0c2016 \u2026<\/p>\n","protected":false},"author":1,"featured_media":180,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"_links":{"self":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/175"}],"collection":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=175"}],"version-history":[{"count":3,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":183,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/posts\/175\/revisions\/183"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=\/wp\/v2\/media\/180"}],"wp:attachment":[{"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.osvlabs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}