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

ztyzrc3y  于 23天前  发布在  其他
关注(0)|答案(4)|浏览(17)

目前是有加@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

spring:
  cloud:
    nacos:
      discovery:
        server-addr: http://192.168.1.121:8848 #Nacos地址
        weight: 1
        enabled: true
        register-enabled: false
      config:
        server-addr: http://192.168.1.121:8848 #Nacos地址
        file-extension: yaml #这里我们获取的yaml格式的配置
        enabled: false
        refresh-enabled: false
    sentinel:
      transport:
        dashboard: 192.168.1.121:8858
        port: 8719
        heartbeat-interval-ms: 5000
        namespace: mall
      filter:
        enabled: true
        url-patterns: /**
      eager:
        enabled: true
      datasource:
        ds1:
          nacos:
            server-addr: 192.168.1.121:8848
            dataId: mall-sentinel
            groupId: DEFAULT_GROUP
            data-type: json
            rule-type: flow
y0u0uwnf

y0u0uwnf1#

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

olhwl3o2

olhwl3o22#

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

at0kjp5o

at0kjp5o3#

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

t2a7ltrp

t2a7ltrp4#

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

相关问题