{"id":1542,"date":"2021-09-08T10:07:24","date_gmt":"2021-09-08T10:07:24","guid":{"rendered":"https:\/\/www.ipcpu.com\/?p=1542"},"modified":"2021-10-08T10:15:21","modified_gmt":"2021-10-08T10:15:21","slug":"thanos-prometheus","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2021\/09\/thanos-prometheus\/","title":{"rendered":"Thanos-Prometheus\u7684\u6269\u5c55\u597d\u4f19\u4f34"},"content":{"rendered":"

\u4e00\u3001Thanos\u6982\u8ff0\uff1a<\/h2>\n

Thanos\u4e3b\u8981\u7528\u4e8e\u89e3\u51b3\u5927\u89c4\u6a21prometheus\u90e8\u7f72\u3001\u589e\u5f3aprometheus\u9ad8\u53ef\u7528\u7684\u5de5\u5177\u3002<\/p>\n

\u9879\u76ee\u5730\u5740
\nhttps:\/\/github.com\/thanos-io\/thanos<\/a><\/p>\n

\u4e8c\u3001Thanos\u67b6\u6784<\/h2>\n

\u4ece\u5b98\u65b9github\u4e2d\u53ef\u4ee5\u770b\u5230Thanos\u7684\u67b6\u6784\u56fe\uff0c\u6211\u5c31\u4e0d\u8d34\u4e86\uff0c\u6211\u753b\u4e86\u4e00\u4e2a\u66f4\u7b80\u5355\u7684\u56fe\u3002
\n
\n\u6211\u4eec\u6765\u8bf4\u4e0b\u76f8\u5173\u7684\u7ec4\u4ef6\uff1a<\/p>\n

\n

thanos-sidecar<\/strong>\uff1a \u4f7f\u7528Sidecar\u65b9\u5f0f\u4e0ePrometheus\u8fde\u63a5\uff0c\u4e3b\u8981\u6709\u4e24\u4e2a\u529f\u80fd\uff1a\u4e00\u662f\u4e0a\u4f20Prometheus\u7684Block\u6570\u636e\u5230\u4e91\u7aef\u7684\u5bf9\u8c61\u5b58\u50a8\uff1b\u4e8c\u662f\u63d0\u4f9bGRPC\u63a5\u53e3\u7ed9Query\u7ec4\u4ef6\u67e5\u8be2\u4f7f\u7528\u3002<\/p>\n

thanos-query<\/strong>\uff1a \u67e5\u8be2\u5176\u4ed6\u7ec4\u4ef6\u7684grpc\u63a5\u53e3\u83b7\u53d6\u6570\u636e\uff0c\u5e76\u5bf9\u6570\u636e\u8fdb\u884c\u805a\u5408\u53bb\u91cd\u5904\u7406\u3002<\/p>\n

thanos-store<\/strong>\uff1a \u5bf9\u63a5\u4e91\u7aef\u7684\u5bf9\u8c61\u5b58\u50a8\u8fdb\u884c\u67e5\u8be2\uff0c\u63d0\u4f9bGRPC\u63a5\u53e3\u4f9bQuery\u7ec4\u4ef6\u8c03\u7528<\/p>\n

thanos-compact<\/strong>\uff1a \u56fe\u4e0a\u6ca1\u6709\u753b\u3002\u5bf9\u5b58\u50a8\u5728\u4e91\u7aef\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u5408\u5e76\u538b\u7f29\u548c\u964d\u91c7\u6837(DownSample\uff09\u3002\u53ef\u4ee5\u51cf\u5c11\u4e91\u7aef\u5b58\u50a8\u5185\u5bb9\u548c\u7a7a\u95f4\u3002\u6211\u4eec\u6ca1\u6709\u4f7f\u7528\uff0c\u56e0\u4e3a\u6211\u4eec\u6ca1\u6709\u964d\u91c7\u6837\u9700\u6c42\uff0c\u5355\u7eaf\u538b\u7f29\u5408\u5e76\u6570\u636e\u964d\u4e0d\u4e86\u591a\u5c11\u5b58\u50a8\u6210\u672c\u3002<\/p>\n

thanos-rule<\/strong>\uff1a \u56fe\u4e0a\u6ca1\u6709\u753b\u3002\u8bbe\u5b9a\u89c4\u5219\u67e5\u8be2query\u7ec4\u4ef6\uff0c\u82e5\u89e6\u53d1\u544a\u8b66\uff0c\u5219\u901a\u77e5altermanager\u3002\u4ec5\u5f53\u76d1\u63a7\u6570\u636e\u9700\u8981\u5408\u5e76\u67e5\u8be2\u65f6\u624d\u9700\u8981\u5f00\u542f\uff0c\u5426\u5219\u76f4\u63a5\u4f7f\u7528prometheus\u7684rule\u5c31\u53ef\u4ee5\u3002<\/p>\n<\/blockquote>\n

\u4e09\u3001Thanos\u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898<\/h2>\n

3.1 \u76d1\u63a7\u6570\u636e\u4e0a\u4f20\u5230\u4e91\u7aef\u5bf9\u8c61\u5b58\u50a8<\/h4>\n

\u6211\u4eec\u77e5\u9053Prometheus\u5b98\u65b9\u4e0d\u63a8\u8350\u5728\u672c\u5730\u5b58\u50a8\u957f\u65f6\u95f4\u7684\u6570\u636e\uff08\u4e5f\u5b58\u5728\u6587\u4ef6\u6253\u5f00\u8fc7\u591a\u7684\u98ce\u9669\uff09\uff0c\u6211\u4eec\u66fe\u7ecf\u5b58\u50a8\u8fc7\u534a\u5e74\u7684\u6570\u636e\uff0c\u6bcf\u4e00\u6b21\u91cd\u542fPrometheus\u52a0\u8f7d\u5386\u53f2\u6570\u636e\u90fd\u662f\u75db\u82e6\u7684\u7b49\u5f85\uff0c\u9700\u898120-30\u5206\u949f\uff0c\u5728\u8fd9\u671f\u95f4\u76d1\u63a7\u90fd\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002\u5c3d\u7ba1Prometheus\u6709remote write\u7b49\u529f\u80fd\uff0c\u4f46\u662f\u6210\u672c\u4f4e\u5ec9\u7684\u4e91\u7aef\u5bf9\u8c61\u5b58\u50a8\u786e\u662f\u4e2a\u597d\u529e\u6cd5\u3002<\/p>\n

3.2 \u529f\u80fd\u5f3a\u5927\u7684Query\u7ec4\u4ef6<\/h4>\n


\nQuery\u7ec4\u4ef6\u62e5\u6709\u53bb\u91cd\u5408\u5e76\u529f\u80fd\uff0c\u4e3a\u5206\u7247\u8bbe\u8ba1\u7684Prometheus\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f88\u597d\u7684\u6c47\u805a\u67e5\u8be2\u70b9\u3002\u4f8b\u5982\u817e\u8baf\u4e91\u7684Kvaas\u5206\u7247\u5de5\u5177\u4e5f\u4f7f\u7528\u4e86Query\u7ec4\u4ef6\u7684\u67e5\u8be2\u529f\u80fd\u3002<\/p>\n

\u56db\u3001\u90e8\u7f72<\/h2>\n

\u90e8\u5206\u7ec4\u4ef6\u7684\u542f\u52a8\u811a\u672c\u5982\u4e0b<\/p>\n

\n
# Sidecar\nExecStart=\/data\/apps\/promes\/thanos\/thanos sidecar \\\n          --tsdb.path=\/data\/apps\/promes\/prometheus\/data \\\n          --prometheus.url=http:\/\/localhost:9090 \\\n          --objstore.config-file=\/data\/apps\/promes\/thanos\/objstore.yml \\\n          --http-address=0.0.0.0:10901 \\\n          --grpc-address=0.0.0.0:10902\n\n# Store\nExecStart=\/data\/apps\/promes\/thanos\/thanos store \\\n          --data-dir=\/data\/apps\/promes\/thanos\/store-cache \\\n          --objstore.config-file=\/data\/apps\/promes\/thanos\/objstore.yml \\\n          --http-address=0.0.0.0:10905 \\\n          --grpc-address=0.0.0.0:10906 \n\n# Query\nExecStart=\/data\/apps\/promes\/thanos\/thanos query \\\n          --http-address=0.0.0.0:10903 \\\n          --grpc-address=0.0.0.0:10904 \\\n          --store=10.140.100.6:10902 \\\n          --store=10.140.100.6:10906 \\\n          --store=172.28.9.46:10902 \\\n          --store=172.28.9.46:10906 \\\n          --query.replica-label=replica<\/code><\/pre>\n<\/div>\n

\u4e94\u3001Thanos\u5e38\u89c1\u95ee\u9898\u7b54\u7591<\/h2>\n

5.1 Thanos-Query\u7684\u53bb\u91cd\u529f\u80fd<\/h4>\n

\u5f88\u591a\u4eba\u90fd\u6709\u8fd9\u4e2a\u7591\u60d1\uff0c\u6bd4\u5982PromA\u3001PromB\u4e24\u4e2aprometheus\u540c\u65f6\u91c7\u96c6\u76f8\u540c\u7684\u76d1\u63a7\u6570\u636e\uff08\u5047\u5982\u5165\u5e93\u65f6\u95f4\u6233\u4e0d\u4e00\u6837\uff0c\u91c7\u96c6\u5230\u7684\u6570\u636e\u4e5f\u7565\u6709\u5dee\u522b\uff09\uff1bThanos-Query\u540c\u65f6\u914d\u7f6ePromA\u548cPromB\u4e3a\u67e5\u8be2\u6570\u636e\u6e90\uff0c\u4f1a\u67e5\u5230\u4e24\u4efd\u6570\u636e\u4e48\uff1f
\n\u4e0d\u4f1a\u3002\u8fd9\u4e5f\u662fThanos-Query\u53bb\u91cd\u529f\u80fd\uff0c\u5b9e\u73b0\u65b9\u5f0f\u662f\uff1a<\/p>\n

\n
\u904d\u5386\u6240\u6709 series, \u53bb\u6389\u6bcf\u4e2a series \u4e2d\u5305\u542b\u7684\u7279\u5b9a replicaLabel(\u6bd4\u5982\u591a\u526f\u672c\u65f6, \u6bcf\u4e2a\u526f\u672c\u90fd\u6709\u4e00\u4e2a\u81ea\u5df1\u7684\u6807\u7b7e); \n\u5982\u679c\u53bb\u6389\u7279\u6b8a\u6807\u7b7e\u540e\u7684\u591a\u4e2a series \u7684\u6807\u7b7e\u5bf9\u662f\u4e00\u6837\u7684, \u5373\u8ba4\u4e3a\u662f\u91cd\u590d\u7684, \u53bb\u6389\u53ea\u7559\u5176\u4e00\u3002<\/code><\/pre>\n<\/div>\n

\u8fd9\u4e2a\u529f\u80fd\u7279\u70b9\uff0c\u53ef\u4ee5\u8ba9\u6211\u4eec\u5728\u6570\u636e\u4e2d\u5fc3\u90e8\u7f722\u4efd\u4e00\u6a21\u4e00\u6837\u7684Prometheus\u4e92\u4e3a\u5907\u4efd\uff0c\u4f7f\u7528Thanos-Query\u67e5\u8be2\u53bb\u91cd\uff08\u2b50\u2b50\u2b50\uff09\u3002<\/p>\n

5.2 Thanos\u80fd\u89e3\u51b3\u5206\u7247\u95ee\u9898\u4e48?<\/h4>\n

Thanos\u6ca1\u6709\u63d0\u4f9bPrometheus\u5206\u7247\u65b9\u6848\uff0c\u53ef\u4ee5\u4f7f\u7528\u624b\u52a8\u5b9a\u4e49\u5206\u7247\u3001hashmod\u3001KvaaS\u6765\u5206\u7247\u3002<\/p>\n

5.3 Thanos\u6709\u6ca1\u6709\u9047\u5230\u4ec0\u4e48\u5751\uff1f<\/h4>\n

sidecar\u5b58\u6d3b\uff0c\u4f46\u662fprometheus\u6302\u6389\u6216\u8005\u6b63\u5728\u91cd\u542f\u72b6\u6001\uff0c\u8fd9\u79cd\u60c5\u51b5\u4f1a\u5bfc\u81f4\u8fd9\u53f0Prometheus\u7684\u6700\u8fd12\u5c0f\u65f6\u6570\u636e\u67e5\u8be2\u4e0d\u5230\u3002
\nQuery\u7ec4\u4ef6\u5b58\u6d3b\uff0c\u4f46\u662f\u540e\u7aef\u6302\u8f7d\u7684store\u7ec4\u4ef6\u6216\u8005sidecar\u7ec4\u4ef6\u6302\u6389\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u67e5\u8be2\u6570\u636e\u4e0d\u5168\u3002
\n\u8fd9\u4e24\u79cd\u60c5\u51b5\u90fd\u5fc5\u987b\u52a0\u5f3a\u5bf9\u4e8e\u76d1\u63a7<\/p>\n

\n
#\u7ec4\u4ef6\u672c\u8eabhealthy\u548cready\u76d1\u63a7\nthanos_status{check=\"healthy\",component=\"query\"} 1\nthanos_status{check=\"ready\",component=\"query\"} 1\nthanos_status{check=\"healthy\",component=\"sidecar\"} 1\nthanos_status{check=\"ready\",component=\"sidecar\"} 1\nthanos_status{check=\"healthy\",component=\"store\"} 1\nthanos_status{check=\"ready\",component=\"store\"} 1\n#sidecar\u7ec4\u4ef6\u4e2dprometheus\u662f\u5426\u5b58\u6d3b\nthanos_sidecar_prometheus_up 1\n#query\u7ec4\u4ef6\u540e\u7aef\u6570\u91cf\nthanos_store_nodes_grpc_connections{external_labels=\"{dc=\\\"AB\\\"}\",store_type=\"sidecar\"} 1\nthanos_store_nodes_grpc_connections{external_labels=\"{dc=\\\"AB\\\"}\",store_type=\"store\"} 1\n#store\u7ec4\u4ef6\u8f7d\u5165\u7684block\u6570\u91cf\nthanos_bucket_store_blocks_loaded 1498<\/code><\/pre>\n<\/div>\n

\u53c2\u8003\u8d44\u6599<\/h2>\n

https:\/\/thanos.io\/tip\/components\/rule.md\/<\/a>
\n
https:\/\/huajiaaa.com\/2020\/11\/22\/thanos-Querier\/<\/a><\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » Thanos-Prometheus\u7684\u6269\u5c55\u597d\u4f19\u4f34<\/a><\/p>","protected":false},"excerpt":{"rendered":"

\u4e00\u3001Thanos\u6982\u8ff0\uff1a Thanos\u4e3b\u8981\u7528\u4e8e\u89e3\u51b3\u5927\u89c4\u6a21prometheus\u90e8\u7f72\u3001\u589e\u5f3aprometheus\u9ad8\u53ef\u7528\u7684\u5de5\u5177\u3002 \u9879\u76ee\u5730\u5740 https:\/\/github.com\/thanos-io\/thanos \u4e8c\u3001Thanos\u67b6\u6784 \u4ece\u5b98\u65b9github\u4e2d\u53ef\u4ee5\u770b\u5230Thanos\u7684\u67b6\u6784\u56fe\uff0c\u6211\u5c31\u4e0d\u8d34\u4e86\uff0c\u6211\u753b\u4e86\u4e00\u4e2a\u66f4\u7b80\u5355\u7684\u56fe\u3002 \u6211\u4eec\u6765\u8bf4\u4e0b\u76f8\u5173\u7684\u7ec4\u4ef6\uff1a thanos-sidecar\uff1a \u4f7f\u7528Sidecar\u65b9\u5f0f\u4e0ePrometheus\u8fde\u63a5\uff0c\u4e3b\u8981\u6709\u4e24\u4e2a\u529f\u80fd\uff1a\u4e00\u662f\u4e0a\u4f20Prometheus\u7684Block\u6570\u636e\u5230\u4e91\u7aef\u7684\u5bf9\u8c61\u5b58\u50a8\uff1b\u4e8c\u662f\u63d0\u4f9bGRPC\u63a5\u53e3\u7ed9Query\u7ec4\u4ef6\u67e5\u8be2\u4f7f\u7528\u3002 thanos-query\uff1a \u67e5\u8be2\u5176\u4ed6\u7ec4\u4ef6\u7684grpc\u63a5\u53e3\u83b7\u53d6\u6570\u636e\uff0c\u5e76\u5bf9\u6570\u636e\u8fdb\u884c\u805a\u5408\u53bb\u91cd\u5904\u7406\u3002 thanos-store\uff1a \u5bf9\u63a5\u4e91\u7aef\u7684\u5bf9\u8c61\u5b58\u50a8\u8fdb\u884c\u67e5\u8be2\uff0c\u63d0\u4f9bGRPC\u63a5\u53e3\u4f9bQuery\u7ec4\u4ef6\u8c03\u7528 thanos-compact\uff1a \u56fe\u4e0a\u6ca1\u6709\u753b\u3002\u5bf9\u5b58\u50a8\u5728\u4e91\u7aef\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u5408\u5e76\u538b\u7f29\u548c\u964d\u91c7\u6837(DownSample\uff09\u3002\u53ef\u4ee5\u51cf\u5c11\u4e91\u7aef\u5b58\u50a8\u5185\u5bb9\u548c\u7a7a\u95f4\u3002\u6211\u4eec\u6ca1\u6709\u4f7f\u7528\uff0c\u56e0\u4e3a\u6211\u4eec\u6ca1\u6709\u964d\u91c7\u6837\u9700\u6c42\uff0c\u5355\u7eaf\u538b\u7f29\u5408\u5e76\u6570\u636e\u964d\u4e0d\u4e86\u591a\u5c11\u5b58\u50a8\u6210\u672c\u3002 thanos-rule\uff1a \u56fe\u4e0a\u6ca1\u6709\u753b\u3002\u8bbe\u5b9a\u89c4\u5219\u67e5\u8be2query\u7ec4\u4ef6\uff0c\u82e5\u89e6\u53d1\u544a\u8b66\uff0c\u5219\u901a\u77e5altermanager\u3002\u4ec5\u5f53\u76d1\u63a7\u6570\u636e\u9700\u8981\u5408\u5e76\u67e5\u8be2\u65f6\u624d\u9700\u8981\u5f00\u542f\uff0c\u5426\u5219\u76f4\u63a5\u4f7f\u7528prometheus\u7684rule\u5c31\u53ef\u4ee5\u3002 \u4e09\u3001Thanos\u89e3\u51b3\u4e86\u4ec0\u4e48\u95ee\u9898 3.1 \u76d1\u63a7\u6570\u636e\u4e0a\u4f20\u5230\u4e91\u7aef\u5bf9\u8c61\u5b58\u50a8 \u6211\u4eec\u77e5\u9053Prometheus\u5b98\u65b9\u4e0d\u63a8\u8350\u5728\u672c\u5730\u5b58\u50a8\u957f\u65f6\u95f4\u7684\u6570\u636e\uff08\u4e5f\u5b58\u5728\u6587\u4ef6\u6253\u5f00\u8fc7\u591a\u7684\u98ce\u9669\uff09\uff0c\u6211\u4eec\u66fe\u7ecf\u5b58\u50a8\u8fc7\u534a\u5e74\u7684\u6570\u636e\uff0c\u6bcf\u4e00\u6b21\u91cd\u542fPrometheus\u52a0\u8f7d\u5386\u53f2\u6570\u636e\u90fd\u662f\u75db\u82e6\u7684\u7b49\u5f85\uff0c\u9700\u898120-30\u5206\u949f\uff0c\u5728\u8fd9\u671f\u95f4\u76d1\u63a7\u90fd\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002\u5c3d\u7ba1Prometheus\u6709remote write\u7b49\u529f\u80fd\uff0c\u4f46\u662f\u6210\u672c\u4f4e\u5ec9\u7684\u4e91\u7aef\u5bf9\u8c61\u5b58\u50a8\u786e\u662f\u4e2a\u597d\u529e\u6cd5\u3002 3.2 \u529f\u80fd\u5f3a\u5927\u7684Query\u7ec4\u4ef6 Query\u7ec4\u4ef6\u62e5\u6709\u53bb\u91cd\u5408\u5e76\u529f\u80fd\uff0c\u4e3a\u5206\u7247\u8bbe\u8ba1\u7684Prometheus\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f88\u597d\u7684\u6c47\u805a\u67e5\u8be2\u70b9\u3002\u4f8b\u5982\u817e\u8baf\u4e91\u7684Kvaas\u5206\u7247\u5de5\u5177\u4e5f\u4f7f\u7528\u4e86Query\u7ec4\u4ef6\u7684\u67e5\u8be2\u529f\u80fd\u3002 \u56db\u3001\u90e8\u7f72 \u90e8\u5206\u7ec4\u4ef6\u7684\u542f\u52a8\u811a\u672c\u5982\u4e0b # Sidecar ExecStart=\/data\/apps\/promes\/thanos\/thanos sidecar \\ –tsdb.path=\/data\/apps\/promes\/prometheus\/data \\ –prometheus.url=http:\/\/localhost:9090 \\ –objstore.config-file=\/data\/apps\/promes\/thanos\/objstore.yml \\ –http-address=0.0.0.0:10901 \\ –grpc-address=0.0.0.0:10902 # Store ExecStart=\/data\/apps\/promes\/thanos\/thanos store \\ –data-dir=\/data\/apps\/promes\/thanos\/store-cache \\ –objstore.config-file=\/data\/apps\/promes\/thanos\/objstore.yml \\ –http-address=0.0.0.0:10905 \\ –grpc-address=0.0.0.0:10906 # Query […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[190,223],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1542"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1542"}],"version-history":[{"count":1,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1542\/revisions"}],"predecessor-version":[{"id":1543,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1542\/revisions\/1543"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}