sentinel如何默认对所有接口都进行监控,而不需要单独每个controller下的方法写@SentinelResource?

ztyzrc3y  于 7个月前  发布在  其他
关注(0)|答案(4)|浏览(259)

目前是有加@SentinelResource的方法能在sentinel控制台看到,但是没有加的,都不显示,如何能让这些接口只要有被请求就全部显示在控制台呢?我的配置如下

Currently, there are methods for adding @ SentinelResource that can be seen on the Sentinel console, but those that are not added will not be displayed. How can we make these interfaces all appear on the console as long as they are requested? My configuration is as follows

  1. spring:
  2. cloud:
  3. nacos:
  4. discovery:
  5. server-addr: http://192.168.1.121:8848 #Nacos地址
  6. weight: 1
  7. enabled: true
  8. register-enabled: false
  9. config:
  10. server-addr: http://192.168.1.121:8848 #Nacos地址
  11. file-extension: yaml #这里我们获取的yaml格式的配置
  12. enabled: false
  13. refresh-enabled: false
  14. sentinel:
  15. transport:
  16. dashboard: 192.168.1.121:8858
  17. port: 8719
  18. heartbeat-interval-ms: 5000
  19. namespace: mall
  20. filter:
  21. enabled: true
  22. url-patterns: /**
  23. eager:
  24. enabled: true
  25. datasource:
  26. ds1:
  27. nacos:
  28. server-addr: 192.168.1.121:8848
  29. dataId: mall-sentinel
  30. groupId: DEFAULT_GROUP
  31. data-type: json
  32. rule-type: flow
y0u0uwnf

y0u0uwnf1#

同问,按个设置太蛋疼了,能否对一类URL做统一限制 :例如 /v1/api/* 做流控或者熔断

olhwl3o2

olhwl3o22#

Sentinel本来就是要你自己定义资源他才能识别处理吧。如果说服务的所有资源使用统一的处理的话,我记得应该可以通过代码来做,创建自定义的处理器实现 BlockExceptionHandler 接口,就可以对所有资源做统一处理。貌似是这个。
至于对一类URL做限制好像在控制台可以配置,貌似是有一个高级配置之类的东西,好像叫什么直连,关联,之类的

at0kjp5o

at0kjp5o3#

我这里更扯淡,我是在虚拟机上面配置的Sentinel控制台,前几天都配好了,服务也可以注册到控制台了,今天再一看就不行了,也不知道是啥毛病,难受的要死

t2a7ltrp

t2a7ltrp4#

引入相关的springmvc、spring-cloud adapter就可以啊,本质就是在interceptor或者filter里全局拦截处理

相关问题