Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

配置网关限流时,Sentinel管理台的流控规则不显示网关流控页面

Open wangs0627 opened this issue 3 years ago • 5 comments

Issue Description

Type: Bug

Describe what happened (or what feature you want)

不配置csp.sentinel.app.type=1这个参数,则sentinal-dashboard中的gateway流控规则不能显示网关流控规则页面。

Describe what you expected to happen

正常应该在不配置csp.sentinel.app.type的情况下是可以展示网关流控页面的

How to reproduce it (as minimally and precisely as possible)

  1. 使用sentinel-1.8.2版本
  2. gateway服务中依赖了spring-cloud-alibaba-sentinel-gateway、spring-cloud-starter-alibaba-sentinel、sentinel-datasource-nacos,做了sentinel规则持久化到nacos,用的示例代码
  3. 在启动时不使用-Dcsp.sentinel.app.type=1

Tell us your environment

JDK:1.8 OS:Windows10 IDEA:2020.3

Anything else we need to know?

HeartbeatMessage类是通过SPI实例化SimpleHttpHeartbeatSender时实例化的,里边通过SentinelConfig.getAppType()得到app_type,最终是通过System.getProperty()去拿值,如果为空,则取默认值0,之后才会在Spring容器初始化时调用SentinelSCGAutoConfiguration的 initAppType()方法,设置System.setProperty("csp.sentinel.app.type", "11");但是此时HeartbeatMessage的app_type已经不可修改,发送心跳参数heartBeat.generateCurrentMessage()里边也没有对HeartbeatMessage类的app_type属性重新赋值,也就是说app_type会一直为0,导致dashboard没有网关流控页面。 问题原因:SentinelSCGAutoConfiguration中对csp.sentinel.app.type的赋值没有真正被用到。

wangs0627 avatar Jun 29 '21 15:06 wangs0627

各位大佬给看看,是不是哪块还没有配置导致的?

wangs0627 avatar Jun 29 '21 15:06 wangs0627

同样的问题,版本1.8.0。 我的解决方法:网关启动设置csp.sentinel.app.type,如果之前启动过网关,应用类型被控制台缓存了,需要更换下application name,或者重启控制台。

Jisfeng avatar Jul 02 '21 01:07 Jisfeng

同样的问题,版本1.8.0。 我的解决方法:网关启动设置csp.sentinel.app.type,如果之前启动过网关,应用类型被控制台缓存了,需要更换下application name,或者重启控制台。

我的解决方案也是在主函数里加csp.sentinel.app.type,还有你说的控制台缓存那个也好坑,只能重启控制台,在addMechine的时候,Map是用的computeIfAbsent把app信息put进去的,只要第一次错了,就只能重启控制台

wangs0627 avatar Jul 03 '21 09:07 wangs0627

发现了一个尴尬的问题: 控制台要显示网关流控页面,必须要先访问下网关路径,否则不显示。即:先有流量后控制。

zuozonglin avatar Mar 17 '22 01:03 zuozonglin

我这儿是改造控制台的时候出现的

HanYi001 avatar Sep 21 '22 02:09 HanYi001