一、application.yml
spring.cloud.sentinel
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: xxx.xxx.xxx.xxx:8848
sentinel:
eager: true
transport:
# 控制台地址
dashboard: localhost:9999
# nacos配置持久化
datasource:
ds2:
nacos:
server-addr: xxx.xxx.xxx.xxx:8848
dataId: circuit-breaker2
groupId: DEFAULT_GROUP
data-type: json
rule-type: degrade
二、nacos中配置circuit-breaker2
[{
“resource”: “test2”,
“count”: 2,
“timeWindow”: 60,
“grade”: 2,
“minRequestAmount”: 2,
“slowRatioThreshold”: 0.2,
“statIntervalMs”: 2000
}]
上述配置可以到localhost:9999这个控制台去查看。
####################################
热点参数配置:rule-tpye为param-flow
nacos配置:
[
{
"burstCount": 0,
"clusterMode": false,
"controlBehavior": 0,
"count": 2,
"durationInSec": 1,
"grade": 1,
"limitApp": "default",
"maxQueueingTimeMs": 0,
"paramFlowItemList": [],
"paramIdx": 0,
"resource": "test3"
}
]
####################################
系统规则配置配置:rule-tpye为system
nacos配置:
[{
"highestSystemLoad": -1,
"avgRt": -1,
"maxThread": -1,
"qps": -1,
"highestCpuUsage": 0.03
}]
这种配置,cpu利用率超3%,则提示超流量
参考:
https://sentinelguard.io/zh-cn/docs/basic-api-resource-rule.html