alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.34k stars 8.01k forks source link

Header GatewayFlowRule rule-type=flow does not take effect | SCA GatewayFlowRule配置header参数限流不生效 #2354

Open fattyhan opened 3 years ago

fattyhan commented 3 years ago

Issue Description

网关规则参数: { "burst": 0, "controlBehavior": 2, "count": 1.0, "grade": 1, "intervalSec": 1, "maxQueueingTimeoutMs": 600, "paramItem": { "fieldName": "clientId", "matchStrategy": 0, "parseStrategy": 2, "pattern": "test" }, "resource": "/list", "resourceMode": 0 }

sentinel配置 spring: jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 cloud: sentinel: enabled: true filter: enabled: true transport: port: 8719 dashboard: localhost:8080 datasource: ds: nacos:

nacos连接地址

        server-addr: localhost:8848
        ## nacos连接的分组
        group-id: DEFAULT_GROUP
        ###路由存储规则
        rule-type: flow
        ### 读取配置文件的 data-id
        data-id: member-sentinal
        ###  读取培训文件类型为json
        data-type: json

Describe what happened (or what feature you want)

1、请求网关接口/list,分别带header参数clientId和不带都不触发限流规则 2、尝试将resource配置为routeId,依然不起作用 3、官方单元测试以及wiki对该部分描述未详尽,demo起不到引导作用

Describe what you expected to happen

1、期望能按照规则执行限流

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

  1. nacos 2.0.2
  2. sentinel 1.8.2

Tell us your environment

local

Anything else we need to know?

sczyh30 commented 3 years ago

Refer https://github.com/alibaba/spring-cloud-alibaba/wiki/Sentinel

注意:网关流控规则数据源类型是 gw-flow,若将网关流控规则数据源指定为 flow 则不生效。