{"id":43697,"date":"2022-12-24T22:11:52","date_gmt":"2023-10-15T04:02:58","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/"},"modified":"2024-04-29T06:50:04","modified_gmt":"2024-04-28T22:50:04","slug":"%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/","title":{"rendered":"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570"},"content":{"rendered":"<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/0-0.jpeg\" alt=\"5dc4d608344107ddb36852a3_Prometheus rate() explained.jpg\" \/><\/div>\n<h1>\u7d22\u5f15<\/h1>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u9996\u5148<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u673a\u5236<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>2.1 \u53c2\u6570\u7c7b\u578b<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>2.2 \u9009\u62e9\u8303\u56f4\u77e2\u91cf\u7684\u65f6\u95f4\u8303\u56f4<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>2.3 \u8ba1\u7b97<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>2.4 \u5916\u63a8\uff1a\u5728\u4fe1\u606f\u7f3a\u5931\u65f6rate()\u51fd\u6570\u7684\u884c\u4e3a<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>2.5 \u805a\u5408<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\u4f8b\u5b50<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>3.1 \u544a\u8b66\u89c4\u5219<\/ol>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<ol>3.2 \u8ba1\u7b97SLO<\/ol>\n<h1>\u9996\u5148<\/h1>\n<p>Prometheus\u548c\u5176\u67e5\u8be2\u8bed\u8a00PromQL\u62e5\u6709\u8bb8\u591a\u51fd\u6570\uff0c\u7528\u4e8e\u5bf9\u4fdd\u5b58\u7684\u6570\u636e\u8fdb\u884c\u5404\u79cd\u8ba1\u7b97\u3002\u5176\u4e2d\u6700\u5e38\u7528\u7684\u51fd\u6570\u4e4b\u4e00\u662frate()\u51fd\u6570\uff0c\u4f46\u4e5f\u662f\u6700\u5bb9\u6613\u88ab\u8bef\u89e3\u7684\u51fd\u6570\u4e4b\u4e00\u3002<\/p>\n<p>\u5982\u679c\u516c\u53f8\u5185\u90e8\u6709\u50cfMetricfire\u63d0\u4f9b\u7684\u76d1\u63a7\u5de5\u5177\uff0c\u5c31\u53ef\u4ee5\u63d0\u4f9b\u6240\u9700\u7684\u57fa\u672c\u529f\u80fd\u3002\u5176\u4e2d\u4e00\u4e2a\u91cd\u8981\u529f\u80fd\u662f\u9884\u6d4b\u8d8b\u52bf\u3002\u8fd9\u5c31\u662frate()\u51fd\u6570\u7684\u7528\u9014\u3002\u6b63\u5982\u5176\u540d\u79f0\u6240\u793a\uff0c\u5b83\u53ef\u4ee5\u8ba1\u7b97\u5728\u67d0\u4e2a\u65f6\u95f4\u8303\u56f4\u5185\u7684\u503c\u589e\u957f\u7387\u7684\u6bcf\u79d2\u5e73\u5747\u503c\u3002\u8be5\u51fd\u6570\u53ef\u7528\u4e8e\u8ba1\u7b97\u4f8b\u5982\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u670d\u52a1\u5668\u6536\u5230\u7684\u8bf7\u6c42\u6570\u91cf\u6216\u670d\u52a1\u5668\u7684CPU\u4f7f\u7528\u7387\u3002\u9996\u5148\u8981\u7406\u89e3\u5176\u5185\u90e8\u673a\u5236\uff0c\u7136\u540e\u79ef\u7d2f\u77e5\u8bc6\u3002\u5982\u679c\u60a8\u60f3\u5c1d\u8bd5\u81ea\u5df1\u4f7f\u7528Prometheus\uff0c\u8bf7\u7acb\u5373\u6ce8\u518cMetricFire\u7684Hosted Prometheus\u7684\u514d\u8d39\u8bd5\u7528\u7248\u3002<\/p>\n<h1>2. \u673a\u6784\u5f62\u5f0f<\/h1>\n<h2>2.1 \u53c2\u6570\u7c7b\u578b de<\/h2>\n<p>\u5728PromQL\u4e2d\uff0c\u6709\u4e24\u79cd\u53c2\u6570\u7c7b\u578b\uff1aRange Vector\u548cInstant Vector\u3002\u901a\u8fc7\u56fe\u8868\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u4e24\u79cd\u7c7b\u578b\u5206\u522b\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/8-0.png\" alt=\"5dc4d63125b1718d1553a7c6_bKB8SBfoSM7h7p3c8UCSeQlVVJba3MrIKuJL-HyjwQyQubRFIkhhDFQrtnjBsqoM-dwoLaRKv3Q5xDkNNIZdDOh5U8Iz_bnfhGOdjHjrkey-zBpA0lBwdQlKRsecEtZcBeao6HhWJRvEsORaBA.png\" \/><\/div>\n<p>\u8fd9\u662f\u4e00\u4e2a\u75313\u4e2aRange Vector\u77e9\u9635\u7ec4\u6210\u7684\u6570\u636e\u96c6\uff0c\u6bcf\u4e2a\u77e9\u9635\u5305\u542b\u6bcf10\u79d2\u8fdb\u884c\u4e00\u6b21\u76841\u5206\u949f\u6570\u636e\u83b7\u53d6\u3002\u56e0\u6b64\uff0c\u8fd9\u662f\u4e00\u4e2a\u7531\u6807\u7b7e\u5bf9\u552f\u4e00\u786e\u5b9a\u7684\u6570\u636e\u96c6\u3002Range Vector\u5177\u6709\u65f6\u95f4\u7ef4\u5ea6\uff08\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e3a1\u5206\u949f\uff09\uff0c\u800cInstant Vector\u5219\u6ca1\u6709\u3002Instant Vector\u7684\u5b9a\u4e49\u5982\u4e0b\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/10-0.png\" alt=\"5dc4d63225b171d5c553a7c8_wUUjK48wIETf72xaAslTYWKXe_7JQqUG-E-pl4zOx4BJgpji99w2JUiPbQKW59svQka5h8J9W4wZGeCcbrptSoTMB4VzJj57l0R4hvnIuhgNMY51dDENn8U34NsiJMLJcdME-SRV9hey-Lrqqg.png\" \/><\/div>\n<p>\u8fd9\u662fInstant Vector\u7684\u5b9a\u4e49\u65b9\u5f0f\uff0c\u5b83\u4ec5\u6307\u5b9a\u6700\u540e\u83b7\u53d6\/\u6293\u53d6\u7684\u503c\uff0c\u5e76\u4e14rate()\u51fd\u6570\u53ca\u5176\u5173\u8054\u65b9\u6cd5\u63a5\u53d7\u8303\u56f4\u7c7b\u578b\u7684\u53c2\u6570\u3002\u8fd9\u662f\u56e0\u4e3a\u4e3a\u4e86\u8ba1\u7b97\u4efb\u4f55\u7c7b\u578b\u7684\u53d8\u5316\uff0c\u81f3\u5c11\u9700\u8981\u4e24\u4e2a\u65f6\u95f4\u70b9\u7684\u6570\u636e\u3002\u56e0\u6b64\uff0c\u5982\u679c\u6837\u672c\u6570\u5c11\u4e8e2\uff0c\u5219\u4e0d\u4f1a\u8fd4\u56de\u4efb\u4f55\u7ed3\u679c\u3002PromQL\u901a\u8fc7\u5728\u9009\u62e9\u5668\u65c1\u8fb9\u7528\u65b9\u62ec\u53f7\u62ec\u8d77\u6765\u7684\u65f6\u95f4\u8303\u56f4\u6765\u8868\u793aRange Vector\u3002\u5b83\u8868\u793a\u8981\u4e0e\u8fc7\u53bb\u591a\u957f\u65f6\u95f4\u7684\u6570\u636e\u8fdb\u884c\u6bd4\u8f83\u3002<\/p>\n<h2>2.2 \u9009\u62e9\u65f6\u95f4\u8303\u56f4\u7684\u8303\u56f4\u77e2\u91cf<\/h2>\n<p>\u5173\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u5e94\u8be5\u9009\u62e9\u54ea\u4e2a\u65f6\u95f4\u8303\u56f4\u5462\uff1f\u5e76\u6ca1\u6709\u4e00\u4e2a\u6a21\u8303\u7b54\u6848\u3002\u4f5c\u4e3a\u6700\u4f4e\u8981\u6c42\uff0c\u9700\u8981\u5c06\u83b7\u53d6\u95f4\u9694\u52a0\u500d\u3002\u7136\u800c\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u7ed3\u679c\u5c06\u53d8\u5f97\u975e\u5e38&#8221;\u9510\u5229&#8221;\uff0c\u503c\u7684\u53d8\u5316\u5c06\u6bd4\u5176\u4ed6\u4efb\u4f55\u65f6\u95f4\u8303\u56f4\u7684\u51fd\u6570\u7ed3\u679c\u90fd\u5feb\u3002\u7136\u540e\uff0c\u7ed3\u679c\u4f1a\u7acb\u5373\u8fd4\u56de0\u3002\u5982\u679c\u5c06\u65f6\u95f4\u8303\u56f4\u5ef6\u957f\uff0c\u53ef\u4ee5\u83b7\u5f97\u76f8\u53cd\u7684\u7ed3\u679c\u3002\u7ed3\u679c\u7684\u7ebf\u6761\uff08\u5982\u679c\u5c06\u7ed3\u679c\u7ed8\u5236\u51fa\u6765\uff09\u4f1a\u53d8\u5f97&#8221;\u5e73\u6ed1&#8221;\uff0c\u5f88\u96be\u627e\u5230\u5c16\u5cf0\u503c\u3002\u56e0\u6b64\uff0c\u5728Grafana\u4e2d\uff0c\u5efa\u8bae\u5c06\u65f6\u95f4\u8303\u56f4\u4f5c\u4e3a\u53d8\u91cf\uff08\u4f8b\u5982\uff1a1m\u30015m\u300115m\u30012h\uff09\u8fdb\u884c\u7ba1\u7406\u3002\u8fd9\u6837\uff0c\u5728\u5c1d\u8bd5\u68c0\u6d4b\u5c16\u5cf0\u6216\u8d8b\u52bf\u7b49\u60c5\u51b5\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9\u6700\u9002\u5408\u60c5\u51b5\u7684\u503c\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u5728Grafana\u4e2d\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7279\u6b8a\u53d8\u91cf$__interval\uff0c\u8be5\u53d8\u91cf\u5b9a\u4e49\u4e3a\u5c06\u65f6\u95f4\u8303\u56f4\u9664\u4ee5\u6b65\u957f\u7684\u5927\u5c0f\u5f97\u5230\u7684\u503c\u3002\u770b\u8d77\u6765\uff0c\u8003\u8651\u4e86\u6bcf\u4e2a\u6b65\u957f\u95f4\u7684\u6240\u6709\u6570\u636e\u70b9\uff0c\u4f3c\u4e4e\u662f\u4e00\u4e2a\u5b8c\u7f8e\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u524d\u9762\u63d0\u5230\u7684\u95ee\u9898\u4ecd\u7136\u5b58\u5728\u3002\u65e0\u6cd5\u540c\u65f6\u67e5\u770b\u975e\u5e38\u8be6\u7ec6\u7684\u56fe\u8868\u548c\u5e7f\u6cdb\u7684\u8d8b\u52bf\u3002\u6b64\u5916\uff0c\u65f6\u95f4\u95f4\u9694\u4e0e\u67e5\u8be2\u6b65\u957f\u76f8\u5173\u8054\uff0c\u56e0\u6b64\u5f53\u83b7\u53d6\u95f4\u9694\u66f4\u6539\u65f6\uff0c\u53ef\u80fd\u4f1a\u5728\u975e\u5e38\u77ed\u7684\u65f6\u95f4\u8303\u56f4\u5185\u51fa\u73b0\u95ee\u9898\u3002<\/p>\n<h2>2.3 \u8fd0\u7b97<\/h2>\n<p>\u5728\u4e2d\u56fd\uff0c\u53ea\u9700\u8981\u4e00\u4e2a\u9009\u9879\u5c06\u5176\u6539\u5199\u6210\u4e2d\u6587\uff1a<br \/>\n\u548c\u5176\u4ed6\u51fd\u6570\u4e00\u6837\uff0crate() \u51fd\u6570\u4e5f\u4f1a\u5728\u6bcf\u4e2a\u6b65\u9aa4\u4e2d\u88ab\u8bc4\u4f30\u3002\u7136\u800c\uff0c\u5b83\u662f\u901a\u8fc7\u4ec0\u4e48\u673a\u5236\u6765\u8fd0\u4f5c\u7684\u5462\uff1f\u603b\u4f53\u800c\u8a00\uff0c\u5b83\u7684\u8ba1\u7b97\u65b9\u5f0f\u5927\u81f4\u5982\u4e0b\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/16-0.png\" alt=\"5dc4d632f5786c5982172636_G78-bOyuWafr1urWiCNgL88BgI7jEAZ8NYBMGtvYBmSXDLz-coiXJ-5Cbi86V34_EPn-A3k1btfvI1FePZTwf1PgH7wMv9uz9bjFMm2BhxaecIcVaiPqt_h64WDGJq3BGAoQ6Mg5KbRiHmEMcg.png\" \/><\/div>\n<p>rate() \u51fd\u6570\u7684\u4f18\u70b9\u662f\u5b83\u8003\u8651\u4e86\u6240\u6709\u6570\u636e\u70b9\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u9996\u5c3e\u7684\u6570\u636e\u70b9\u3002\u53e6\u5916\u4e5f\u5b58\u5728\u4e00\u4e2a\u53ea\u4f7f\u7528\u9996\u5c3e\u6570\u636e\u70b9\u7684 irate() \u51fd\u6570\u3002\u73b0\u5728\u4f60\u53ef\u80fd\u4f1a\u60f3\u4e3a\u4ec0\u4e48\u4e0d\u4f7f\u7528 delta() \u51fd\u6570\u3002\u73b0\u5728\u5df2\u7ecf\u89e3\u91ca\u4e86 rate() \u51fd\u6570\u5177\u6709\u6839\u636e\u590d\u4f4d\u81ea\u52a8\u8c03\u6574\u7684\u4f18\u79c0\u7279\u6027\u3002\u8fd9\u53ef\u4ee5\u7406\u89e3\u4e3a\u5b83\u53ea\u9002\u7528\u4e8e\u201c\u8ba1\u6570\u5668\uff08Counter\uff09\u201d\u8fd9\u79cd\u6307\u6807\u7c7b\u578b\uff0c\u5373\u90a3\u4e9b\u6301\u7eed\u589e\u52a0\u7684\u6307\u6807\u3002\u5b83\u4e0d\u9002\u7528\u4e8e\u201c\u4eea\u8868\uff08Gauge\uff09\u201d\u8fd9\u79cd\u6307\u6807\u7c7b\u578b\u3002\u800c\u4e14\uff0c\u5982\u679c\u4f60\u662f\u4e00\u4e2a\u70ed\u5fc3\u7684\u8bfb\u8005\uff0c\u4f60\u53ef\u80fd\u5df2\u7ecf\u6ce8\u610f\u5230\u4f7f\u7528 rate() \u51fd\u6570\u662f\u4e3a\u4e86\u907f\u514d\u6d6e\u70b9\u6570\u5728\u6307\u6807\u503c\u4e2d\u7684\u4f7f\u7528\u9650\u5236\uff0c\u5f53\u8fbe\u5230\u9650\u5236\u65f6\uff0c\u6d6e\u70b9\u6570\u5c06\u65e0\u9650\u589e\u957f\uff0c\u56e0\u6b64\u8fdb\u884c\u201c\u7ffb\u8f6c\u201d\u3002\u901a\u8fc7\u8fd9\u79cd\u903b\u8f91\uff0c\u53ef\u4ee5\u9632\u6b62\u65e7\u6570\u636e\u4e22\u5931\uff0c\u56e0\u6b64\u5982\u679c\u9700\u8981\u8be5\u529f\u80fd\uff0c\u5219\u5efa\u8bae\u4f7f\u7528 rate() \u51fd\u6570\u3002<br \/>\n\u6ce8\u610f\uff1a\u7531\u4e8e\u8fd9\u79cd\u590d\u4f4d\u7684\u81ea\u52a8\u8c03\u6574\uff0c\u5982\u679c\u4e0e rate() \u51fd\u6570\u4e00\u8d77\u4f7f\u7528\u5176\u4ed6\u805a\u5408\u51fd\u6570\uff0c\u5219\u5fc5\u987b\u5148\u5e94\u7528 rate() \u51fd\u6570\u3002\u5426\u5219\uff0c\u8ba1\u6570\u5668\u7684\u590d\u4f4d\u5c06\u4e0d\u4f1a\u88ab\u6355\u6349\u5230\uff0c\u5bfc\u81f4\u610f\u60f3\u4e0d\u5230\u7684\u7ed3\u679c\u3002<br \/>\n\u4e0d\u7ba1\u600e\u6837\uff0c\u76ee\u524d PromQL \u4e0d\u80fd\u963b\u6b62\u5728\u201c\u4eea\u8868\uff08Gauge\uff09\u201d\u4e2d\u4f7f\u7528 rate() \u51fd\u6570\u3002\u56e0\u6b64\uff0c\u5728\u9009\u62e9\u8981\u5c06\u54ea\u4e2a\u6307\u6807\u4f20\u9012\u7ed9\u8be5\u51fd\u6570\u65f6\uff0c\u4e86\u89e3\u8fd9\u4e00\u70b9\u975e\u5e38\u91cd\u8981\u3002\u5728\u201c\u4eea\u8868\uff08Gauge\uff09\u201d\u4e2d\u4f7f\u7528 rate() \u51fd\u6570\u662f\u4e0d\u6b63\u786e\u7684\u3002\u8fd9\u662f\u56e0\u4e3a\u590d\u4f4d\u68c0\u6d4b\u903b\u8f91\u4f1a\u9519\u8bef\u5730\u6355\u6349\u5230\u56e0\u201c\u8ba1\u6570\u5668\u590d\u4f4d\u201d\u800c\u4e0b\u964d\u7684\u503c\uff0c\u4ece\u800c\u5f97\u5230\u9519\u8bef\u7684\u7ed3\u679c\u3002<br \/>\n\u603b\u4e4b\uff0c\u5047\u8bbe\u6709\u4ee5\u4e0b\u53d8\u5316\u7684\u8ba1\u6570\u5668\u6307\u6807\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">0<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">4<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">6<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">10<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">2<\/ul>\n<p>\u5728\u201c10\u201d\u548c\u201c2\u201d\u4e4b\u95f4\u7684\u91cd\u7f6e\u88abirate()\u51fd\u6570\u548crate()\u51fd\u6570\u6355\u83b7\uff0c\u7136\u540e\u7684\u503c\u88ab\u89e3\u91ca\u4e3a\u662f\u201c12\u201d\uff0c\u4e5f\u5c31\u662f\u6bd4\u201c2\u201d\uff08\u4ece0\u5f00\u59cb\uff09\u589e\u52a0\u4e862\u4e2a\u5355\u4f4d\u3002\u5047\u8bbe\u572860\u79d2\u5185\u4f7f\u7528rate()\u51fd\u6570\u8ba1\u7b97\u901f\u7387\uff0c\u5e76\u5728\u7406\u60f3\u7684\u65f6\u95f4\u6233\u4e0b\u83b7\u53d6\u4e86\u8fd96\u4e2a\u6837\u672c\uff0c\u90a3\u4e48\u6bcf\u79d2\u7684\u5e73\u5747\u589e\u52a0\u7387\u5c06\u5982\u4e0b\u6240\u793a\uff1a<br \/>\n12-0\/60 = 0.2\u3002\u56e0\u4e3a\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e00\u5207\u90fd\u662f\u5b8c\u5168\u7406\u60f3\u7684\uff0c\u6240\u4ee5\u9006\u8ba1\u7b97\uff080.2*60=12\uff09\u4e5f\u662f\u6b63\u786e\u7684\u3002\u7136\u800c\uff0c\u5982\u679c\u67d0\u4e9b\u6837\u672c\u5e76\u6ca1\u6709\u5b8c\u5168\u8986\u76d6\u6574\u4e2a\u8303\u56f4\uff0c\u6216\u8005\u5728\u6837\u672c\u83b7\u53d6\u671f\u95f4\u53d1\u751f\u4e86\u968f\u673a\u5ef6\u8fdf\uff0c\u5bfc\u81f4\u5b83\u4eec\u65e0\u6cd5\u5b8c\u5168\u5bf9\u9f50\uff0c\u90a3\u4e48\u8fd9\u79cd\u9006\u8ba1\u7b97\u5e76\u4e0d\u603b\u662f\u6210\u7acb\u3002\u5173\u4e8e\u8fd9\u4e00\u70b9\uff0c\u5c06\u5728\u4e0b\u4e00\u90e8\u5206\u8fdb\u884c\u8be6\u7ec6\u8bf4\u660e\u3002<\/p>\n<h2>2.4 \u5916\u63a8\uff1a\u5f53\u4fe1\u606f\u7f3a\u5931\u65f6\uff0crate()\u51fd\u6570\u7684\u884c\u4e3a<\/h2>\n<p>\u6700\u5f8c\u306b\uff0c\u7406\u89e3 rate() \u51fd\u6570\u6267\u884c\u5916\u63a8\u7684\u91cd\u8981\u6027\u662f\u5173\u952e\u7684\u3002\u5982\u679c\u4f60\u77e5\u9053\u8fd9\u4e00\u70b9\uff0c\u4f60\u5c31\u4e0d\u7528\u957f\u671f\u56f0\u6270\u4e86\u3002\u5f53 rate() \u51fd\u6570\u88ab\u6267\u884c\u65f6\uff0c\u4e00\u4e9b\u83b7\u53d6 (scrape) \u53ef\u80fd\u4f1a\u5931\u8d25\uff0c\u4e00\u4e9b\u6570\u636e\u53ef\u80fd\u4f1a\u4e22\u5931\u3002\u6b64\u5916\uff0c\u7531\u4e8e\u968f\u673a\u6027\u7684\u52a0\u5165\uff0c\u5373\u4f7f\u662f\u65f6\u95f4\u8303\u56f4\u5411\u91cf\u7684\u500d\u6570\uff0c\u5b83\u4e5f\u4e0d\u4f1a\u5b8c\u5168\u5339\u914d\u8303\u56f4\u5411\u91cf\u3002<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0crate() \u51fd\u6570\u4f1a\u4ece\u4fdd\u6301\u7684\u6570\u636e\u4e2d\u8ba1\u7b97\u51fa\u6bd4\u7387\uff0c\u5e76\u4f7f\u7528\u7b2c\u4e00\u4e2a\u6216\u6700\u540e\u4e24\u4e2a\u6570\u636e\u70b9\u6765\u4f30\u8ba1\u6240\u9009\u7a97\u53e3\u7684\u5f00\u59cb\u6216\u7ed3\u675f\uff0c\u82e5\u5b58\u5728\u4fe1\u606f\u7f3a\u5931\u3002\u8fd9\u610f\u5473\u7740\u5373\u4f7f\u6240\u6709\u6570\u636e\u70b9\u90fd\u662f\u6574\u6570\uff0c\u7ed3\u679c\u4e5f\u53ef\u80fd\u4e0d\u5747\u5300\u3002\u56e0\u6b64\uff0c\u6b64\u51fd\u6570\u53ea\u9002\u7528\u4e8e\u68c0\u6d4b\u8d8b\u52bf\u3001\u5c16\u5cf0\u548c\u53d1\u751f\u8b66\u544a\u7684\u60c5\u51b5\u3002<\/p>\n<h2>2.5 \u7edf\u8ba1<\/h2>\n<p>\u4e0e\u5176\u4ed6\u51fd\u6570\u7c7b\u4f3c\uff0c\u60a8\u4e5f\u53ef\u4ee5\u53ea\u5c06rate()\u51fd\u6570\u5e94\u7528\u4e8e\u7279\u5b9a\u7684\u7ef4\u5ea6\u3002\u4f8b\u5982\uff0crate(foo) by (bar) \u5c06\u8ba1\u7b97\u5728\u6240\u6709bar\uff08\u6807\u7b7e\u540d\u79f0\uff09\u4e0b\uff0cfoo\u7684\u53d8\u5316\u7387\u3002\u8fd9\u5728\u4f7f\u7528haproxy\u5e76\u60f3\u8981\u8ba1\u7b97\u4e0d\u540c\u540e\u7aef\u7684\u9519\u8bef\u6570\u53d8\u5316\u7387\u65f6\u975e\u5e38\u6709\u7528\u3002\u60a8\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u65b9\u5f0f\u7f16\u5199\uff1a<br \/>\nrate(haproxy_connection_errors_total[5m]) by (backend)<\/p>\n<h1>\u4f8b:<br \/>\n3. \u4f8b\u5b50<\/h1>\n<p>Note: &#8220;\u4f8b&#8221; in Chinese can be translated to &#8220;example&#8221; or &#8220;case&#8221;, but it is commonly used in combination with other words to form phrases or idioms.<\/p>\n<h2>3.1 \u8b66\u62a5\u89c4\u5219<\/h2>\n<p>\u6b63\u5982\u524d\u9762\u6240\u8ff0\uff0crate()\u51fd\u6570\u5728\u9519\u8bef\u6570\u91cf\u6025\u5267\u589e\u52a0\u65f6\u5b8c\u7f8e\u5730\u63a5\u6536\u8b66\u62a5\u3002\u56e0\u6b64\uff0c\u53ef\u4ee5\u521b\u5efa\u5982\u4e0b\u8b66\u62a5\uff1a<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/27-0.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2020-04-16 16.58.18.png\" \/><\/div>\n<p>\u901a\u8fc7\u8fd9\u4e2a\uff0c\u5982\u679c\u4efb\u4f55\u4e00\u4e2a\u540e\u7aef\u51fa\u73b0\u8fde\u63a5\u9519\u8bef\u5c06\u4f1a\u6536\u5230\u901a\u77e5\u3002\u56e0\u6b64\uff0crate() \u51fd\u6570\u975e\u5e38\u9002\u5408\u8fd9\u79cd\u7528\u9014\u3002\u8bf7\u968f\u65f6\u4f7f\u7528 Metricfire \u6765\u76d1\u63a7\u670d\u52a1\u5e76\u5c1d\u8bd5\u5b9e\u65bd\u7c7b\u4f3c\u7684\u8b66\u62a5\u3002<\/p>\n<h2>3.2 \u8ba1\u7b97SLO<\/h2>\n<p>\u5728\u4f7f\u7528\u4e2d\u6587\u8fdb\u884c\u91cd\u8ff0\u65f6\uff0c\u8bf7\u6ce8\u610f\u4ee5\u4e0b\u4e8b\u9879\uff1a<\/p>\n<p>1. rate() \u51fd\u6570\u7684\u53e6\u4e00\u4e2a\u5e38\u89c1\u7528\u4f8b\u662f\u8ba1\u7b97 SLI \u5e76\u68c0\u67e5\u662f\u5426\u8fdd\u53cd\u4e86 SLO \/ SLA\u3002\u6700\u8fd1\uff0cGoogle \u53d1\u5e03\u4e86\u4e00\u672c\u53d7 SRE \u6b22\u8fce\u7684\u4e66\u7c4d\u3002\u8ba1\u7b97\u670d\u52a1\u53ef\u7528\u6027\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>Please note that the translation may vary depending on the specific context and intended meaning.<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/31-0.png\" alt=\"5dc4d632e681df3fe8dabd59_rUKm-LWSkiQoJX-Aj3eOzhIfBew1blqnQfrBolwUifNDcV8brS5wlwcAA4P3JKmG0LU6k3-VtrTVJhjhh3XSYcwWKTurxry75EfNtBthFHVXtfx4MVw4rb8no9bTHQJNAL9nERNQ0XSX3-x05g.png\" \/><\/div>\n<p>\u4ee5\u8fd9\u79cd\u65b9\u5f0f\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba1\u7b97\u51fa\u9664\u53bb5xx\u54cd\u5e94\u4e4b\u5916\u7684\u6240\u6709\u8bf7\u6c42\u91cf\u7684\u53d8\u5316\u7387\uff0c\u5e76\u5c06\u5176\u9664\u4ee5\u8bf7\u6c42\u603b\u91cf\u7684\u53d8\u5316\u7387\u3002\u5982\u679c\u5b58\u57285xx\u54cd\u5e94\uff0c\u7ed3\u679c\u503c\u5c06\u5c0f\u4e8e1\u3002\u91cd\u590d\u4e00\u904d\uff0c\u60a8\u53ef\u4ee5\u5728\u8b66\u62a5\u89c4\u5219\u4e2d\u6307\u5b9a\u67d0\u4e2a\u9608\u503c\u6765\u4f7f\u7528\u6b64\u516c\u5f0f\uff0c\u4ee5\u4fbf\u5728\u8d85\u8fc7\u9608\u503c\u65f6\u63a5\u6536\u5230\u8b66\u62a5\uff0c\u6216\u8005\u4f7f\u7528predict_linear\u51fd\u6570\u6765\u9884\u6d4b\u8fd1\u671f\u7684\u60c5\u51b5\uff0c\u4ece\u800c\u907f\u514dSLA\/SLO\u95ee\u9898\u3002<\/p>\n<p>\u8bf7\u53c2\u8003MetricFire\u7684\u6258\u7ba1Prometheus\u9875\u9762\u83b7\u53d6\u66f4\u8be6\u7ec6\u4fe1\u606f\u3002\u540c\u65f6\uff0c\u5982\u679c\u60a8\u5e0c\u671b\u5c1d\u8bd5\uff0c\u53ef\u4ee5\u6ce8\u518c\u514d\u8d39\u8bd5\u7528\u7248\u7684\u6258\u7ba1Prometheus\u3002\u60a8\u4e5f\u53ef\u4ee5\u9884\u7ea6\u6f14\u793a\uff0c\u4e86\u89e3\u6709\u5173Prometheus\u6700\u4f73\u76d1\u63a7\u89e3\u51b3\u65b9\u6848\u7684\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d22\u5f15 \u9996\u5148 &nbsp; \u673a\u5236 &nbsp; 2.1 \u53c2\u6570\u7c7b\u578b &nbsp; 2.2 \u9009\u62e9\u8303\u56f4\u77e2\u91cf\u7684\u65f6\u95f4\u8303\u56f4  [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-43697","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u7406\u89e3prometheus\u7684rate\u51fd\u6570\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570\" \/>\n<meta property=\"og:description\" content=\"\u7d22\u5f15 \u9996\u5148 &nbsp; \u673a\u5236 &nbsp; 2.1 \u53c2\u6570\u7c7b\u578b &nbsp; 2.2 \u9009\u62e9\u8303\u56f4\u77e2\u91cf\u7684\u65f6\u95f4\u8303\u56f4 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u7406\u89e3prometheus\u7684rate\u51fd\u6570\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-15T04:02:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T22:50:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/0-0.jpeg\" \/>\n<meta name=\"author\" content=\"\u6e05, \u5b87\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6e05, \u5b87\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/\",\"name\":\"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-10-15T04:02:58+00:00\",\"dateModified\":\"2024-04-28T22:50:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e\",\"name\":\"\u6e05, \u5b87\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g\",\"caption\":\"\u6e05, \u5b87\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u7406\u89e3prometheus\u7684rate\u51fd\u6570\/","og_locale":"zh_CN","og_type":"article","og_title":"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570","og_description":"\u7d22\u5f15 \u9996\u5148 &nbsp; \u673a\u5236 &nbsp; 2.1 \u53c2\u6570\u7c7b\u578b &nbsp; 2.2 \u9009\u62e9\u8303\u56f4\u77e2\u91cf\u7684\u65f6\u95f4\u8303\u56f4 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u7406\u89e3prometheus\u7684rate\u51fd\u6570\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-10-15T04:02:58+00:00","article_modified_time":"2024-04-28T22:50:04+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d53fc37434c4406cd1551\/0-0.jpeg"}],"author":"\u6e05, \u5b87","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6e05, \u5b87","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/","name":"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-10-15T04:02:58+00:00","dateModified":"2024-04-28T22:50:04+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u7406\u89e3Prometheus\u7684rate()\u51fd\u6570"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/1a6ecd3d914d22a5ac32791ffc1fbd8e","name":"\u6e05, \u5b87","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b2016c18459a605fc469c7566608f5686491baa112d0871ee613f61b7210565?s=96&d=mm&r=g","caption":"\u6e05, \u5b87"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/qingyu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e7%90%86%e8%a7%a3prometheus%e7%9a%84rate%e5%87%bd%e6%95%b0\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=43697"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43697\/revisions"}],"predecessor-version":[{"id":83702,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/43697\/revisions\/83702"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=43697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=43697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=43697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}