当添加流控规则后,控制台无法监控应用
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- java, spring-boot
- 領域
- backend, observability
調査の方向性
trace に記載されているダッシュボードのエントリポイント、特に SentinelApiClient と MetricFetcher から始め、提供されている Java 11、Spring Boot 2.7 の設定とルール初期化を使用して問題を再現します。クライアントに設定されている監視エンドポイントと、ログに示されているダッシュボードのリクエストを比較します。ダッシュボードでメトリクスとリソースツリーを取得でき、Flow ルールが有効なままであれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug 描述
在使用sentinel的组件时,碰到了控制台无法监控应用。
环境
环境:"java11,spring boot2.7"
sentinel的依赖是:
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>2021.0.5.0</version>
</dependency>
配置文件为:
spring:
cloud:
sentinel:
transport:
dashboard: 127.0.0.1:8858
port: 8719 # Sentinel客户端暴露的监控端口,默认为8719
client-ip: 127.0.0.1
enabled: true
sentinel控制台与项目运行在本地电脑上。
问题详细:
在项目中编写了sentinel的流控规则后,控制台就无法监控应用,但是流控规则是生效的,就是控制台监控不了应用了,但是把流控规则去掉后就能监控应用了
在代码中设置sentinel的流控与熔断规则:
@Component
public class SentinelRulesManager {
@PostConstruct
public void initRules() {
initFlowRules(); // 当我注释这个流控规则后,控制台就能监控应用了
initDegradeRules();
}
// 限流规则
public void initFlowRules() {
FlowRule flowRule = new FlowRule();
flowRule.setResource("listQuestionVOByPage");
flowRule.setCount(2);
flowRule.setGrade(RuleConstant.FLOW_GRADE_QPS);
flowRule.setLimitApp("default");
flowRule.setStrategy(RuleConstant.STRATEGY_DIRECT);
FlowRuleManager.loadRules(Collections.singletonList(flowRule));
}
// 降级规则
public void initDegradeRules() {
// 单 IP 查看题目列表熔断规则
DegradeRule slowCallRule = new DegradeRule("listQuestionVOByPage")
.setGrade(CircuitBreakerStrategy.SLOW_REQUEST_RATIO.getType())
.setCount(0.2) // 慢调用比例大于 20%
.setTimeWindow(10) // 熔断持续时间 60 秒
.setStatIntervalMs(30 * 1000) // 统计时长 30 秒
.setMinRequestAmount(5) // 最小请求数
.setSlowRatioThreshold(3); // 响应时间超过 3 秒
DegradeRule errorRateRule = new DegradeRule("listQuestionVOByPage")
.setGrade(CircuitBreakerStrategy.ERROR_RATIO.getType())
.setCount(0.1) // 异常率大于 10%
.setTimeWindow(10) // 熔断持续时间 60 秒
.setStatIntervalMs(30 * 1000) // 统计时长 30 秒
.setMinRequestAmount(5); // 最小请求数
// 加载规则
DegradeRuleManager.loadRules(Arrays.asList(slowCallRule, errorRateRule));
}
}
错误信息:
然后控制台就报错如下:
2025-04-18 12:43:20.872 ERROR 51776 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher : Failed to fetch metric from <http://127.0.0.1:8720/metric?startTime=1744951392000&endTime=1744951398000&refetch=false> (ConnectionException: Connection refused: no further information)
2025-04-18 12:43:27.867 ERROR 51776 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher : Failed to fetch metric from <http://127.0.0.1:8720/metric?startTime=1744951399000&endTime=1744951405000&refetch=false> (ConnectionException: Connection refused: no further information)
2025-04-18 12:43:34.873 ERROR 51776 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher : Failed to fetch metric from <http://127.0.0.1:8720/metric?startTime=1744951406000&endTime=1744951412000&refetch=false> (ConnectionException: Connection refused: no further information)
2025-04-18 12:43:37.613 ERROR 51776 --- [pool-1-thread-1] c.a.c.s.d.client.SentinelApiClient : HTTP request failed: http://127.0.0.1:8720/jsonTree?type=root
java.net.ConnectException: Connection refused: no further information
at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na]
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[na:na]
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946) ~[na:na]
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171) ~[httpcore-nio-4.4.6.jar!/:4.4.6]
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145) ~[httpcore-nio-4.4.6.jar!/:4.4.6]
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348) ~[httpcore-nio-4.4.6.jar!/:4.4.6]
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:194) ~[httpasyncclient-4.1.3.jar!/:4.1.3]
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) ~[httpasyncclient-4.1.3.jar!/:4.1.3]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
2025-04-18 12:43:37.613 ERROR 51776 --- [nio-8858-exec-8] c.a.c.s.d.client.SentinelApiClient : Error when fetching items from api: jsonTree -> root
java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused: no further information
at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073) ~[na:na]
at com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient.fetchItems(SentinelApiClient.java:383) ~[classes!/:na]
at com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient.fetchResourceOfMachine(SentinelApiClient.java:450) ~[classes!/:na]
at com.alibaba.csp.sentinel.dashboard.controller.ResourceController.fetchResourceChainListOfMachine(ResourceController.java:70) ~[classes!/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
- 主要言語
- Java
- スター
- 23.1k
- フォーク
- 8.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
alibaba/Sentinel のほかの issue
-
[BUG] sentinel-spring-webflux-adapter 在 Spring WebFlux 6.2.x 下触发限流时抛出 NoSuchMethodError対応中かも @amalsaidov が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
[BUG] sentinel-dashboard: upgrade Spring Boot 2.5.12 -> 2.5.15 for known CVEs対応中かも @vendrov が 29 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
[DOC] Correct method-name typo in WebMVC interceptor example対応中かも @vietdungnguyen2005 が 18 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
README: broken Keruyun (客如云) logo image link in "Who is using" section (404)対応中かも @525600Cloud2 が 86 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
fix: replace printStackTrace with RecordLog in ConfigUtil再び着手できるかも @yichao0824 が 118 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
alibaba/Sentinel の issue をすべて見る
似ている issue
-
Add contributing guide対応中かも @WadekarPrashant が今日担当しました。 オープンgood first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
jenkinsci/gitea-checks-plugin#382 · コメント 1 件 ·
-
enhancement infra
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
5.0.x backport bug
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
spring-cloud/spring-cloud-function#1569 ·
メンテナーはふだん 1 日以内に返信
-
Move the spring-cloud-commons version and BOM import from the bus parent to the stream parent対応中かも @olegz が今日担当しました。 オープンtask
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
spring-cloud/spring-cloud-stream#3355 ·
メンテナーはふだん 1 日以内に返信
-
bug untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
opensearch-project/opensearch-java#2342 ·
メンテナーはふだん 1 日以内に返信