{"id":115515,"date":"2026-10-12T10:57:05","date_gmt":"2026-10-12T02:57:05","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115515.html"},"modified":"2026-10-12T10:57:05","modified_gmt":"2026-10-12T02:57:05","slug":"litmus-chaoscenter-graphql-%e6%9c%8d%e5%8a%a1%e5%99%a8-prometheus-%e6%8c%87%e6%a0%87%e5%85%a8%e8%a7%a3%e6%9e%90%e4%b8%8e-grafana-%e5%8f%af%e8%a7%86%e5%8c%96%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115515.html","title":{"rendered":"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218"},"content":{"rendered":"<ul class=\"gcb-tag-list\">\n<li><span class=\"gcb-tag\">\u4e91\u539f\u751f<\/span><\/li>\n<li><span class=\"gcb-tag\">\u8fd0\u7ef4<\/span><\/li>\n<li><span class=\"gcb-tag\">\u53ef\u89c2\u6d4b\u6027<\/span><\/li>\n<\/ul>\n<h3 class=\"gcb-project-title\">\u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011litmus<\/h3>\n<p class=\"gcb-project-desc\">Litmus helps SREs and developers practice chaos engineering in a Cloud-native way. Chaos experiments are published at the ChaosHub (https:\/\/hub.litmuschaos.io). Community notes is at https:\/\/hackmd.io\/a4Zu_sH4TZGeih-xCimi3Q<\/p>\n<p>    <span class=\"gcb-project-addr-label\">\u9879\u76ee\u5730\u5740&#xff1a;<\/span><br \/>\n    <span class=\"gcb-project-addr-link\">https:\/\/gitcode.com\/gh_mirrors\/li\/litmus<\/span> <\/p>\n<p>  <span class=\"gcb-project-btn\"> <span class=\"gcb-project-btn-main\">\u70b9\u51fb\u67e5\u770b<\/span> <span class=\"gcb-project-btn-sub\">\u514d\u8d39\u4e0b\u8f7d<\/span> <\/span> <\/p>\n<p>Litmus \u662f\u4e00\u4e2a\u4ee5\u4e91\u539f\u751f\u65b9\u5f0f\u5e2e\u52a9 SRE \u4e0e\u5f00\u53d1\u8005\u5b9e\u8df5\u6df7\u6c8c\u5de5\u7a0b\u7684\u5f00\u6e90\u9879\u76ee&#xff0c;\u5176\u63a7\u5236\u5e73\u9762&#xff08;ChaosCenter&#xff09;\u4e2d\u7684 GraphQL \u670d\u52a1\u5668\u5728 chaoscenter\/graphql\/server\/pkg\/metrics \u5305\u4e2d\u5185\u7f6e\u4e86\u4e00\u5957\u5b8c\u6574\u7684 Prometheus \u6307\u6807\u4f53\u7cfb\u3002\u672c\u6587\u5c06\u4ee5\u8be5\u5305\u6587\u6863\u4e3a\u9aa8\u67b6&#xff0c;\u7ed3\u5408\u4ed3\u5e93\u6e90\u7801\u6df1\u5165\u5256\u6790 litmus_api_*\u3001litmus_experiment_*\u3001litmus_*_agents \u4e09\u7c7b\u5171 11 \u4e2a\u6307\u6807\u7684\u5b9a\u4e49\u3001\u6807\u7b7e\u4e0e\u91c7\u96c6\u94fe\u8def&#xff0c;\u5e76\u7ed9\u51fa\u4ece\u7aef\u70b9\u9a8c\u8bc1\u3001Prometheus \u6293\u53d6\u914d\u7f6e\u5230 Grafana \u4eea\u8868\u76d8\u5bfc\u5165\u7684\u5b8c\u6574\u5b9e\u6218\u6b65\u9aa4\u3002\u8bfb\u5b8c\u672c\u6587&#xff0c;\u4f60\u5c06\u80fd\u72ec\u7acb\u4e3a Litmus ChaosCenter \u63a7\u5236\u5e73\u9762\u642d\u5efa\u4e00\u5957\u53ef\u89c2\u6d4b\u3001\u53ef\u544a\u8b66\u7684\u6307\u6807\u76d1\u63a7\u65b9\u6848\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u6307\u6807\u4f53\u7cfb\u7684\u843d\u70b9&#xff1a;\u63a7\u5236\u5e73\u9762\u53ef\u89c2\u6d4b\u6027<\/h3>\n<p>Litmus \u7684\u6df7\u6c8c\u5b9e\u9a8c\u7f16\u6392\u5206\u4e3a\u63a7\u5236\u5e73\u9762\u4e0e\u6267\u884c\u5e73\u9762&#xff1a;\u63a7\u5236\u5e73\u9762\u7531 ChaosCenter \u7684 GraphQL \u670d\u52a1\u5668\u3001\u8ba4\u8bc1\u670d\u52a1\u3001\u4e8b\u4ef6\u8ffd\u8e2a\u5668\u4e0e\u8ba2\u9605\u5668\u7b49\u7ec4\u4ef6\u6784\u6210&#xff0c;\u8d1f\u8d23\u5b9e\u9a8c\u7f16\u6392\u3001\u57fa\u7840\u8bbe\u65bd&#xff08;Infra\/Agent&#xff09;\u7ba1\u7406\u548c\u7528\u6237\u4ea4\u4e92&#xff1b;\u6267\u884c\u5e73\u9762\u5219\u5728\u76ee\u6807\u96c6\u7fa4\u4e0a\u8fd0\u884c\u6df7\u6c8c\u5b9e\u9a8c\u3002\u800c pkg\/metrics \u5305\u6b63\u662f\u63a7\u5236\u5e73\u9762\u4e2d\u8d1f\u8d23\u66b4\u9732 Prometheus \u6307\u6807\u7684\u6838\u5fc3\u6a21\u5757&#xff0c;\u5b83\u56de\u7b54\u4e86\u4e09\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<li>API \u662f\u5426\u5065\u5eb7\u2014\u2014\u8bf7\u6c42\u91cf\u3001\u54cd\u5e94\u5ef6\u8fdf\u3001\u9519\u8bef\u7387\u3001\u8ba4\u8bc1\u5931\u8d25&#xff1b;<\/li>\n<li>\u5b9e\u9a8c\u662f\u5426\u6309\u9884\u671f\u8fd0\u884c\u2014\u2014\u5b9e\u9a8c\u603b\u91cf\u3001\u8fd0\u884c\u6b21\u6570\u3001\u8fd0\u884c\u65f6\u957f\u3001\u5f53\u524d\u72b6\u6001&#xff1b;<\/li>\n<li>\u6df7\u6c8c Agent&#xff08;Infrastructure&#xff09;\u662f\u5426\u5728\u7ebf\u2014\u2014\u5df2\u8fde\u63a5\u3001\u5df2\u65ad\u5f00\u3001\u6ce8\u518c\u603b\u6570\u3002<\/li>\n<p>\u8fd9\u4e9b\u6307\u6807\u7edf\u4e00\u901a\u8fc7\u4e00\u4e2a\u72ec\u7acb\u7684 HTTP \u670d\u52a1\u66b4\u9732&#xff0c;\u9ed8\u8ba4\u7aef\u53e3 8889&#xff0c;\u8def\u5f84 \/metrics&#xff0c;\u7531 metrics.go \u4e2d\u5b9a\u4e49\u7684 11 \u4e2a Prometheus \u6307\u6807\u5411\u91cf\u627f\u8f7d\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u6307\u6807\u7aef\u70b9\u4e0e\u7aef\u53e3\u914d\u7f6e<\/h3>\n<h4>2.1 \u72ec\u7acb\u6307\u6807\u670d\u52a1\u5668<\/h4>\n<p>\u4e0e\u4e1a\u52a1 API \u4e0d\u540c&#xff0c;\u6307\u6807\u5e76\u4e0d\u6302\u5728\u4e3b GraphQL \u8def\u7531\u4e0a&#xff0c;\u800c\u662f\u7531 startMetricsServer() \u542f\u52a8\u4e00\u4e2a\u72ec\u7acb\u3001\u8f7b\u91cf\u7684 Gin HTTP \u670d\u52a1&#xff0c;\u5176\u5b9e\u73b0\u4f4d\u4e8e server.go&#xff1a;<\/p>\n<p>\/\/ startMetricsServer starts a separate HTTP server for Prometheus metrics<br \/>\nfunc startMetricsServer() {<br \/>\nmetricsRouter :&#061; gin.New()<br \/>\nmetricsRouter.Use(gin.Recovery())<br \/>\nmetricsRouter.GET(&#034;\/metrics&#034;, gin.WrapH(promhttp.Handler()))<\/p>\n<p>metricsPort :&#061; utils.Config.MetricsPort<br \/>\nlog.Infof(&#034;Metrics server running at http:\/\/localhost:%s\/metrics&#034;, metricsPort)<\/p>\n<p>if err :&#061; http.ListenAndServe(&#034;:&#034;&#043;metricsPort, metricsRouter); err !&#061; nil {<br \/>\nlog.Fatalf(&#034;Failed to start metrics server: %v&#034;, err)<br \/>\n}<br \/>\n}<\/p>\n<p>\u5173\u952e\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u7aef\u70b9\u4f7f\u7528 promhttp.Handler() \u8f93\u51fa\u6807\u51c6 Prometheus \u6587\u672c\u683c\u5f0f&#xff0c;\u53ef\u76f4\u63a5\u88ab Prometheus \u6293\u53d6&#xff1b;<\/li>\n<li>\u8be5\u670d\u52a1\u5668\u5728 main() \u4e2d\u4ee5 go startMetricsServer() \u534f\u7a0b\u65b9\u5f0f\u542f\u52a8&#xff08;\u89c1 server.go&#xff09;&#xff0c;\u4e0e GraphQL \u4e3b\u670d\u52a1\u4e92\u4e0d\u963b\u585e&#xff1b;<\/li>\n<li>\u65e5\u5fd7\u4f1a\u6253\u5370\u5b9e\u9645\u76d1\u542c\u5730\u5740&#xff0c;\u5f62\u5982 Metrics server running at http:\/\/localhost:8889\/metrics\u3002<\/li>\n<\/ul>\n<h4>2.2 \u7aef\u53e3&#xff1a;METRICS_PORT \u73af\u5883\u53d8\u91cf<\/h4>\n<p>\u7aef\u53e3\u7531\u73af\u5883\u53d8\u91cf METRICS_PORT \u63a7\u5236&#xff0c;\u9ed8\u8ba4\u503c\u4e3a 8889&#xff0c;\u5176\u914d\u7f6e\u5b9a\u4e49\u4f4d\u4e8e utils\/variables.go&#xff1a;<\/p>\n<p>MetricsPort string &#096;envconfig:&#034;METRICS_PORT&#034; default:&#034;8889&#034;&#096;<\/p>\n<p>\u56e0\u6b64\u4f60\u65e2\u53ef\u4ee5\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u8986\u76d6\u7aef\u53e3&#xff08;\u4f8b\u5982\u90e8\u7f72\u591a\u5957\u63a7\u5236\u5e73\u9762\u907f\u514d\u51b2\u7a81\u65f6&#xff09;&#xff0c;\u4e5f\u53ef\u4ee5\u5728\u90e8\u7f72\u6e05\u5355\u4e2d\u6309\u9700\u6ce8\u5165&#xff1a;<\/p>\n<p>env:<br \/>\n  &#8211; name: METRICS_PORT<br \/>\n    value: &#034;8889&#034;<\/p>\n<p>\u9a8c\u8bc1\u65b9\u5f0f&#xff1a;\u542f\u52a8 ChaosCenter \u540e&#xff0c;\u76f4\u63a5\u8bbf\u95ee http:\/\/localhost:8889\/metrics \u5373\u53ef\u770b\u5230\u6240\u6709\u4ee5 litmus_ \u5f00\u5934\u7684\u6307\u6807\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001API \u6307\u6807&#xff08;litmus_api_*&#xff09;<\/h3>\n<p>\u8fd9\u7ec4\u6307\u6807\u63cf\u8ff0 GraphQL \u670d\u52a1\u5668\u7684\u8bf7\u6c42\u5904\u7406\u60c5\u51b5&#xff0c;\u5747\u5728 metrics.go \u4e2d\u5b9a\u4e49&#xff1a;<\/p>\n<table>\n<tr>\u6307\u6807\u540d\u7c7b\u578b\u542b\u4e49\u6807\u7b7e<\/tr>\n<tbody>\n<tr>\n<td>litmus_api_requests_total<\/td>\n<td>Counter&#xff08;CounterVec&#xff09;<\/td>\n<td>\u5230\u8fbe GraphQL \u670d\u52a1\u5668\u7684 API \u8bf7\u6c42\u603b\u6570&#xff0c;\u643a\u5e26 GraphQL \u64cd\u4f5c\u4fe1\u606f<\/td>\n<td>endpoint\u3001status\u3001operation_name\u3001operation_type<\/td>\n<\/tr>\n<tr>\n<td>litmus_api_response_time_milliseconds<\/td>\n<td>Histogram&#xff08;HistogramVec&#xff09;<\/td>\n<td>API \u8bf7\u6c42\u54cd\u5e94\u8017\u65f6&#xff08;\u6beb\u79d2&#xff09;&#xff0c;\u5206\u6876\u4ece 10ms \u5230 5s<\/td>\n<td>endpoint\u3001operation_name\u3001operation_type<\/td>\n<\/tr>\n<tr>\n<td>litmus_api_error_requests_total<\/td>\n<td>Counter&#xff08;CounterVec&#xff09;<\/td>\n<td>\u51fa\u9519\u8bf7\u6c42\u603b\u6570<\/td>\n<td>endpoint\u3001error_type<\/td>\n<\/tr>\n<tr>\n<td>litmus_api_authentication_failures_total<\/td>\n<td>Counter&#xff08;CounterVec&#xff09;<\/td>\n<td>\u8ba4\u8bc1\u5931\u8d25\u6b21\u6570<\/td>\n<td>auth_method<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3.1 \u6807\u7b7e\u4e0e\u53d6\u503c<\/h4>\n<ul>\n<li>endpoint&#xff1a;Gin \u8def\u7531\u7684\u5b8c\u6574\u8def\u5f84&#xff0c;\u5982 \/query&#xff1b;\u672a\u5339\u914d\u5230\u4efb\u4f55\u8def\u7531\u65f6\u8bb0\u4e3a unmatched&#xff08;\u89c1 middleware.go&#xff09;&#xff1b;<\/li>\n<li>status&#xff1a;HTTP \u72b6\u6001\u7801\u5b57\u7b26\u4e32&#xff0c;\u5982 200\u3001500\u3001404&#xff1b;<\/li>\n<li>operation_name&#xff1a;GraphQL \u64cd\u4f5c\u540d&#xff0c;\u5982 listExperiment\u3001runChaosExperiment\u3001getExperiment&#xff1b;\u533f\u540d\u64cd\u4f5c\u8bb0\u4e3a anonymous&#xff0c;\u975e GraphQL \u8bf7\u6c42\u8bb0\u4e3a N\/A&#xff1b;<\/li>\n<li>operation_type&#xff1a;GraphQL \u64cd\u4f5c\u7c7b\u578b&#xff0c;\u53d6\u503c\u4e3a query \u6216 mutation&#xff1b;<\/li>\n<li>error_type&#xff1a;client_error&#xff08;HTTP \u72b6\u6001\u7801 \u2265 400 \u4e14 &lt; 500&#xff09;\u6216 server_error&#xff08;\u72b6\u6001\u7801 \u2265 500&#xff09;&#xff1b;<\/li>\n<li>auth_method&#xff1a;\u8ba4\u8bc1\u65b9\u5f0f&#xff0c;\u76ee\u524d\u6e90\u7801\u4e2d\u4e3a bearer&#xff08;\u89c1 authorization\/middleware.go&#xff09;\u3002<\/li>\n<\/ul>\n<h4>3.2 \u76f4\u65b9\u56fe\u5206\u6876<\/h4>\n<p>litmus_api_response_time_milliseconds \u7684\u5206\u6876\u5b9a\u4e49\u5982\u4e0b&#xff08;\u5355\u4f4d\u6beb\u79d2&#xff09;&#xff1a;<\/p>\n<p>Buckets: []float64{10, 50, 100, 200, 500, 1000, 2000, 5000},<\/p>\n<p>\u5373\u8986\u76d6 10ms&#xff5e;5s \u7684\u54cd\u5e94\u8017\u65f6\u533a\u95f4&#xff0c;\u914d\u5408 histogram_quantile \u53ef\u8ba1\u7b97 p50\/p95\/p99 \u7b49\u5206\u4f4d\u5ef6\u8fdf&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>histogram_quantile(0.99, sum by (le) (rate(litmus_api_response_time_milliseconds_bucket[5m])))<\/p>\n<h4>3.3 \u91c7\u96c6\u94fe\u8def<\/h4>\n<p>API \u6307\u6807\u7684\u5199\u5165\u53d1\u751f\u5728 middleware.go \u7684 MetricsMiddleware() \u4e2d&#xff0c;\u5b83\u662f\u4e00\u4e2a Gin \u4e2d\u95f4\u4ef6&#xff0c;\u901a\u8fc7 router.Use(metrics.MetricsMiddleware()) \u6302\u8f7d\u5728\u5168\u5c40\u8def\u7531\u4e0a&#xff08;\u89c1 server.go&#xff09;\u3002\u5176\u6267\u884c\u6d41\u7a0b\u4e3a&#xff1a;<\/p>\n<li>\u8bb0\u5f55\u8bf7\u6c42\u5f00\u59cb\u65f6\u95f4&#xff0c;\u53d6\u5f97\u8def\u7531 FullPath()&#xff1b;<\/li>\n<li>c.Next() \u653e\u884c\u8bf7\u6c42&#xff1b;<\/li>\n<li>\u8bf7\u6c42\u7ed3\u675f\u540e\u8ba1\u7b97\u8017\u65f6&#xff08;time.Since(start).Milliseconds()&#xff09;&#xff1b;<\/li>\n<li>\u4ece context \u4e2d\u8bfb\u53d6 GraphQL \u64cd\u4f5c\u540d\u4e0e\u7c7b\u578b&#xff08;\u952e\u4e3a graphql_operation_name\u3001graphql_operation_type&#xff0c;\u5b9a\u4e49\u4e8e metrics.go&#xff09;&#xff1b;<\/li>\n<li>\u9012\u589e\u8bf7\u6c42\u8ba1\u6570\u3001\u5199\u5165\u8017\u65f6\u89c2\u6d4b\u503c&#xff1b;\u82e5\u72b6\u6001\u7801 \u2265 400 \u5219\u6309 client_error\/server_error \u5f52\u7c7b\u9012\u589e\u9519\u8bef\u8ba1\u6570\u3002<\/li>\n<p>\u800c GraphQL \u64cd\u4f5c\u4fe1\u606f\u7531 server.go \u4e2d\u7684 AroundOperations \u62e6\u622a\u5668\u6ce8\u5165 context&#xff1a;<\/p>\n<p>srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {<br \/>\noc :&#061; graphql.GetOperationContext(ctx)<br \/>\noperationType :&#061; &#034;query&#034;<br \/>\nif oc.Operation !&#061; nil &amp;&amp; oc.Operation.Operation &#061;&#061; &#034;mutation&#034; {<br \/>\noperationType &#061; &#034;mutation&#034;<br \/>\n}<br \/>\noperationName :&#061; oc.OperationName<br \/>\nif operationName &#061;&#061; &#034;&#034; {<br \/>\noperationName &#061; &#034;anonymous&#034;<br \/>\n}<br \/>\n\/\/ Store operation details in context for HTTP middleware to use<br \/>\nctx &#061; context.WithValue(ctx, metrics.GraphqlOperationNameKey, operationName)<br \/>\nctx &#061; context.WithValue(ctx, metrics.GraphqlOperationTypeKey, operationType)<br \/>\nreturn next(ctx)<br \/>\n})<\/p>\n<p>\u8ba4\u8bc1\u5931\u8d25\u6307\u6807\u5219\u7531\u8ba4\u8bc1\u4e2d\u95f4\u4ef6\u5728 JWT \u4ee4\u724c\u88ab\u540a\u9500\u65f6\u9012\u589e&#xff08;\u89c1 authorization\/middleware.go&#xff09;&#xff0c;\u4ece\u800c\u8ba9\u8fd0\u7ef4\u8005\u53ef\u4ee5\u533a\u5206&#034;\u4e1a\u52a1\u51fa\u9519&#034;\u4e0e&#034;\u8ba4\u8bc1\u88ab\u62d2&#034;\u4e24\u7c7b\u5f02\u5e38\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u5b9e\u9a8c\u6307\u6807&#xff08;litmus_experiment_*&#xff09;<\/h3>\n<p>\u8fd9\u7ec4\u6307\u6807\u63cf\u8ff0\u6df7\u6c8c\u5b9e\u9a8c\u53ca\u5176\u8fd0\u884c\u60c5\u51b5&#xff0c;\u5b9a\u4e49\u4e8e metrics.go&#xff1a;<\/p>\n<table>\n<tr>\u6307\u6807\u540d\u7c7b\u578b\u542b\u4e49\u6807\u7b7e<\/tr>\n<tbody>\n<tr>\n<td>litmus_experiments_total<\/td>\n<td>Gauge&#xff08;GaugeVec&#xff09;<\/td>\n<td>\u7cfb\u7edf\u4e2d\u7684\u5b9e\u9a8c\u603b\u6570<\/td>\n<td>project_id\u3001status\u3001infra_id<\/td>\n<\/tr>\n<tr>\n<td>litmus_experiment_runs_total<\/td>\n<td>Counter&#xff08;CounterVec&#xff09;<\/td>\n<td>\u5b9e\u9a8c\u7d2f\u8ba1\u8fd0\u884c\u6b21\u6570<\/td>\n<td>project_id\u3001experiment_id\u3001experiment_name\u3001infra_id<\/td>\n<\/tr>\n<tr>\n<td>litmus_experiment_run_duration_seconds<\/td>\n<td>Histogram&#xff08;HistogramVec&#xff09;<\/td>\n<td>\u5b9e\u9a8c\u8fd0\u884c\u8017\u65f6&#xff08;\u79d2&#xff09;&#xff0c;\u5206\u6876\u4ece 1s \u5230 30 \u5206\u949f<\/td>\n<td>project_id\u3001experiment_id\u3001experiment_name\u3001infra_id<\/td>\n<\/tr>\n<tr>\n<td>litmus_experiment_status<\/td>\n<td>Gauge&#xff08;GaugeVec&#xff09;<\/td>\n<td>\u5b9e\u9a8c\u5f53\u524d\u8fd0\u884c\u72b6\u6001&#xff1a;1 &#061; \u8fd0\u884c\u4e2d&#xff0c;0 &#061; \u672a\u8fd0\u884c<\/td>\n<td>project_id\u3001experiment_id\u3001experiment_name\u3001status\u3001infra_id<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4.1 \u76f4\u65b9\u56fe\u5206\u6876<\/h4>\n<p>litmus_experiment_run_duration_seconds \u7684\u5206\u6876\u8986\u76d6 1 \u79d2\u5230 30 \u5206\u949f&#xff1a;<\/p>\n<p>Buckets: []float64{1, 5, 10, 30, 60, 120, 300, 600, 1200, 1800},<\/p>\n<p>\u9002\u5408\u7edf\u8ba1\u5927\u591a\u6570\u6df7\u6c8c\u5b9e\u9a8c&#xff08;\u4ece pod \u5220\u9664\u5230\u8d1f\u8f7d\u6ce8\u5165&#xff09;\u7684\u65f6\u957f\u5206\u5e03\u3002<\/p>\n<h4>4.2 \u5199\u5165\u65f6\u673a\u4e0e\u6e90\u7801\u4f9d\u636e<\/h4>\n<ul>\n<li>\n<p>\u5b9e\u9a8c\u521b\u5efa&#xff1a;\u5728 chaos_experiment\/handler\/handler.go \u4e2d&#xff0c;\u521b\u5efa\u5b9e\u9a8c\u6210\u529f\u540e\u4ee5 ExperimentsTotal.WithLabelValues(projectID, &#034;Active&#034;, request.InfraID).Inc() \u9012\u589e\u5b9e\u9a8c\u603b\u91cf&#xff08;\u6ce8\u610f&#xff1a;\u8be5\u6307\u6807\u58f0\u660e\u4e3a Gauge&#xff0c;\u4f46\u5b9e\u9645\u4ee5 Inc() \u65b9\u5f0f\u4f7f\u7528&#xff0c;\u53cd\u6620\u7684\u662f\u5b9e\u9a8c\u7d2f\u79ef\u603b\u91cf&#xff0c;status \u6807\u7b7e\u5f53\u524d\u53d6\u503c\u4e3a Active&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b9e\u9a8c\u8fd0\u884c\u542f\u52a8&#xff1a;\u5728 chaos_experiment_run\/handler\/handler.go \u4e2d&#xff0c;\u5b9e\u9a8c\u8fd0\u884c\u8bb0\u5f55\u521b\u5efa\u6210\u529f\u5e76\u63d0\u4ea4\u4e8b\u52a1\u540e&#xff1a;<\/p>\n<\/li>\n<\/ul>\n<p>metrics.ExperimentRunsTotal.WithLabelValues(projectID, workflow.ExperimentID, workflow.Name, workflow.InfraID).Inc()<br \/>\nmetrics.ExperimentStatus.WithLabelValues(projectID, workflow.ExperimentID, workflow.Name, string(model.ExperimentRunStatusQueued), workflow.InfraID).Set(0)<\/p>\n<p>\u5373\u6392\u961f&#xff08;Queued&#xff09;\u9636\u6bb5\u72b6\u6001\u503c\u4e3a 0&#xff1b;\u968f\u540e\u5728 cron \u5b9e\u9a8c\u542f\u52a8\u65f6&#xff08;\u89c1 handler.go&#xff09;\u5c06\u72b6\u6001\u7f6e\u4e3a 1&#xff08;Running&#xff09;&#xff1a;<\/p>\n<p>metrics.ExperimentStatus.WithLabelValues(projectID, workflow.ExperimentID, workflow.Name, string(model.ExperimentRunStatusRunning), workflow.InfraID).Set(1)<br \/>\nmetrics.ExperimentRunsTotal.WithLabelValues(projectID, workflow.ExperimentID, workflow.Name, workflow.InfraID).Inc()<\/p>\n<ul>\n<li>\u5b9e\u9a8c\u5b8c\u6210&#xff1a;\u5728 handler.go \u4e2d&#xff0c;\u5f53\u8ba2\u9605\u8005\u4e0a\u62a5\u5b9e\u9a8c\u5b8c\u6210\u4e8b\u4ef6\u540e&#xff0c;\u4ee5 (\u5f53\u524d\u65f6\u95f4 &#8211; \u521b\u5efa\u65f6\u95f4) \u6362\u7b97\u79d2\u6570\u89c2\u6d4b\u8fd0\u884c\u65f6\u957f&#xff0c;\u5e76\u5c06\u72b6\u6001\u7f6e 0&#xff1a;<\/li>\n<\/ul>\n<p>duration :&#061; float64(time.Now().UnixMilli()-experimentRun.CreatedAt) \/ 1000.0 \/\/ Convert to seconds<br \/>\nmetrics.ExperimentRunDuration.WithLabelValues(experiment.ProjectID, event.ExperimentID, experimentRun.ExperimentName, experiment.InfraID).Observe(duration)<br \/>\nmetrics.ExperimentStatus.WithLabelValues(experiment.ProjectID, event.ExperimentID, experimentRun.ExperimentName, executionData.Phase, experiment.InfraID).Set(0)<\/p>\n<p>\u56e0\u6b64 litmus_experiment_status \u7684\u503c\u8bed\u4e49\u4e3a&#xff1a;1 \u8868\u793a\u5b9e\u9a8c\u6b63\u5728\u8fd0\u884c&#xff08;Running&#xff09;&#xff0c;0 \u8868\u793a\u5b9e\u9a8c\u672a\u5728\u8fd0\u884c&#xff08;Queued\u3001Completed\u3001Stopped\u3001Error \u7b49\u9636\u6bb5&#xff09;&#xff1b;\u800c status \u6807\u7b7e\u59cb\u7ec8\u643a\u5e26\u5177\u4f53\u9636\u6bb5\u5b57\u7b26\u4e32&#xff08;\u5982 Running\u3001Completed\u3001Stopped\u3001Error&#xff09;&#xff0c;\u53ef\u4ee5\u636e\u6b64\u533a\u5206&#034;\u6b63\u5728\u8fd0\u884c&#034;\u4e0e&#034;\u5df2\u5b8c\u6210&#034;\u5e76\u5206\u522b\u7b5b\u9009\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001Agent&#xff08;\u57fa\u7840\u8bbe\u65bd&#xff09;\u6307\u6807&#xff08;litmus_*_agents&#xff09;<\/h3>\n<p>\u8fd9\u7ec4\u6307\u6807\u63cf\u8ff0 ChaosCenter \u7ba1\u7406\u7684\u6df7\u6c8c Agent&#xff08;\u5373\u8fde\u63a5\u5404\u76ee\u6807\u96c6\u7fa4\u7684\u6df7\u6c8c\u57fa\u7840\u8bbe\u65bd&#xff09;&#xff0c;\u5b9a\u4e49\u4e8e metrics.go&#xff1a;<\/p>\n<table>\n<tr>\u6307\u6807\u540d\u7c7b\u578b\u542b\u4e49\u6807\u7b7e<\/tr>\n<tbody>\n<tr>\n<td>litmus_connected_agents<\/td>\n<td>Gauge&#xff08;GaugeVec&#xff09;<\/td>\n<td>\u5f53\u524d\u5df2\u8fde\u63a5\u7684\u6df7\u6c8c Agent \u6570\u91cf<\/td>\n<td>project_id<\/td>\n<\/tr>\n<tr>\n<td>litmus_disconnected_agents<\/td>\n<td>Gauge&#xff08;GaugeVec&#xff09;<\/td>\n<td>\u5f53\u524d\u5904\u4e8e\u65ad\u5f00\u72b6\u6001\u7684 Agent \u6570\u91cf<\/td>\n<td>project_id<\/td>\n<\/tr>\n<tr>\n<td>litmus_total_agents<\/td>\n<td>Gauge&#xff08;GaugeVec&#xff09;<\/td>\n<td>\u5df2\u6ce8\u518c\u7684 Agent \u603b\u6570<\/td>\n<td>project_id<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>5.1 \u5468\u671f\u6027\u5237\u65b0\u903b\u8f91<\/h4>\n<p>\u8fd9\u7ec4 Gauge \u4e0d\u662f\u9010\u4e8b\u4ef6\u66f4\u65b0\u7684&#xff0c;\u800c\u662f\u7531 chaos_infrastructure\/service.go \u4e2d\u7684 RecordInfraMetrics(ctx) \u4ee5 30 \u79d2\u4e3a\u5468\u671f\u4ece\u6570\u636e\u5e93\u67e5\u8be2\u5e76\u5237\u65b0&#xff1a;<\/p>\n<p>ticker :&#061; time.NewTicker(30 * time.Second)<br \/>\n&#8230;<br \/>\ninfras, err :&#061; in.infraOperator.GetInfras(ctx, bson.D{{&#034;is_removed&#034;, false}})<br \/>\nprojectCounts :&#061; make(map[string][2]int) \/\/ [connected, total]<br \/>\nfor _, infra :&#061; range infras {<br \/>\ncounts :&#061; projectCounts[infra.ProjectID]<br \/>\ncounts[1]&#043;&#043; \/\/ total<br \/>\nif infra.IsActive {<br \/>\ncounts[0]&#043;&#043; \/\/ connected<br \/>\n}<br \/>\nprojectCounts[infra.ProjectID] &#061; counts<br \/>\n}<br \/>\nfor projectID, counts :&#061; range projectCounts {<br \/>\nmetrics.ConnectedAgents.WithLabelValues(projectID).Set(float64(counts[0]))<br \/>\nmetrics.DisconnectedAgents.WithLabelValues(projectID).Set(float64(counts[1] &#8211; counts[0]))<br \/>\nmetrics.TotalAgents.WithLabelValues(projectID).Set(float64(counts[1]))<br \/>\n}<\/p>\n<p>\u7531\u6b64\u53ef\u63a8\u5bfc\u51fa\u4ee5\u4e0b\u76d1\u63a7\u53e3\u5f84&#xff1a;<\/p>\n<ul>\n<li>\u5df2\u8fde\u63a5 Agent &#061; is_removed&#061;false \u4e14 IsActive&#061;true \u7684\u57fa\u7840\u8bbe\u65bd\u6570\u91cf&#xff1b;<\/li>\n<li>\u65ad\u5f00 Agent &#061; \u6ce8\u518c\u603b\u6570\u51cf\u53bb\u5df2\u8fde\u63a5\u6570&#xff08;\u5373 disconnected &#061; total &#8211; connected&#xff09;&#xff1b;<\/li>\n<li>\u8be5\u6307\u6807\u4ee5 project_id \u7ef4\u5ea6\u533a\u5206&#xff0c;\u53ef\u5206\u522b\u76d1\u63a7\u6bcf\u4e2a\u9879\u76ee\u7684 Agent \u5728\u7ebf\u7387&#xff0c;\u4f8b\u5982\u544a\u8b66 litmus_disconnected_agents &gt; 0\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u516d\u3001\u5feb\u901f\u9a8c\u8bc1\u4e0e Prometheus \u91c7\u96c6\u914d\u7f6e<\/h3>\n<h4>6.1 \u76f4\u63a5\u8bbf\u95ee\u7aef\u70b9<\/h4>\n<p>\u5728\u672c\u5730\u5f00\u53d1\u73af\u5883&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u9a8c\u8bc1\u6307\u6807\u8f93\u51fa&#xff1a;<\/p>\n<p>curl http:\/\/localhost:8889\/metrics<\/p>\n<p>\u5728 Kubernetes \u90e8\u7f72\u573a\u666f\u4e2d&#xff0c;\u5148\u901a\u8fc7\u7aef\u53e3\u8f6c\u53d1\u66b4\u9732\u6307\u6807\u7aef\u53e3&#xff1a;<\/p>\n<p>kubectl port-forward -n litmus deployment\/litmusportal-server 8889:8889<br \/>\ncurl http:\/\/localhost:8889\/metrics | grep litmus_<\/p>\n<p>\u9884\u671f\u80fd\u770b\u5230\u7c7b\u4f3c litmus_api_requests_total\u3001litmus_experiment_runs_total\u3001litmus_experiment_status \u7b49\u6307\u6807\u53ca\u5b8c\u6574\u6807\u7b7e\u5e8f\u5217\u3002<\/p>\n<h4>6.2 \u521b\u5efa Metrics Service<\/h4>\n<p>\u4e3a\u4e86\u8ba9 Prometheus&#xff08;\u6216 ServiceMonitor&#xff09;\u80fd\u591f\u7a33\u5b9a\u6293\u53d6\u6307\u6807&#xff0c;\u5efa\u8bae\u4e3a\u6307\u6807\u7aef\u53e3\u5355\u72ec\u521b\u5efa\u4e00\u4e2a ClusterIP Service&#xff08;\u53c2\u8003 getting-started.md&#xff09;&#xff1a;<\/p>\n<p>apiVersion: v1<br \/>\nkind: Service<br \/>\nmetadata:<br \/>\n  name: litmus-server-metrics<br \/>\n  namespace: litmus<br \/>\n  labels:<br \/>\n    app: litmus-server-metrics<br \/>\nspec:<br \/>\n  selector:<br \/>\n    component: litmusportal-server<br \/>\n  ports:<br \/>\n    &#8211; name: metrics<br \/>\n      port: 8889<br \/>\n      targetPort: 8889<br \/>\n  type: ClusterIP<\/p>\n<p>\u5e94\u7528&#xff1a;<\/p>\n<p>kubectl apply -f litmus-server-metrics-service.yaml<\/p>\n<h4>6.3 \u521b\u5efa ServiceMonitor&#xff08;Prometheus Operator \u573a\u666f&#xff09;<\/h4>\n<p>\u82e5\u4f7f\u7528 Prometheus Operator \/ kube-prometheus-stack&#xff0c;\u53ef\u521b\u5efa\u5982\u4e0b ServiceMonitor \u8ba9 Prometheus \u81ea\u52a8\u53d1\u73b0\u5e76\u6bcf 30 \u79d2\u6293\u53d6\u4e00\u6b21&#xff1a;<\/p>\n<p>apiVersion: monitoring.coreos.com\/v1<br \/>\nkind: ServiceMonitor<br \/>\nmetadata:<br \/>\n  name: litmus-server-metrics<br \/>\n  namespace: litmus<br \/>\n  labels:<br \/>\n    release: prometheus<br \/>\nspec:<br \/>\n  selector:<br \/>\n    matchLabels:<br \/>\n      app: litmus-server-metrics<br \/>\n  endpoints:<br \/>\n    &#8211; port: metrics<br \/>\n      path: \/metrics<br \/>\n      interval: 30s<\/p>\n<p>\u5e94\u7528&#xff1a;<\/p>\n<p>kubectl apply -f litmus-server-metrics-monitor.yaml<\/p>\n<p>\u6ce8\u610f&#xff1a;release: prometheus \u6807\u7b7e\u5fc5\u987b\u4e0e\u4f60\u7684 Prometheus Operator \u914d\u7f6e\u7684\u6807\u7b7e\u9009\u62e9\u5668\u4e00\u81f4&#xff1b;\u5982\u679c Helm release \u540d\u79f0\u4e0d\u540c&#xff0c;\u8bf7\u76f8\u5e94\u4fee\u6539\u8be5\u6807\u7b7e\u3002<\/p>\n<h4>6.4 \u539f\u751f Prometheus scrape \u914d\u7f6e<\/h4>\n<p>\u672a\u4f7f\u7528 Operator \u65f6&#xff0c;\u4e5f\u53ef\u4ee5\u5728 scrape_configs \u4e2d\u76f4\u63a5\u914d\u7f6e&#xff1a;<\/p>\n<p>scrape_configs:<br \/>\n  &#8211; job_name: &#039;litmus-graphql-server&#039;<br \/>\n    metrics_path: &#039;\/metrics&#039;<br \/>\n    static_configs:<br \/>\n      &#8211; targets: [&#039;litmus-server-metrics.litmus.svc.cluster.local:8889&#039;]<\/p>\n<h4>6.5 \u9a8c\u8bc1\u6293\u53d6\u662f\u5426\u6210\u529f<\/h4>\n<p>\u7aef\u53e3\u8f6c\u53d1\u5230 Prometheus UI \u5e76\u68c0\u67e5\u76ee\u6807\u72b6\u6001&#xff1a;<\/p>\n<p>kubectl port-forward -n monitoring svc\/prometheus-kube-prometheus-prometheus 9090:9090<\/p>\n<p>\u6253\u5f00 http:\/\/localhost:9090\/targets&#xff0c;\u627e\u5230 litmus-server-metrics&#xff0c;\u5176\u72b6\u6001\u5e94\u663e\u793a\u4e3a UP\u3002\u968f\u540e\u53ef\u5728 Prometheus \u67e5\u8be2\u9875\u9762\u6267\u884c&#xff1a;<\/p>\n<p>litmus_api_requests_total<\/p>\n<p>\u786e\u8ba4\u80fd\u8fd4\u56de\u5e26\u6807\u7b7e\u7684\u6307\u6807\u5e8f\u5217\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001Grafana \u4eea\u8868\u76d8\u5bfc\u5165\u4e0e\u9762\u677f\u6e05\u5355<\/h3>\n<p>\u4ed3\u5e93\u5185\u7f6e\u4e86\u4e00\u4efd\u9884\u6784\u5efa\u7684 Grafana \u4eea\u8868\u76d8&#xff1a;chaoscenter\/graphql\/server\/grafana\/litmuschaos-metrics-dashboard.json&#xff08;\u4eea\u8868\u76d8\u6807\u9898\u4e3a LitmusChaos Control Plane Observability&#xff09;&#xff0c;\u5bfc\u5165\u540e\u5373\u53ef\u5f00\u7bb1\u53ef\u89c6\u5316\u5168\u90e8\u6307\u6807\u3002<\/p>\n<h4>7.1 \u5bfc\u5165\u6b65\u9aa4<\/h4>\n<li>\u7aef\u53e3\u8f6c\u53d1 Grafana&#xff1a;<\/li>\n<p>kubectl port-forward -n monitoring deployment\/prometheus-grafana 3000:3000<\/p>\n<li>\u6d4f\u89c8\u5668\u6253\u5f00 http:\/\/localhost:3000 \u5e76\u767b\u5f55&#xff1b;<\/li>\n<li>\u4f9d\u6b21\u8fdb\u5165 Dashboards \u2192 New \u2192 Import&#xff1b;<\/li>\n<li>\u4e0a\u4f20 litmuschaos-metrics-dashboard.json&#xff1b;<\/li>\n<li>\u6570\u636e\u6e90\u9009\u62e9 Prometheus&#xff0c;\u70b9\u51fb Import \u5b8c\u6210\u5bfc\u5165\u3002<\/li>\n<h4>7.2 \u5185\u7f6e\u9762\u677f\u6e05\u5355<\/h4>\n<p>\u4ece\u4eea\u8868\u76d8 JSON \u53ef\u4ee5\u786e\u8ba4&#xff0c;\u5b83\u6309\u4e09\u7c7b\u6307\u6807\u7ec4\u7ec7\u4e86 19 \u4e2a\u9762\u677f&#xff1a;<\/p>\n<ul>\n<li>API \u7ef4\u5ea6&#xff1a;API Overview\u3001API Request Rate\u3001API Error Rate\u3001API p99 Latency\u3001Auth Failures&#xff08;5m rate&#xff09;\u3001API Request Rate by Endpoint\u3001API Response Time&#xff08;p50 \/ p95 \/ p99&#xff09;&#xff1b;<\/li>\n<li>\u5b9e\u9a8c\u7ef4\u5ea6&#xff1a;Experiment Runs\u3001Total Experiment Runs\u3001Total Experiments\u3001Experiment Run Duration&#xff08;p50&#xff09;\u3001Experiments Currently Running\u3001Experiment Run Rate by Name &amp; Infra\u3001Experiment Run Duration by Name\u3001Experiment Status Table&#xff1b;<\/li>\n<li>Agent \u7ef4\u5ea6&#xff1a;Infra Agents\u3001Total Agents\u3001Connected Agents\u3001Disconnected Agents\u3002<\/li>\n<\/ul>\n<h4>7.3 \u5e38\u7528 PromQL \u793a\u4f8b<\/h4>\n<p>\u57fa\u4e8e\u4e0a\u8ff0\u6307\u6807&#xff0c;\u53ef\u4ee5\u7ec4\u5408\u51fa\u4ee5\u4e0b\u5e38\u7528\u67e5\u8be2&#xff1a;<\/p>\n<table>\n<tr>\u5173\u6ce8\u70b9PromQL<\/tr>\n<tbody>\n<tr>\n<td>API \u8bf7\u6c42\u901f\u7387<\/td>\n<td>sum(rate(litmus_api_requests_total[5m]))<\/td>\n<\/tr>\n<tr>\n<td>5 \u5206\u949f\u9519\u8bef\u7387<\/td>\n<td>sum(rate(litmus_api_error_requests_total[5m]))<\/td>\n<\/tr>\n<tr>\n<td>\u8ba4\u8bc1\u5931\u8d25\u901f\u7387<\/td>\n<td>sum(rate(litmus_api_authentication_failures_total[5m]))<\/td>\n<\/tr>\n<tr>\n<td>\u6b63\u5728\u8fd0\u884c\u7684\u5b9e\u9a8c<\/td>\n<td>litmus_experiment_status &#061;&#061; 1<\/td>\n<\/tr>\n<tr>\n<td>\u5b9e\u9a8c\u5e73\u5747\u8fd0\u884c\u65f6\u957f<\/td>\n<td>rate(litmus_experiment_run_duration_seconds_sum[1h]) \/ rate(litmus_experiment_run_duration_seconds_count[1h])<\/td>\n<\/tr>\n<tr>\n<td>\u6bcf\u4e2a\u9879\u76ee\u7684 Agent \u5728\u7ebf\u6570<\/td>\n<td>sum by (project_id) (litmus_connected_agents)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u516b\u3001\u6d4b\u8bd5\u4e0e\u8d28\u91cf\u4fdd\u969c<\/h3>\n<p>\u8be5\u5305\u9644\u5e26\u5b8c\u6574\u7684\u5355\u5143\u6d4b\u8bd5 metrics_test.go&#xff0c;\u8986\u76d6\u4e86\u6307\u6807\u4f53\u7cfb\u7684\u6b63\u786e\u6027&#xff0c;\u53ef\u4f5c\u4e3a\u7406\u89e3\u6307\u6807\u8bed\u4e49\u7684\u6700\u4f73\u53c2\u8003&#xff1a;<\/p>\n<ul>\n<li>TestMetricsRegistration&#xff1a;\u9a8c\u8bc1 11 \u4e2a\u6307\u6807\u5411\u91cf\u5747\u53ef\u88ab Prometheus Registry \u6ce8\u518c&#xff0c;\u4e0d\u4f1a\u5f15\u53d1\u91cd\u590d\u6ce8\u518c panic&#xff1b;<\/li>\n<li>TestAPIRequestsTotal \/ TestExperimentRunsTotal&#xff1a;\u9a8c\u8bc1 Counter \u5728\u591a\u6b21 Inc() \u540e\u8ba1\u6570\u6b63\u786e&#xff0c;\u4e14\u4e0d\u540c\u6807\u7b7e\u7ec4\u5408\u4e92\u4e0d\u5e72\u6270&#xff1b;<\/li>\n<li>TestExperimentStatus \/ TestExperimentsTotal \/ TestAgentMetrics&#xff1a;\u9a8c\u8bc1 Gauge \u7684 Set\/Inc \u8bed\u4e49&#xff0c;\u5176\u4e2d Agent \u6d4b\u8bd5\u8fd8\u6821\u9a8c\u4e86 connected &#043; disconnected &#061; total \u7684\u5b88\u6052\u5173\u7cfb&#xff1b;<\/li>\n<li>TestMetricsMiddleware_SuccessRequest \/ TestMetricsMiddleware_ErrorRequest \/ TestMetricsMiddleware_UnmatchedRoute&#xff1a;\u901a\u8fc7 httptest \u6784\u9020\u771f\u5b9e Gin \u8def\u7531&#xff0c;\u9a8c\u8bc1\u4e2d\u95f4\u4ef6\u5bf9 200\u3001500\u3001404&#xff08;\u672a\u5339\u914d\u8def\u7531\u8bb0 unmatched&#xff09;\u4e09\u79cd\u573a\u666f\u7684\u6307\u6807\u5199\u5165&#xff1b;<\/li>\n<li>TestContextKeys&#xff1a;\u9501\u5b9a context \u952e\u5e38\u91cf\u7684\u53d6\u503c\u3002<\/li>\n<\/ul>\n<p>\u5982\u9700\u5728\u672c\u5730\u8fd0\u884c\u6d4b\u8bd5&#xff1a;<\/p>\n<p>cd chaoscenter\/graphql\/server &amp;&amp; go test .\/pkg\/metrics\/&#8230;<\/p>\n<hr \/>\n<h3>\u4e5d\u3001\u5c0f\u7ed3\u4e0e\u6700\u4f73\u5b9e\u8df5<\/h3>\n<p>Litmus ChaosCenter GraphQL \u670d\u52a1\u5668\u7684\u6307\u6807\u4f53\u7cfb\u4ee5 pkg\/metrics \u5305\u4e3a\u5355\u4e00\u4e8b\u5b9e\u6765\u6e90&#xff0c;\u901a\u8fc7\u72ec\u7acb\u7aef\u53e3 8889 \u66b4\u9732&#xff0c;\u5177\u6709\u4ee5\u4e0b\u7279\u70b9&#xff1a;<\/p>\n<li>\u4e09\u5c42\u89c2\u6d4b\u89c6\u89d2&#xff1a;API \u5c42&#xff08;\u8bf7\u6c42\u91cf\/\u5ef6\u8fdf\/\u9519\u8bef\/\u8ba4\u8bc1&#xff09;\u3001\u5b9e\u9a8c\u5c42&#xff08;\u603b\u91cf\/\u8fd0\u884c\u6b21\u6570\/\u65f6\u957f\/\u72b6\u6001&#xff09;\u3001Agent \u5c42&#xff08;\u8fde\u63a5\u6570\/\u65ad\u5f00\u6570\/\u603b\u6570&#xff09;&#xff0c;\u8986\u76d6\u63a7\u5236\u5e73\u9762\u5065\u5eb7\u5ea6\u3001\u6df7\u6c8c\u5b9e\u9a8c\u6267\u884c\u6548\u679c\u4e0e\u57fa\u7840\u8bbe\u65bd\u5728\u7ebf\u7387&#xff1b;<\/li>\n<li>\u6807\u51c6 Prometheus \u5f62\u6001&#xff1a;Counter \/ Gauge \/ Histogram \u4e09\u7c7b\u6307\u6807\u5168\u90e8\u4f7f\u7528 client_golang \u5b9a\u4e49\u5e76\u5728 init() \u4e2d\u6ce8\u518c&#xff08;\u89c1 metrics.go&#xff09;&#xff0c;\u53ef\u76f4\u63a5\u88ab\u4efb\u610f Prometheus \u517c\u5bb9\u7cfb\u7edf\u6293\u53d6&#xff1b;<\/li>\n<li>\u5f00\u7bb1\u5373\u7528&#xff1a;\u4ed3\u5e93\u81ea\u5e26 Grafana \u4eea\u8868\u76d8 \u4e0e \u5b8c\u6574\u4e0a\u624b\u6307\u5f15&#xff0c;\u4ece\u96f6\u642d\u5efa\u76d1\u63a7\u7684\u6210\u672c\u5f88\u4f4e\u3002<\/li>\n<p>\u5efa\u8bae\u5b9e\u8df5\u8def\u5f84&#xff1a;\u5148\u6309\u7b2c\u516d\u7ae0\u5b8c\u6210\u7aef\u70b9\u9a8c\u8bc1\u4e0e\u91c7\u96c6\u914d\u7f6e&#xff0c;\u786e\u8ba4 Prometheus target \u4e3a UP&#xff1b;\u518d\u5bfc\u5165\u7b2c\u4e03\u7ae0\u7684 Grafana \u4eea\u8868\u76d8\u5efa\u7acb\u53ef\u89c6\u5316\u57fa\u7ebf&#xff1b;\u968f\u540e\u9488\u5bf9 litmus_api_error_requests_total\u3001litmus_api_authentication_failures_total\u3001litmus_disconnected_agents \u4e0e litmus_experiment_status &#061;&#061; 1&#xff08;\u957f\u65f6\u95f4\u65e0\u53d8\u5316&#xff09;\u914d\u7f6e\u544a\u8b66\u89c4\u5219&#xff0c;\u5373\u53ef\u5f62\u6210\u4e00\u5957\u5b8c\u6574\u7684 ChaosCenter \u63a7\u5236\u5e73\u9762\u53ef\u89c2\u6d4b\u95ed\u73af\u3002<\/p>\n<p>  <img loading=\"lazy\" decoding=\"async\" class=\"gcb-icon-like\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012025704-6acc4c803a231.svg\" alt=\"\" width=\"16\" height=\"16\" \/> <span class=\"gcb-like-text\">\u8d5e<\/span>  <\/p>\n<p>   <span class=\"gcb-share-text\">\u5206\u4eab<\/span>  <\/p>\n<ul class=\"gcb-tag-list\">\n<li><span class=\"gcb-tag\">\u4e91\u539f\u751f<\/span><\/li>\n<li><span class=\"gcb-tag\">\u8fd0\u7ef4<\/span><\/li>\n<li><span class=\"gcb-tag\">\u53ef\u89c2\u6d4b\u6027<\/span><\/li>\n<\/ul>\n<h3 class=\"gcb-project-title\">\u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011litmus<\/h3>\n<p class=\"gcb-project-desc\">Litmus helps SREs and developers practice chaos engineering in a Cloud-native way. Chaos experiments are published at the ChaosHub (https:\/\/hub.litmuschaos.io). Community notes is at https:\/\/hackmd.io\/a4Zu_sH4TZGeih-xCimi3Q<\/p>\n<p>    <span class=\"gcb-project-addr-label\">\u9879\u76ee\u5730\u5740&#xff1a;<\/span><br \/>\n    <span class=\"gcb-project-addr-link\">https:\/\/gitcode.com\/gh_mirrors\/li\/litmus<\/span> <\/p>\n<p>  <span class=\"gcb-project-btn\"> <span class=\"gcb-project-btn-main\">\u70b9\u51fb\u67e5\u770b<\/span> <span class=\"gcb-project-btn-sub\">\u514d\u8d39\u4e0b\u8f7d<\/span> <\/span> <\/p>\n<h4 class=\"gcb-related-title\">\u76f8\u5173\u63a8\u8350<\/h4>\n<ul class=\"gcb-related-list\">\n<li class=\"gcb-related-item\">\n<h5 class=\"gcb-related-item-title\">\u5982\u4f55\u901a\u8fc7reSolve\u4e0eReact\/Redux\u96c6\u6210\u6784\u5efa\u73b0\u4ee3\u5316\u5168\u6808\u5e94\u7528<\/h5>\n<p class=\"gcb-related-item-desc\">\u5982\u4f55\u901a\u8fc7reSolve\u4e0eReact\/Redux\u96c6\u6210\u6784\u5efa\u73b0\u4ee3\u5316\u5168\u6808\u5e94\u7528 reSolve\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u5168\u6808JavaScript\u6846\u67b6&#xff0c;\u4e13\u4e3a\u6784\u5efa\u73b0\u4ee3\u5316\u3001\u53ef\u6269\u5c55\u7684\u5e94\u7528\u7a0b<\/p>\n<\/li>\n<li class=\"gcb-related-item\">\n<h5 class=\"gcb-related-item-title\">opus-mt-de-en\u914d\u7f6e\u6307\u5357&#xff1a;tokenizer_config.json\u4e0egeneration_config.json\u8be6\u89e3<\/h5>\n<p class=\"gcb-related-item-desc\">opus mt de en\u914d\u7f6e\u6307\u5357&#xff1a;tokenizer_config.json\u4e0egeneration_config.json\u8be6\u89e3 \u60f3\u8981\u5feb\u901f\u638c\u63e1opus mt d<\/p>\n<\/li>\n<li class=\"gcb-related-item\">\n<h5 class=\"gcb-related-item-title\"> \u76d1\u63a7gorush\u670d\u52a1&#xff1a;Prometheus\u6307\u6807\u4e0eGrafana\u53ef\u89c6\u5316\u65b9\u6848<\/h5>\n<p class=\"gcb-related-item-desc\">\u76d1\u63a7gorush\u670d\u52a1&#xff1a;Prometheus\u6307\u6807\u4e0eGrafana\u53ef\u89c6\u5316\u65b9\u6848 \u4f60\u662f\u5426\u66fe\u56e0\u63a8\u9001\u670d\u52a1\u5f02\u5e38\u5bfc\u81f4\u7528\u6237\u6295\u8bc9&#xff1f;\u662f\u5426\u60f3\u5b9e\u65f6\u638c\u63e1\u63a8\u9001\u6210\u529f\u7387\u3001\u4efb\u52a1\u961f\u5217\u72b6\u6001&#xff1f;\u672c\u6587\u5c06\u5e26\u4f60<\/p>\n<p>     <span class=\"gcb-tag\">\u540e\u7aef<\/span>\n      <\/li>\n<\/ul>\n<p>  <span class=\"gcb-prev-next-label\">\u4e0a\u4e00\u7bc7&#xff1a;<\/span><br \/>\n  ATProto Feed Generator API \u5b8c\u5168\u53c2\u8003&#xff1a;\u65b9\u6cd5\u3001\u53c2\u6570\u4e0e\u54cd\u5e94\u8be6\u89e3 <\/p>\n<p>  <span class=\"gcb-prev-next-label\">\u4e0b\u4e00\u7bc7&#xff1a;<\/span><br \/>\n   EasySwoole \u8def\u7531\u7cfb\u7edf\u8be6\u89e3&#xff1a;\u9ad8\u6027\u80fd RESTful API \u8bbe\u8ba1\u7ec8\u6781\u6307\u5357 <\/p>\n<p>\u521b\u4f5c\u58f0\u660e\uff1a\u672c\u6587\u90e8\u5206\u5185\u5bb9\u7531AI\u8f85\u52a9\u751f\u6210\uff08AIGC\uff09\uff0c\u4ec5\u4f9b\u53c2\u8003<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e91\u539f\u751f\u8fd0\u7ef4\u53ef\u89c2\u6d4b\u6027 \u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011litmus Litmus helps SREs and developers practice chaos engineering in a Cloud-native way. Chaos experiments are published at the ChaosHub (https:\/\/hub.litmuschaos.io). Community notes is at https:\/\/hackmd.io\/a4Zu_sH4TZGeih<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-115515","post","type-post","status-publish","format-standard","hentry","category-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/115515.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e91\u539f\u751f\u8fd0\u7ef4\u53ef\u89c2\u6d4b\u6027 \u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011litmus Litmus helps SREs and developers practice chaos engineering in a Cloud-native way. Chaos experiments are published at the ChaosHub (https:\/\/hub.litmuschaos.io). Community notes is at https:\/\/hackmd.io\/a4Zu_sH4TZGeih\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115515.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-12T02:57:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012025704-6acc4c803a231.svg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115515.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115515.html\",\"name\":\"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-12T02:57:05+00:00\",\"dateModified\":\"2026-10-12T02:57:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115515.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115515.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115515.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/115515.html","og_locale":"zh_CN","og_type":"article","og_title":"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e91\u539f\u751f\u8fd0\u7ef4\u53ef\u89c2\u6d4b\u6027 \u3010\u514d\u8d39\u4e0b\u8f7d\u94fe\u63a5\u3011litmus Litmus helps SREs and developers practice chaos engineering in a Cloud-native way. Chaos experiments are published at the ChaosHub (https:\/\/hub.litmuschaos.io). Community notes is at https:\/\/hackmd.io\/a4Zu_sH4TZGeih","og_url":"https:\/\/www.wsisp.com\/helps\/115515.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-12T02:57:05+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261012025704-6acc4c803a231.svg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115515.html","url":"https:\/\/www.wsisp.com\/helps\/115515.html","name":"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-12T02:57:05+00:00","dateModified":"2026-10-12T02:57:05+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115515.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115515.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115515.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Litmus ChaosCenter GraphQL \u670d\u52a1\u5668 Prometheus \u6307\u6807\u5168\u89e3\u6790\u4e0e Grafana \u53ef\u89c6\u5316\u5b9e\u6218"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=115515"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115515\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115515"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}