一、下载sentinel 控制台jar包
https://github.com/alibaba/sentinel/releases
注:生产环境中,sentinel 控制台保本尽量保持和应用的sentinel版本一致

二、启动sentinel 控制台
java -jar sentinel-dashboard-1.6.2
localhost:8080 打开sentinel控制台
三、为内容中心整合控制台
添加jar包
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>0.9.0.RELEASE</version>
</dependency>
添加配置
sentinel:
transport:
#指定sentinel控制台的地址
dashboard: localhost:8080
启动content-center、user-center服务
由于sentinel是懒加载,需要先访问资源才会对资源进行监控

访问资源http://localhost:8010/shares/1

四、怎么确定应用整合了sentinel呢?
应用整合了sentinel之后会暴露出来一个/actuator/sentinel的端点
所以需要为应用整合actuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
actuator暴露/sentinel/actuator端点默认是隐藏的,需要添加配置
management:
endpoints:
web:
exposure:
include: '*'

网友评论