{"id":1862,"date":"2020-07-01T06:49:13","date_gmt":"2020-06-30T22:49:13","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1862"},"modified":"2020-07-01T06:49:13","modified_gmt":"2020-06-30T22:49:13","slug":"prometheus-%e6%9f%a5%e8%af%a2%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1862","title":{"rendered":"Prometheus \u67e5\u8be2\u8bf4\u660e"},"content":{"rendered":"<div id=\\\"cnblogs_post_body\\\">\n<h2>1.Prothetheus\u67e5\u8be2<\/h2>\n<div>\n<div>Prometheus\u63d0\u4f9b\u4e00\u4e2a\u51fd\u6570\u5f0f\u7684\u8868\u8fbe\u5f0f\u8bed\u8a00PromQL (Prometheus Query Language)\uff0c\u53ef\u4ee5\u4f7f\u7528\u6237\u5b9e\u65f6\u5730\u67e5\u627e\u548c\u805a\u5408\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u8868\u8fbe\u5f0f\u8ba1\u7b97\u7ed3\u679c\u53ef\u4ee5\u5728\u56fe\u8868\u4e2d\u5c55\u793a\uff0c\u4e5f\u53ef\u4ee5\u5728\u8868\u8fbe\u5f0f\u6d4f\u89c8\u5668\u4e2d\u4ee5\u8868\u683c\u5f62\u5f0f\u5c55\u793a\uff0c\u6216\u8005\u4f5c\u4e3a\u6570\u636e\u6e90, \u4ee5HTTP API\u7684\u65b9\u5f0f\u63d0\u4f9b\u7ed9\u5916\u90e8\u7cfb\u7edf\u4f7f\u7528\u3002<\/div>\n<div>\n<div>\n<h3><\/h3>\n<h3>2.\u8868\u8fbe\u5f0f\u8bed\u8a00\u6570\u636e\u7c7b\u578b<\/h3>\n<p>\u5728Prometheus\u7684\u8868\u8fbe\u5f0f\u8bed\u8a00\u4e2d\uff0c\u4efb\u4f55\u8868\u8fbe\u5f0f\u6216\u8005\u5b50\u8868\u8fbe\u5f0f\u90fd\u53ef\u4ee5\u5f52\u4e3a\u56db\u79cd\u7c7b\u578b\uff1a<\/p>\n<ul>\n<li>instant vector\u00a0\u77ac\u65f6\u5411\u91cf\uff1a\u5b83\u662f\u6307\u5728\u540c\u4e00\u65f6\u523b\uff0c\u6293\u53d6\u7684\u6240\u6709\u5ea6\u91cf\u6307\u6807\u6570\u636e\u3002\u8fd9\u4e9b\u5ea6\u91cf\u6307\u6807\u6570\u636e\u7684key\u90fd\u662f\u76f8\u540c\u7684\uff0c\u4e5f\u5373\u76f8\u540c\u7684\u65f6\u95f4\u6233<\/li>\n<li>range vector\u00a0\u8303\u56f4\u5411\u91cf\uff1a\u5b83\u662f\u6307\u5728\u4efb\u4f55\u4e00\u4e2a\u65f6\u95f4\u8303\u56f4\u5185\uff0c\u6293\u53d6\u7684\u6240\u6709\u5ea6\u91cf\u6307\u6807\u6570\u636e<\/li>\n<li>scalar\u00a0\u6807\u91cf\uff1a\u4e00\u4e2a\u7b80\u5355\u7684\u6d6e\u70b9\u503c<\/li>\n<li>string\u00a0\u5b57\u7b26\u4e32\uff1a\u4e00\u4e2a\u5f53\u524d\u6ca1\u6709\u88ab\u4f7f\u7528\u7684\u7b80\u5355\u5b57\u7b26\u4e32<\/li>\n<\/ul>\n<\/div>\n<p>\u6839\u636e\u7528\u4f8b\uff08\u4f8b\u5982\u5728\u7ed8\u5236\u56fe\u5f62\u6216\u663e\u793a\u8868\u8fbe\u5f0f\u7684\u8f93\u51fa\u65f6\uff09\uff0c\u7531\u4e8e\u7528\u6237\u6307\u5b9a\u7684\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\uff0c\u5176\u4e2d\u53ea\u6709\u67d0\u4e9b\u7c7b\u578b\u662f\u5408\u6cd5\u7684\u3002 \u4f8b\u5982\uff0c\u8fd4\u56de\u77ac\u65f6\u5411\u91cf\u7684\u8868\u8fbe\u5f0f\u662f\u552f\u4e00\u53ef\u4ee5\u76f4\u63a5\u7ed8\u5236\u56fe\u5f62\u7684\u7c7b\u578b\u3002<\/p><\/div>\n<div>\n<h3><\/h3>\n<h3>3.\u5b57\u9762\u91cf<\/h3>\n<h3>3.1 \u5b57\u7b26\u4e32\u5b57\u9762\u91cf<\/h3>\n<p>\u5b57\u7b26\u4e32\u53ef\u4ee5\u7528\u5355\u5f15\u53f7\uff0c\u53cc\u5f15\u53f7\u6216\u53cd\u5f15\u53f7\u6307\u5b9a\u4e3a\u6587\u5b57\u3002PromQL\u9075\u5faa\u4e0eGo\u76f8\u540c\u7684<a href=\\\"https:\/\/golang.org\/ref\/spec#String_literals\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">\u8f6c\u4e49\u89c4\u5219<\/a>\u3002\u5728\u5355\u5f15\u53f7\uff0c\u53cc\u5f15\u53f7\u4e2d\uff0c\u53cd\u659c\u6760\u6210\u4e3a\u4e86\u8f6c\u4e49\u5b57\u7b26\uff0c\u540e\u9762\u53ef\u4ee5\u8ddf\u7740a,b,\u00a0f,\u00a0n,\u00a0r,\u00a0t,\u00a0v\u6216\u8005\\\\\u3002 \u53ef\u4ee5\u4f7f\u7528\u516b\u8fdb\u5236(\\\\nnn)\u6216\u8005\u5341\u516d\u8fdb\u5236(\\\\xnn,\u00a0\\\\unnnn\u548c\\\\Unnnnnnnn)\u63d0\u4f9b\u7279\u5b9a\u5b57\u7b26\u3002\u5728\u53cd\u5f15\u53f7\u5185\u4e0d\u5904\u7406\u8f6c\u4e49\u5b57\u7b26\u3002\u4e0eGo\u4e0d\u540c\uff0cPrometheus\u4e0d\u4f1a\u4e22\u5f03\u53cd\u5f15\u53f7\u4e2d\u7684\u6362\u884c\u7b26\u3002\u4f8b\u5982\uff1a<\/p>\n<div>\n<pre>\\\"this is a string\\\"\n\\'these are unescaped: \\\\n \\\\\\\\ \\\\t\\'\n`these are not unescaped: \\\\n \\' \\\" \\\\t\\\"\\'`<\/pre>\n<\/div>\n<h3>3.2 \u6d6e\u70b9\u6570\u5b57\u9762\u91cf<\/h3>\n<p>\u6807\u91cf\u6d6e\u70b9\u503c\u53ef\u4ee5\u76f4\u63a5\u5199\u6210\u5f62\u5f0f[-](digits)[.(digits)]\u3002<\/p>\n<div>\n<pre>-2.43<\/pre>\n<\/div>\n<h3><\/h3>\n<h3>\u65f6\u95f4\u5e8f\u5217\u9009\u62e9\u5668<\/h3>\n<h3>4.1 \u77ac\u65f6\u5411\u91cf\u9009\u62e9\u5668<\/h3>\n<div>\n\u77ac\u65f6\u5411\u91cf\u9009\u62e9\u5668\u5141\u8bb8\u5728\u7ed9\u5b9a\u65f6\u95f4\u6233\uff08\u5373\u65f6\uff09\u4e3a\u6bcf\u4e2a\u9009\u62e9\u4e00\u7ec4\u65f6\u95f4\u5e8f\u5217\u548c\u5355\u4e2a\u6837\u672c\u503c\uff1a\u5728\u6700\u7b80\u5355\u7684\u5f62\u5f0f\u4e2d\uff0c\u4ec5\u6307\u5b9a\u5ea6\u91cf\u540d\u79f0\u3002 \u8fd9\u4f1a\u751f\u6210\u5305\u542b\u5177\u6709\u6b64\u5ea6\u91cf\u6807\u51c6\u540d\u79f0\u7684\u6240\u6709\u65f6\u95f4\u5e8f\u5217\u7684\u5143\u7d20\u7684\u5373\u65f6\u5411\u91cf\u3002<br \/>\n\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\u9009\u62e9\u6240\u6709\u65f6\u95f4\u5e8f\u5217\u5ea6\u91cf\u540d\u79f0\u4e3ahttp_requests_total\u7684\u6837\u672c\u6570\u636e\uff1a<\/p>\n<div>\n<pre>http_requests_total<\/pre>\n<\/div>\n<div>\n\u901a\u8fc7\u5728\u5ea6\u91cf\u6307\u6807\u540e\u9762\u589e\u52a0{}\u4e00\u7ec4\u6807\u7b7e\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5730\u8fc7\u6ee4\u8fd9\u4e9b\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002<br \/>\n\u6b64\u793a\u4f8b\u4ec5\u9009\u62e9\u5177\u6709http_requests_total\u5ea6\u91cf\u6807\u51c6\u540d\u79f0\u7684\u65f6\u95f4\u7cfb\u5217\uff0c\u8be5\u540d\u79f0\u4e5f\u5c06job\u6807\u7b7e\u8bbe\u7f6e\u4e3aprometheus\uff0c\u5e76\u5c06\u5176group\u6807\u7b7e\u8bbe\u7f6e\u4e3acanary\uff1a<\/p>\n<div>\n<pre>http_requests_total{job=\\\"prometheus\\\",group=\\\"canary\\\"}<\/pre>\n<\/div>\n<div>\n<div>\n\u53ef\u4ee5\u91c7\u7528\u4e0d\u5339\u914d\u7684\u6807\u7b7e\u503c\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u6216\u8005\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u4e0d\u5339\u914d\u6807\u7b7e\u3002\u6807\u7b7e\u5339\u914d\u64cd\u4f5c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<ul>\n<li>=\u00a0\u00a0: \u7cbe\u786e\u5730\u5339\u914d\u6807\u7b7e\u7ed9\u5b9a\u7684\u503c<\/li>\n<li>!=\u00a0: \u4e0d\u7b49\u4e8e\u7ed9\u5b9a\u7684\u6807\u7b7e\u503c<\/li>\n<li>=~\u00a0: \u6b63\u5219\u8868\u8fbe\u5339\u914d\u7ed9\u5b9a\u7684\u6807\u7b7e\u503c<\/li>\n<li>!~\u00a0: \u7ed9\u5b9a\u7684\u6807\u7b7e\u503c\u4e0d\u7b26\u5408\u6b63\u5219\u8868\u8fbe\u5f0f<\/li>\n<\/ul>\n<p>\u4f8b\u5982\uff1a\u5ea6\u91cf\u6307\u6807\u540d\u79f0\u4e3ahttp_requests_total\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u6807\u7b7eenvironment\u4e3astaging, testing, development\u7684\u503c\uff0c\u4e14http\u8bf7\u6c42\u65b9\u6cd5\u4e0d\u7b49\u4e8eGET\u3002\n<\/p><\/div>\n<div>\n<pre>http_requests_total{environment=~\\\"staging|testing|development\\\",method!=\\\"GET\\\"}<\/pre>\n<\/div>\n<div>\n\u5339\u914d\u7a7a\u6807\u7b7e\u503c\u7684\u6807\u7b7e\u5339\u914d\u5668\u4e5f\u53ef\u4ee5\u9009\u62e9\u6ca1\u6709\u8bbe\u7f6e\u4efb\u4f55\u6807\u7b7e\u7684\u6240\u6709\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u6b63\u5219\u8868\u8fbe\u5f0f\u5b8c\u5168\u5339\u914d\u3002 \u53ef\u4ee5\u4e3a\u540c\u4e00\u6807\u7b7e\u540d\u79f0\u63d0\u4f9b\u591a\u4e2a\u5339\u914d\u5668\u3002<br \/>\n\u5411\u91cf\u9009\u62e9\u5668\u5fc5\u987b\u6307\u5b9a\u4e00\u4e2a\u540d\u79f0\u6216\u81f3\u5c11\u4e00\u4e2a\u4e0e\u7a7a\u5b57\u7b26\u4e32\u4e0d\u5339\u914d\u7684\u6807\u7b7e\u5339\u914d\u5668\u3002 \u4ee5\u4e0b\u8868\u8fbe\u5f0f\u662f\u975e\u6cd5\u7684\uff1a<\/p>\n<div>\n<pre>{job=~\\\".*\\\"} # Bad!<\/pre>\n<\/div>\n<p>\u76f8\u53cd\uff0c\u8fd9\u4e9b\u8868\u8fbe\u5f0f\u662f\u6709\u6548\u7684\uff0c\u56e0\u4e3a\u5b83\u4eec\u90fd\u6709\u4e00\u4e2a\u4e0e\u7a7a\u6807\u7b7e\u503c\u4e0d\u5339\u914d\u7684\u9009\u62e9\u5668\u3002<\/p>\n<div>\n<pre>{job=~\\\".+\\\"}              # Good!\n{job=~\\\".*\\\",method=\\\"get\\\"} # Good!<\/pre>\n<\/div>\n<div>\n<div>\u6807\u7b7e\u5339\u914d\u5668\u80fd\u591f\u88ab\u5e94\u7528\u5230\u5ea6\u91cf\u6307\u6807\u540d\u79f0\uff0c\u4f7f\u7528__name__\u6807\u7b7e\u7b5b\u9009\u5ea6\u91cf\u6307\u6807\u540d\u79f0\u3002\u4f8b\u5982\uff1a\u8868\u8fbe\u5f0fhttp_requests_total\u7b49\u4ef7\u4e8e{__name__=\\&#8221;http_requests_total\\&#8221;}\u3002 \u5176\u4ed6\u7684\u5339\u914d\u5668\uff0c\u5982\uff1a= ( !=, =~, !~)\u90fd\u53ef\u4ee5\u4f7f\u7528\u3002\u4e0b\u9762\u7684\u8868\u8fbe\u5f0f\u9009\u62e9\u4e86\u5ea6\u91cf\u6307\u6807\u540d\u79f0\u4ee5job:\u5f00\u5934\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff1a<\/div>\n<div>\n<div>\n<pre>{__name__=~\\\"job:.*\\\"}<\/pre>\n<\/div>\n<p>Prometheus\u4e2d\u7684\u6240\u6709\u6b63\u5219\u8868\u8fbe\u5f0f\u90fd\u4f7f\u7528<a href=\\\"https:\/\/github.com\/google\/re2\/wiki\/Syntax\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">RE2\u8bed\u6cd5<\/a>\u3002<\/p>\n<div>\n<div>\n<h3>4.2 \u8303\u56f4\u5411\u91cf\u9009\u62e9\u5668<\/h3>\n<p>\u8303\u56f4\u5411\u91cf\u7684\u5de5\u4f5c\u65b9\u5f0f\u4e0e\u5373\u65f6\u5411\u91cf\u76f8\u540c\uff0c\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u5b83\u4eec\u4ece\u5f53\u524d\u5373\u65f6\u9009\u62e9\u56de\u91c7\u6837\u8303\u56f4\u3002\u00a0\u5728\u8bed\u6cd5\u4e0a\uff0c\u8303\u56f4\u6301\u7eed\u65f6\u95f4\u9644\u52a0\u5728\u5411\u91cf\u9009\u62e9\u5668\u672b\u5c3e\u7684\u65b9\u62ec\u53f7\uff08[]\uff09\u4e2d\uff0c\u6307\u5b9a\u4e3a\u6bcf\u4e2a\u7ed3\u679c\u8303\u56f4\u5411\u91cf\u5143\u7d20\u63d0\u53d6\u591a\u957f\u65f6\u95f4\u503c\u3002\u6301\u7eed\u65f6\u95f4\u6307\u5b9a\u4e3a\u6570\u5b57\uff0c\u5355\u4f4d\u4e3a\uff1a<\/p>\n<ul>\n<li>s\u00a0&#8211; seconds<\/li>\n<li>m\u00a0&#8211; minutes<\/li>\n<li>h\u00a0&#8211; hours<\/li>\n<li>d\u00a0&#8211; days<\/li>\n<li>w\u00a0&#8211; weeks<\/li>\n<li>y\u00a0&#8211; years<\/li>\n<\/ul>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9009\u62e9\u5728\u8fc7\u53bb5\u5206\u949f\u5185\u4e3a\u5ea6\u91cf\u6807\u51c6\u540d\u79f0\u4e3ahttp_requests_total\u4e14job\u6807\u7b7e\u8bbe\u7f6e\u4e3aprometheus\u7684\u6240\u6709\u65f6\u95f4\u5e8f\u5217\u8bb0\u5f55\u7684\u6240\u6709\u503c\uff1a<\/p>\n<div>\n<pre>http_requests_total{job=\\\"prometheus\\\"}[5m]<\/pre>\n<\/div>\n<h3>4.3 \u504f\u79fb\u4fee\u9970\u7b26<\/h3>\n<p>\u8fd9\u4e2aoffset\u504f\u79fb\u4fee\u9970\u7b26\u5141\u8bb8\u5728\u67e5\u8be2\u4e2d\u6539\u53d8\u5355\u4e2a\u77ac\u65f6\u5411\u91cf\u548c\u8303\u56f4\u5411\u91cf\u4e2d\u7684\u65f6\u95f4\u504f\u79fb\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8868\u8fbe\u5f0f\u8fd4\u56de\u8fc7\u53bb\u76f8\u5bf9\u4e8e\u5f53\u524d\u67e5\u8be2\u8bc4\u4f30\u65f6\u95f45\u5206\u949f\u7684http_requests_total\u503c\uff1a\n<\/p><\/div>\n<\/div>\n<\/div>\n<div>\n<pre>http_requests_total offset 5m<\/pre>\n<\/div>\n<p>\u6ce8\u610f\uff1aoffset\u504f\u79fb\u4fee\u9970\u7b26\u5fc5\u987b\u76f4\u63a5\u8ddf\u5728\u9009\u62e9\u5668\u540e\u9762\uff0c\u4f8b\u5982\uff1a\u4ee5\u4e0b\u662f\u6b63\u786e\u7684\uff1a<\/p>\n<div>\n<pre>sum(http_requests_total{method=\\\"GET\\\"} offset 5m) \/\/ GOOD.<\/pre>\n<\/div>\n<p>\u7136\u800c\uff0c\u4e0b\u9762\u8fd9\u79cd\u60c5\u51b5\u662f\u4e0d\u6b63\u786e\u7684:<\/p>\n<div>\n<pre>sum(http_requests_total{method=\\\"GET\\\"}) offset 5m \/\/ INVALID.<\/pre>\n<\/div>\n<p>\u540c\u6837\u9002\u7528\u4e8e\u8303\u56f4\u5411\u91cf\u3002 \u8fd9\u5c06\u8fd4\u56dehttp_requests_total\u4e00\u5468\u524d\u76845\u5206\u949f\u901f\u7387\uff1a<\/p>\n<div>\n<pre>rate(http_requests_total[5m] offset 1w)<\/pre>\n<\/div>\n<h3>\u4e94\u3001\u5b50\u67e5\u8be2<\/h3>\n<div>\n<div>\n\u5b50\u67e5\u8be2\u5141\u8bb8\u9488\u5bf9\u7ed9\u5b9a\u8303\u56f4\u548c\u5206\u8fa8\u7387\u8fd0\u884c\u5373\u65f6\u67e5\u8be2\u3002 \u5b50\u67e5\u8be2\u7684\u7ed3\u679c\u662f\u8303\u56f4\u5411\u91cf\u3002<br \/>\n\u8bed\u6cd5\uff1a&lt;instant_query&gt;\\'[\\'&lt;range&gt;\\&#8217;\uff1a\\'[&lt;resolution&gt;]\\&#8217;]\\'[offset &lt;duration&gt;]<\/p>\n<ul>\n<li>&lt;resolution&gt;\u662f\u53ef\u9009\u7684\u3002 \u9ed8\u8ba4\u503c\u662f\u5168\u5c40\u8bc4\u4f30\u95f4\u9694\u3002<\/li>\n<\/ul>\n<h3>\u516d\u3001\u64cd\u4f5c\u7b26<\/h3>\n<p>Prometheus\u652f\u6301\u4e8c\u5143\u548c\u805a\u5408\u64cd\u4f5c\u7b26\u3002\u8be6\u89c1<a href=\\\"https:\/\/prometheus.io\/docs\/prometheus\/latest\/querying\/operators\/\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">\u8868\u8fbe\u5f0f\u8bed\u8a00\u64cd\u4f5c\u7b26<\/a><\/p>\n<h3>\u4e03\u3001\u51fd\u6570<\/h3>\n<p>Prometheus\u63d0\u4f9b\u4e86\u4e00\u4e9b\u51fd\u6570\u5217\u8868\u64cd\u4f5c\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u8be6\u89c1<a href=\\\"https:\/\/prometheus.io\/docs\/prometheus\/latest\/querying\/functions\/\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\">\u8868\u8fbe\u5f0f\u8bed\u8a00\u51fd\u6570<\/a>\n<\/div>\n<h3>\u516b\u3001\u6ce8\u91ca<\/h3>\n<p>PromQL\u652f\u6301\u4ee5\uff03\u5f00\u5934\u7684\u884c\u6ce8\u91ca\u3002 \u5982\uff1a<\/p>\n<div>\n<pre>\uff03\u8fd9\u662f\u4e00\u6761\u8bc4\u8bba<\/pre>\n<\/div>\n<div>\n<h3>\u4e5d\u3001\u9677\u9631<\/h3>\n<h3>9.1 \u65e7\u6570\u636e<\/h3>\n<p>\u8fd0\u884c\u67e5\u8be2\u65f6\uff0c\u72ec\u7acb\u4e8e\u5f53\u524d\u65f6\u95f4\u5e8f\u5217\u7684\u6570\u636e\u9009\u62e9\u91c7\u6837\u6570\u636e\u7684\u65f6\u95f4\u6233\u3002\u8fd9\u4e3b\u8981\u662f\u4e3a\u4e86\u652f\u6301\u805a\u5408\uff08\u603b\u548c\uff0c\u5e73\u5747\u7b49\uff09\u8fd9\u6837\u7684\u60c5\u51b5\uff0c\u5176\u4e2d\u591a\u4e2a\u805a\u5408\u65f6\u95f4\u5e8f\u5217\u5728\u65f6\u95f4\u4e0a\u4e0d\u5b8c\u5168\u5bf9\u9f50\u3002\u7531\u4e8e\u5b83\u4eec\u7684\u72ec\u7acb\u6027\uff0cPrometheus\u9700\u8981\u5728\u6bcf\u4e2a\u76f8\u5173\u65f6\u95f4\u5e8f\u5217\u7684\u65f6\u95f4\u6233\u4e0a\u5206\u914d\u503c\u3002\u5b83\u53ea\u9700\u5728\u6b64\u65f6\u95f4\u6233\u4e4b\u524d\u91c7\u7528\u6700\u65b0\u7684\u6837\u672c\u5373\u53ef\u3002<br \/>\n\u5982\u679c\u76ee\u6807\u6293\u53d6\u6216\u89c4\u5219\u8bc4\u4f30\u4e0d\u518d\u8fd4\u56de\u5148\u524d\u5b58\u5728\u7684\u65f6\u95f4\u5e8f\u5217\u7684\u6837\u672c\uff0c\u5219\u8be5\u65f6\u95f4\u5e8f\u5217\u5c06\u88ab\u6807\u8bb0\u4e3a\u65e7\u6570\u636e\u3002\u5982\u679c\u76ee\u6807\u88ab\u79fb\u9664\uff0c\u4e4b\u524d\u5f88\u5feb\u5c31\u4f1a\u5c06\u5176\u5148\u524d\u8fd4\u56de\u7684\u65f6\u95f4\u5e8f\u5217\u6807\u8bb0\u4e3a\u65e7\u6570\u636e\u3002<br \/>\n\u5982\u679c\u5728\u65f6\u95f4\u5e8f\u5217\u6807\u8bb0\u4e3a\u8fc7\u65f6\u540e\uff0c\u5728\u91c7\u6837\u65f6\u95f4\u6233\u5904\u8bc4\u4f30\u67e5\u8be2\uff0c\u5219\u4e0d\u4f1a\u4e3a\u8be5\u65f6\u95f4\u7cfb\u5217\u8fd4\u56de\u4efb\u4f55\u503c\u3002\u5982\u679c\u968f\u540e\u5728\u8be5\u65f6\u95f4\u5e8f\u5217\u4e2d\u6444\u53d6\u65b0\u6837\u672c\uff0c\u5b83\u4eec\u5c06\u7167\u5e38\u8fd4\u56de\u3002<br \/>\n\u5982\u679c\u5728\u91c7\u6837\u65f6\u95f4\u6233\u524d5\u5206\u949f\u672a\u627e\u5230\u4efb\u4f55\u6837\u672c\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff09\uff0c\u5219\u6b64\u65f6\u95f4\u70b9\u4e0d\u8fd4\u56de\u8be5\u65f6\u95f4\u5e8f\u5217\u7684\u503c\u3002\u8fd9\u5b9e\u9645\u4e0a\u610f\u5473\u7740\u65f6\u95f4\u5e8f\u5217\u5728\u5176\u6700\u65b0\u6536\u96c6\u7684\u6837\u672c\u8d85\u8fc75\u5206\u949f\u6216\u6807\u8bb0\u4e3a\u65e7\u6570\u636e\u4e4b\u540e\u4ece\u56fe\u8868\u201c\u6d88\u5931\u201d\u3002\u5bf9\u4e8e\u5728\u5176\u6293\u53d6\u4e2d\u5305\u542b\u65f6\u95f4\u6233\u7684\u65f6\u95f4\u5e8f\u5217\uff0c\u4e0d\u4f1a\u6807\u8bb0\u65e7\u6570\u636e\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4ec5\u5e94\u75285\u5206\u949f\u7684\u9608\u503c\u3002<\/p>\n<h3>9.2 \u907f\u514d\u6162\u67e5\u8be2\u548c\u8fc7\u8f7d<\/h3>\n<p>\u5982\u679c\u67e5\u8be2\u9700\u8981\u5bf9\u5927\u91cf\u6570\u636e\u8fdb\u884c\u64cd\u4f5c\uff0c\u5219\u7ed8\u5236\u56fe\u8868\u53ef\u80fd\u4f1a\u8d85\u65f6\u6216\u4f7f\u670d\u52a1\u5668\u6216\u6d4f\u89c8\u5668\u8fc7\u8f7d\u3002\u56e0\u6b64\uff0c\u5728\u6784\u5efa\u5bf9\u672a\u77e5\u6570\u636e\u7684\u67e5\u8be2\u65f6\uff0c\u59cb\u7ec8\u5728Prometheus\u8868\u8fbe\u5f0f\u6d4f\u89c8\u5668\u7684\u8868\u683c\u89c6\u56fe\u4e2d\u5f00\u59cb\u6784\u5efa\u67e5\u8be2\uff0c\u76f4\u5230\u7ed3\u679c\u96c6\u770b\u8d77\u6765\u5408\u7406\uff08\u6700\u591a\u6570\u767e\u4e2a\uff0c\u800c\u4e0d\u662f\u6570\u5343\u4e2a\u65f6\u95f4\u5e8f\u5217\uff09\u3002\u53ea\u6709\u5728\u5145\u5206\u8fc7\u6ee4\u6216\u6c47\u603b\u6570\u636e\u540e\uff0c\u624d\u80fd\u5207\u6362\u5230\u56fe\u8868\u6a21\u5f0f\u3002\u5982\u679c\u8868\u8fbe\u5f0f\u4ecd\u7136\u9700\u8981\u5f88\u957f\u65f6\u95f4\u6765\u7ed8\u5236ad-hoc\u56fe\u5f62\uff0c\u8bf7\u901a\u8fc7\u5f55\u5236\u89c4\u5219\u9884\u5148\u5f55\u5236\u5b83\u3002<br \/>\n\u8fd9\u4e0ePrometheus\u7684\u67e5\u8be2\u8bed\u8a00\u5c24\u5176\u76f8\u5173\uff0c\u5176\u4e2d\u50cfapi_http_requests_total\u8fd9\u6837\u7684\u7b80\u5355\u5ea6\u91cf\u6807\u51c6\u540d\u79f0\u9009\u62e9\u5668\u53ef\u4ee5\u6269\u5c55\u5230\u5177\u6709\u4e0d\u540c\u6807\u7b7e\u7684\u6570\u5343\u4e2a\u65f6\u95f4\u5e8f\u5217\u3002\u8fd8\u8981\u8bb0\u4f4f\uff0c\u5373\u4f7f\u8f93\u51fa\u53ea\u662f\u5c11\u91cf\u7684\u65f6\u95f4\u5e8f\u5217\uff0c\u805a\u5408\u5728\u8bb8\u591a\u65f6\u95f4\u5e8f\u5217\u4e0a\u7684\u8868\u8fbe\u5f0f\u4e5f\u4f1a\u5728\u670d\u52a1\u5668\u4e0a\u4ea7\u751f\u8d1f\u8f7d\u3002\u8fd9\u7c7b\u4f3c\u4e8e\u5728\u5173\u7cfb\u6570\u636e\u5e93\u4e2d\u5bf9\u5217\u7684\u6240\u6709\u503c\u6c42\u548c\u7684\u901f\u5ea6\u5f88\u6162\uff0c\u5373\u4f7f\u8f93\u51fa\u503c\u53ea\u662f\u4e00\u4e2a\u6570\u5b57\u3002\n<\/p><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1.Prothetheus\u67e5\u8be2 Prometheus\u63d0\u4f9b\u4e00\u4e2a\u51fd\u6570\u5f0f\u7684\u8868\u8fbe\u5f0f\u8bed\u8a00PromQL (Promethe &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1862\"> <span class=\"screen-reader-text\">Prometheus \u67e5\u8be2\u8bf4\u660e<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[138,122],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"1.Prothetheus\u67e5\u8be2 Prometheus\u63d0\u4f9b\u4e00\u4e2a\u51fd\u6570\u5f0f\u7684\u8868\u8fbe\u5f0f\u8bed\u8a00PromQL (Promethe&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1862"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1862"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1862\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1862"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}