1 版本说明

2 官方文档

3 开发指南

3.1 Nacos 服务注册与发现

3.1.1 Nacos 单机部署

使用 Docker 单机模式启动 Nacos(注意:容器下部署需要暴露 3 个端口)。

  1. docker run -d \
  2. -e PREFER_HOST_MODE=hostname \
  3. -e MODE=standalone \
  4. -e NACOS_APPLICATION_PORT=8848 \
  5. -e NACOS_SERVERS="192.168.50.163:8848" \
  6. -e SPRING_DATASOURCE_PLATFORM=mysql \
  7. -e MYSQL_SERVICE_HOST=192.168.50.163 \
  8. -e MYSQL_SERVICE_PORT=3306 \
  9. -e MYSQL_SERVICE_USER=root \
  10. -e MYSQL_SERVICE_PASSWORD=demo \
  11. -e MYSQL_SERVICE_DB_NAME=nacos \
  12. -e NACOS_SERVER_IP=192.168.50.163 \
  13. -p 8848:8848 \
  14. -p 9848:9848 \
  15. -p 9849:9849 \
  16. --name nacos-node1 \
  17. nacos/nacos-server

请注意,Nacos 2.0 版本相比 1.X 新增了 gRPC 的通信方式,在设置的主端口 8848 基础上偏移 1000 生成 9848 端口和偏移 1001 生成 9849 端口,因此,在部署 Docker 时需要设置相关端口,允许对外访问。
启动完成后,访问 http://192.168.50.163:8848/nacos,初始用户密码为 nacos/nacos
image.png

3.1.2 Nacos 集群部署

以 Docker 伪集群搭建为例,分别启动 nacos-node1nacos-node2nacos-node3 节点。

  1. docker run -d \
  2. -e PREFER_HOST_MODE=hostname \
  3. -e MODE=cluster \
  4. -e NACOS_APPLICATION_PORT=8850 \
  5. -e NACOS_SERVERS="192.168.50.163:8850 192.168.50.163:8852 192.168.50.163:8854" \
  6. -e SPRING_DATASOURCE_PLATFORM=mysql \
  7. -e MYSQL_SERVICE_HOST=192.168.50.163 \
  8. -e MYSQL_SERVICE_PORT=3306 \
  9. -e MYSQL_SERVICE_USER=root \
  10. -e MYSQL_SERVICE_PASSWORD=数据库密码 \
  11. -e MYSQL_SERVICE_DB_NAME=nacos \
  12. -e NACOS_SERVER_IP=192.168.50.163 \
  13. -e JVM_XMS=256m \
  14. -e JVM_XMX=256m \
  15. -p 8850:8850 \
  16. -p 9850:9850 \
  17. -p 9851:9851 \
  18. --name nacos-node1 \
  19. nacos/nacos-server

启动 nacos-node2 节点。

  1. docker run -d \
  2. -e PREFER_HOST_MODE=hostname \
  3. -e MODE=cluster \
  4. -e NACOS_APPLICATION_PORT=8852 \
  5. -e NACOS_SERVERS="192.168.50.163:8850 192.168.50.163:8852 192.168.50.163:8854" \
  6. -e SPRING_DATASOURCE_PLATFORM=mysql \
  7. -e MYSQL_SERVICE_HOST=192.168.50.163 \
  8. -e MYSQL_SERVICE_PORT=3306 \
  9. -e MYSQL_SERVICE_USER=root \
  10. -e MYSQL_SERVICE_PASSWORD=数据库密码 \
  11. -e MYSQL_SERVICE_DB_NAME=nacos \
  12. -e NACOS_SERVER_IP=192.168.50.163 \
  13. -e JVM_XMS=256m \
  14. -e JVM_XMX=256m \
  15. -p 8852:8852 \
  16. -p 9852:9852 \
  17. -p 9853:9853 \
  18. --name nacos-node2 \
  19. nacos/nacos-server

启动 nacos-node3 节点。

  1. docker run -d \
  2. -e PREFER_HOST_MODE=hostname \
  3. -e MODE=cluster \
  4. -e NACOS_APPLICATION_PORT=8854 \
  5. -e NACOS_SERVERS="192.168.50.163:8850 192.168.50.163:8852 192.168.50.163:8854" \
  6. -e SPRING_DATASOURCE_PLATFORM=mysql \
  7. -e MYSQL_SERVICE_HOST=192.168.50.163 \
  8. -e MYSQL_SERVICE_PORT=3306 \
  9. -e MYSQL_SERVICE_USER=root \
  10. -e MYSQL_SERVICE_PASSWORD=数据库密码 \
  11. -e MYSQL_SERVICE_DB_NAME=nacos \
  12. -e NACOS_SERVER_IP=192.168.50.163 \
  13. -e JVM_XMS=256m \
  14. -e JVM_XMX=256m \
  15. -p 8854:8854 \
  16. -p 9854:9854 \
  17. -p 9855:9855 \
  18. --name nacos-node3 \
  19. nacos/nacos-server

Nacos 的集群依赖 Nginx 的反向代理。由于 Nacos 2.0 版本新增了 gRPC 端口,需要 Nginx 开启 stream 模块实现 TCP 协议的转发。Nginx 默认安装时并没有加载 stream 模块,因此我们需要在 ./configure 编译时新增 --with-stream 选项。

  1. # 需要开启 Nginx 的 stream 模块,执行 ./configure 编译时新增 --with-stream 选项
  2. ./configure --prefix=/opt/nginx --sbin-path=/opt/nginx/sbin/nginx --conf-path=/opt/nginx/conf/nginx.conf --with-http_stub_status_module --with-http_gzip_static_module --with-stream

关于启动 nginx 容器如何开启 stream 模块这块还在研究中。

  1. docker run --name nginx -v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro -p 8080:8080 -d nginx

修改 /opt/nginx/conf/nginx.conf 的内容,配置 Nacos 服务的代理。

  1. http {
  2. # ..
  3. upstream nacos-cluster {
  4. server 192.168.50.163:8850;
  5. server 192.168.50.163:8852;
  6. server 192.168.50.163:8854;
  7. }
  8. server {
  9. listen 8848;
  10. server_name _;
  11. location / {
  12. proxy_pass http://nacos-cluster;
  13. proxy_set_header Host $host;
  14. proxy_set_header X-Real-IP $remote_addr;
  15. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  16. proxy_set_header REMOTE-HOST $remote_addr;
  17. add_header X-Cache $upstream_cache_status;
  18. add_header Cache-Control no-cache;
  19. }
  20. }
  21. }
  22. stream {
  23. upstream nacos-grpc-9848 {
  24. server 192.168.50.163:9850;
  25. server 192.168.50.163:9852;
  26. server 192.168.50.163:9854;
  27. }
  28. server {
  29. listen 9848;
  30. proxy_connect_timeout 300s;
  31. proxy_timeout 300s;
  32. proxy_pass nacos-grpc-9848;
  33. }
  34. upstream nacos-grpc-9849 {
  35. server 192.168.50.163:9851;
  36. server 192.168.50.163:8853;
  37. server 192.168.50.163:8855;
  38. }
  39. server {
  40. listen 9849;
  41. proxy_connect_timeout 300s;
  42. proxy_timeout 300s;
  43. proxy_pass nacos-grpc-9849;
  44. }
  45. }

访问 Nginx 代理后的地址 http://192.168.50.163:8848/nacos
image.png

3.1.3 服务提供者注册到 Nacos

Nacos Discovery 使用文档:https://github.com/alibaba/spring-cloud-alibaba/wiki/Nacos-discovery

pom.xml 文件中添加相关依赖。

  1. <dependency>
  2. <groupid>com.alibaba.cloud</groupid>
  3. <artifactid>spring-cloud-starter-alibaba-nacos-discovery</artifactid>
  4. </dependency>

bootstrap.yaml 文件中新增相关配置。

  1. spring:
  2. application:
  3. name: demo
  4. cloud:
  5. nacos:
  6. discovery:
  7. server-addr: 192.168.50.163:8848
  8. namespace: demo # 环境隔离,默认使用 public 命名空间
  9. group: DEFAULT_GROUP # 组件隔离,默认使用 DEFAULT_GROUP 组名
  10. username: 开源版 nacos 账号
  11. password: 开源版 nacos 密码
  12. # access-key: 阿里云账号名称
  13. # secret-key: 阿里云账号密码
  14. management:
  15. endpoints:
  16. web:
  17. exposure:
  18. include: '*'

Spring Boot 启动类新增 @EnableDiscoveryClient 注解。

  1. @EnableDiscoveryClient
  2. @SpringBootApplication
  3. public class Application {
  4. public static void main(String[] args) {
  5. SpringApplication.run(Application.class, args);
  6. }
  7. }

3.1.4 服务消费者注册到 Nacos

方式和 3.1.3 小节一致。

3.1.5 异构微服务注册到 Nacos

Java 平台的项目,在 pom.xml 文件中添加相关依赖。

  1. <dependency>
  2. <groupId>com.alibaba.cloud</groupId>
  3. <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
  4. </dependency>
  5. <dependency>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-actuator</artifactId>
  8. </dependency>
  9. <dependency>
  10. <groupId>com.alibaba.cloud</groupId>
  11. <artifactId>spring-cloud-starter-alibaba-sidecar</artifactId>
  12. </dependency>
  13. <dependency>
  14. <groupId>org.springframework.boot</groupId>
  15. <artifactId>spring-boot-starter-webflux</artifactId>
  16. </dependency>

application.yaml 添加如下配置:

  1. spring:
  2. cloud:
  3. nacos:
  4. discovery:
  5. server-addr: 192.168.50.163:8848
  6. application:
  7. name: sidecar-simple
  8. server:
  9. port: 8080
  10. sidecar:
  11. ip: localhost
  12. port: 8081
  13. health-check-url: http://localhost:8081/health
  14. management:
  15. endpoint:
  16. health:
  17. show-details: always

非 Java 平台语言,需要自行实现 /health 接口,返回特定的 JSON 数据,格式如下:
返回服务在线状态的报文格式如下:

  1. {
  2. status: "UP"
  3. }

返回服务离线状态的报文格式如下:

  1. {
  2. status: "DOWN"
  3. }

3.1.6 Nacos 接入 Prometheus 监控

访问 Nacos 端点是否正常:http://192.168.50.163:8848/nacos/actuator/prometheus
image.png
设置 Prometheus 的配置文件 /opt/docker/prometheus/etc/prometheus.yaml

  1. global:
  2. scrape_interval: 15s
  3. evaluation_interval: 15s
  4. scrape_configs:
  5. - job_name: nacos
  6. metrics_path: '/nacos/actuator/prometheus'
  7. static_configs:
  8. - targets: ['192.168.50.163:8850','192.168.50.163:8852','192.168.50.163:8854']

启动 Prometheus 容器,挂载 /opt/docker/prometheus/etc/prometheus.yaml

  1. docker run -d -p 9090:9090 --name=prometheus -v /opt/docker/prometheus/etc/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

访问 http://192.168.50.163:9090/graph,输入 nacos_monitor 关键字验证是否返回数据。
image.png
访问 http://192.168.50.163:9090/targets,查看 Nacos 集群状态是否为 UP
image.png
启动 Grafana 容器,挂在数据到宿主机的 /opt/docker/grafana 目录。

  1. docker run -d -p 3000:3000 --name=grafana -v /opt/docker/grafana:/var/lib/grafana grafana/grafana

访问 http://192.168.50.163:3000/dashboards
image.png
导入 Nacos 官方提供的 Grafana 模板。

  1. {
  2. "annotations": {
  3. "list": [
  4. {
  5. "builtIn": 1,
  6. "datasource": "-- Grafana --",
  7. "enable": true,
  8. "hide": true,
  9. "iconColor": "rgba(0, 211, 255, 1)",
  10. "name": "Annotations & Alerts",
  11. "type": "dashboard"
  12. }
  13. ]
  14. },
  15. "editable": true,
  16. "gnetId": null,
  17. "graphTooltip": 0,
  18. "id": 8,
  19. "iteration": 1547344645256,
  20. "links": [],
  21. "panels": [
  22. {
  23. "collapsed": false,
  24. "gridPos": {
  25. "h": 1,
  26. "w": 24,
  27. "x": 0,
  28. "y": 0
  29. },
  30. "id": 80,
  31. "panels": [],
  32. "title": "nacos monitor",
  33. "type": "row"
  34. },
  35. {
  36. "cacheTimeout": null,
  37. "colorBackground": false,
  38. "colorValue": false,
  39. "colors": [
  40. "#299c46",
  41. "rgba(237, 129, 40, 0.89)",
  42. "#d44a3a"
  43. ],
  44. "datasource": "Prometheus",
  45. "format": "none",
  46. "gauge": {
  47. "maxValue": 100,
  48. "minValue": 0,
  49. "show": false,
  50. "thresholdLabels": false,
  51. "thresholdMarkers": true
  52. },
  53. "gridPos": {
  54. "h": 3,
  55. "w": 3,
  56. "x": 0,
  57. "y": 1
  58. },
  59. "id": 89,
  60. "interval": null,
  61. "links": [],
  62. "mappingType": 1,
  63. "mappingTypes": [
  64. {
  65. "name": "value to text",
  66. "value": 1
  67. },
  68. {
  69. "name": "range to text",
  70. "value": 2
  71. }
  72. ],
  73. "maxDataPoints": 100,
  74. "nullPointMode": "connected",
  75. "nullText": null,
  76. "postfix": "",
  77. "postfixFontSize": "50%",
  78. "prefix": "",
  79. "prefixFontSize": "50%",
  80. "rangeMaps": [
  81. {
  82. "from": "null",
  83. "text": "N/A",
  84. "to": "null"
  85. }
  86. ],
  87. "sparkline": {
  88. "fillColor": "rgba(31, 118, 189, 0.18)",
  89. "full": false,
  90. "lineColor": "rgb(31, 120, 193)",
  91. "show": false
  92. },
  93. "tableColumn": "",
  94. "targets": [
  95. {
  96. "expr": "count(nacos_monitor{name=\"configCount\"})",
  97. "format": "time_series",
  98. "intervalFactor": 1,
  99. "refId": "A"
  100. }
  101. ],
  102. "thresholds": "",
  103. "title": "UP",
  104. "type": "singlestat",
  105. "valueFontSize": "80%",
  106. "valueMaps": [
  107. {
  108. "op": "=",
  109. "text": "N/A",
  110. "value": "null"
  111. }
  112. ],
  113. "valueName": "current"
  114. },
  115. {
  116. "cacheTimeout": null,
  117. "colorBackground": false,
  118. "colorValue": false,
  119. "colors": [
  120. "#299c46",
  121. "rgba(237, 129, 40, 0.89)",
  122. "#d44a3a"
  123. ],
  124. "datasource": "Prometheus",
  125. "format": "none",
  126. "gauge": {
  127. "maxValue": 100,
  128. "minValue": 0,
  129. "show": false,
  130. "thresholdLabels": false,
  131. "thresholdMarkers": true
  132. },
  133. "gridPos": {
  134. "h": 3,
  135. "w": 3,
  136. "x": 3,
  137. "y": 1
  138. },
  139. "id": 90,
  140. "interval": null,
  141. "links": [],
  142. "mappingType": 1,
  143. "mappingTypes": [
  144. {
  145. "name": "value to text",
  146. "value": 1
  147. },
  148. {
  149. "name": "range to text",
  150. "value": 2
  151. }
  152. ],
  153. "maxDataPoints": 100,
  154. "nullPointMode": "connected",
  155. "nullText": null,
  156. "postfix": "",
  157. "postfixFontSize": "50%",
  158. "prefix": "",
  159. "prefixFontSize": "50%",
  160. "rangeMaps": [
  161. {
  162. "from": "null",
  163. "text": "N/A",
  164. "to": "null"
  165. }
  166. ],
  167. "sparkline": {
  168. "fillColor": "rgba(31, 118, 189, 0.18)",
  169. "full": false,
  170. "lineColor": "rgb(31, 120, 193)",
  171. "show": false
  172. },
  173. "tableColumn": "",
  174. "targets": [
  175. {
  176. "expr": "max(nacos_monitor{name='domCount'})",
  177. "format": "time_series",
  178. "intervalFactor": 1,
  179. "refId": "A"
  180. }
  181. ],
  182. "thresholds": "",
  183. "title": "service count",
  184. "type": "singlestat",
  185. "valueFontSize": "80%",
  186. "valueMaps": [
  187. {
  188. "op": "=",
  189. "text": "N/A",
  190. "value": "null"
  191. }
  192. ],
  193. "valueName": "current"
  194. },
  195. {
  196. "cacheTimeout": null,
  197. "colorBackground": false,
  198. "colorValue": false,
  199. "colors": [
  200. "#299c46",
  201. "rgba(237, 129, 40, 0.89)",
  202. "#d44a3a"
  203. ],
  204. "datasource": "Prometheus",
  205. "format": "none",
  206. "gauge": {
  207. "maxValue": 100,
  208. "minValue": 0,
  209. "show": false,
  210. "thresholdLabels": false,
  211. "thresholdMarkers": true
  212. },
  213. "gridPos": {
  214. "h": 3,
  215. "w": 3,
  216. "x": 6,
  217. "y": 1
  218. },
  219. "id": 93,
  220. "interval": null,
  221. "links": [],
  222. "mappingType": 1,
  223. "mappingTypes": [
  224. {
  225. "name": "value to text",
  226. "value": 1
  227. },
  228. {
  229. "name": "range to text",
  230. "value": 2
  231. }
  232. ],
  233. "maxDataPoints": 100,
  234. "nullPointMode": "connected",
  235. "nullText": null,
  236. "postfix": "",
  237. "postfixFontSize": "50%",
  238. "prefix": "",
  239. "prefixFontSize": "50%",
  240. "rangeMaps": [
  241. {
  242. "from": "null",
  243. "text": "N/A",
  244. "to": "null"
  245. }
  246. ],
  247. "sparkline": {
  248. "fillColor": "rgba(31, 118, 189, 0.18)",
  249. "full": false,
  250. "lineColor": "rgb(31, 120, 193)",
  251. "show": false
  252. },
  253. "tableColumn": "",
  254. "targets": [
  255. {
  256. "expr": "max(nacos_monitor{name='ipCount'})",
  257. "format": "time_series",
  258. "intervalFactor": 1,
  259. "refId": "A"
  260. }
  261. ],
  262. "thresholds": "",
  263. "title": "ip count",
  264. "type": "singlestat",
  265. "valueFontSize": "80%",
  266. "valueMaps": [
  267. {
  268. "op": "=",
  269. "text": "N/A",
  270. "value": "null"
  271. }
  272. ],
  273. "valueName": "current"
  274. },
  275. {
  276. "cacheTimeout": null,
  277. "colorBackground": false,
  278. "colorValue": false,
  279. "colors": [
  280. "#299c46",
  281. "rgba(237, 129, 40, 0.89)",
  282. "#d44a3a"
  283. ],
  284. "datasource": "Prometheus",
  285. "format": "none",
  286. "gauge": {
  287. "maxValue": 100,
  288. "minValue": 0,
  289. "show": false,
  290. "thresholdLabels": false,
  291. "thresholdMarkers": true
  292. },
  293. "gridPos": {
  294. "h": 3,
  295. "w": 3,
  296. "x": 9,
  297. "y": 1
  298. },
  299. "id": 92,
  300. "interval": null,
  301. "links": [],
  302. "mappingType": 1,
  303. "mappingTypes": [
  304. {
  305. "name": "value to text",
  306. "value": 1
  307. },
  308. {
  309. "name": "range to text",
  310. "value": 2
  311. }
  312. ],
  313. "maxDataPoints": 100,
  314. "nullPointMode": "connected",
  315. "nullText": null,
  316. "postfix": "",
  317. "postfixFontSize": "50%",
  318. "prefix": "",
  319. "prefixFontSize": "50%",
  320. "rangeMaps": [
  321. {
  322. "from": "null",
  323. "text": "N/A",
  324. "to": "null"
  325. }
  326. ],
  327. "sparkline": {
  328. "fillColor": "rgba(31, 118, 189, 0.18)",
  329. "full": false,
  330. "lineColor": "rgb(31, 120, 193)",
  331. "show": false
  332. },
  333. "tableColumn": "",
  334. "targets": [
  335. {
  336. "expr": "max(nacos_monitor{name='configCount', instance=~'$instance'})",
  337. "format": "time_series",
  338. "intervalFactor": 1,
  339. "refId": "A"
  340. }
  341. ],
  342. "thresholds": "",
  343. "title": "config count",
  344. "type": "singlestat",
  345. "valueFontSize": "80%",
  346. "valueMaps": [
  347. {
  348. "op": "=",
  349. "text": "N/A",
  350. "value": "null"
  351. }
  352. ],
  353. "valueName": "current"
  354. },
  355. {
  356. "cacheTimeout": null,
  357. "colorBackground": false,
  358. "colorValue": false,
  359. "colors": [
  360. "#299c46",
  361. "rgba(237, 129, 40, 0.89)",
  362. "#d44a3a"
  363. ],
  364. "datasource": "Prometheus",
  365. "format": "none",
  366. "gauge": {
  367. "maxValue": 100,
  368. "minValue": 0,
  369. "show": false,
  370. "thresholdLabels": false,
  371. "thresholdMarkers": true
  372. },
  373. "gridPos": {
  374. "h": 3,
  375. "w": 3,
  376. "x": 12,
  377. "y": 1
  378. },
  379. "id": 91,
  380. "interval": null,
  381. "links": [],
  382. "mappingType": 1,
  383. "mappingTypes": [
  384. {
  385. "name": "value to text",
  386. "value": 1
  387. },
  388. {
  389. "name": "range to text",
  390. "value": 2
  391. }
  392. ],
  393. "maxDataPoints": 100,
  394. "nullPointMode": "connected",
  395. "nullText": null,
  396. "postfix": "",
  397. "postfixFontSize": "50%",
  398. "prefix": "",
  399. "prefixFontSize": "50%",
  400. "rangeMaps": [
  401. {
  402. "from": "null",
  403. "text": "N/A",
  404. "to": "null"
  405. }
  406. ],
  407. "sparkline": {
  408. "fillColor": "rgba(31, 118, 189, 0.18)",
  409. "full": false,
  410. "lineColor": "rgb(31, 120, 193)",
  411. "show": false
  412. },
  413. "tableColumn": "",
  414. "targets": [
  415. {
  416. "expr": "sum(nacos_monitor{name='longPolling'})",
  417. "format": "time_series",
  418. "intervalFactor": 1,
  419. "refId": "A"
  420. }
  421. ],
  422. "thresholds": "",
  423. "title": "long polling",
  424. "type": "singlestat",
  425. "valueFontSize": "80%",
  426. "valueMaps": [
  427. {
  428. "op": "=",
  429. "text": "N/A",
  430. "value": "null"
  431. }
  432. ],
  433. "valueName": "current"
  434. },
  435. {
  436. "cacheTimeout": null,
  437. "colorBackground": false,
  438. "colorValue": false,
  439. "colors": [
  440. "#299c46",
  441. "rgba(237, 129, 40, 0.89)",
  442. "#d44a3a"
  443. ],
  444. "datasource": "Prometheus",
  445. "format": "none",
  446. "gauge": {
  447. "maxValue": 100,
  448. "minValue": 0,
  449. "show": false,
  450. "thresholdLabels": false,
  451. "thresholdMarkers": true
  452. },
  453. "gridPos": {
  454. "h": 3,
  455. "w": 3,
  456. "x": 15,
  457. "y": 1
  458. },
  459. "id": 88,
  460. "interval": null,
  461. "links": [],
  462. "mappingType": 1,
  463. "mappingTypes": [
  464. {
  465. "name": "value to text",
  466. "value": 1
  467. },
  468. {
  469. "name": "range to text",
  470. "value": 2
  471. }
  472. ],
  473. "maxDataPoints": 100,
  474. "nullPointMode": "connected",
  475. "nullText": null,
  476. "postfix": "",
  477. "postfixFontSize": "50%",
  478. "prefix": "",
  479. "prefixFontSize": "50%",
  480. "rangeMaps": [
  481. {
  482. "from": "null",
  483. "text": "N/A",
  484. "to": "null"
  485. }
  486. ],
  487. "sparkline": {
  488. "fillColor": "rgba(31, 118, 189, 0.18)",
  489. "full": false,
  490. "lineColor": "rgb(31, 120, 193)",
  491. "show": false
  492. },
  493. "tableColumn": "",
  494. "targets": [
  495. {
  496. "expr": "sum(nacos_monitor{name='getConfig', instance=~'$instance'}) by (name)",
  497. "format": "time_series",
  498. "intervalFactor": 1,
  499. "refId": "A"
  500. }
  501. ],
  502. "thresholds": "",
  503. "title": "config push total",
  504. "type": "singlestat",
  505. "valueFontSize": "80%",
  506. "valueMaps": [
  507. {
  508. "op": "=",
  509. "text": "N/A",
  510. "value": "null"
  511. }
  512. ],
  513. "valueName": "current"
  514. },
  515. {
  516. "content": "<br/><center><a href=\"https://nacos.io\">\n<img src=\"https://nacos.io/img/nacos.png\" style=\"height: 50px;\" >\n</a>\n</center>",
  517. "gridPos": {
  518. "h": 3,
  519. "w": 6,
  520. "x": 18,
  521. "y": 1
  522. },
  523. "id": 82,
  524. "links": [],
  525. "mode": "html",
  526. "title": "",
  527. "type": "text"
  528. },
  529. {
  530. "cacheTimeout": null,
  531. "colorBackground": false,
  532. "colorPrefix": false,
  533. "colorValue": false,
  534. "colors": [
  535. "#299c46",
  536. "rgba(237, 129, 40, 0.89)",
  537. "#d44a3a"
  538. ],
  539. "datasource": "Prometheus",
  540. "decimals": null,
  541. "format": "none",
  542. "gauge": {
  543. "maxValue": 100,
  544. "minValue": 0,
  545. "show": true,
  546. "thresholdLabels": false,
  547. "thresholdMarkers": true
  548. },
  549. "gridPos": {
  550. "h": 4,
  551. "w": 9,
  552. "x": 0,
  553. "y": 4
  554. },
  555. "id": 33,
  556. "interval": "",
  557. "links": [],
  558. "mappingType": 1,
  559. "mappingTypes": [
  560. {
  561. "name": "value to text",
  562. "value": 1
  563. },
  564. {
  565. "name": "range to text",
  566. "value": 2
  567. }
  568. ],
  569. "maxDataPoints": 100,
  570. "nullPointMode": "connected",
  571. "nullText": null,
  572. "postfix": "%",
  573. "postfixFontSize": "50%",
  574. "prefix": "",
  575. "prefixFontSize": "50%",
  576. "rangeMaps": [
  577. {
  578. "from": "null",
  579. "text": "N/A",
  580. "to": "null"
  581. }
  582. ],
  583. "repeat": null,
  584. "repeatDirection": "h",
  585. "sparkline": {
  586. "fillColor": "rgba(31, 118, 189, 0.18)",
  587. "full": false,
  588. "lineColor": "rgb(31, 120, 193)",
  589. "show": false
  590. },
  591. "tableColumn": "",
  592. "targets": [
  593. {
  594. "expr": "max(system_cpu_usage{instance=~'$instance'}) * 100",
  595. "format": "time_series",
  596. "interval": "",
  597. "intervalFactor": 1,
  598. "legendFormat": "",
  599. "refId": "A"
  600. }
  601. ],
  602. "thresholds": "50,80",
  603. "title": "cpu",
  604. "type": "singlestat",
  605. "valueFontSize": "70%",
  606. "valueMaps": [
  607. {
  608. "op": "=",
  609. "text": "N/A",
  610. "value": "null"
  611. }
  612. ],
  613. "valueName": "current"
  614. },
  615. {
  616. "cacheTimeout": null,
  617. "colorBackground": false,
  618. "colorPrefix": false,
  619. "colorValue": false,
  620. "colors": [
  621. "#299c46",
  622. "rgba(237, 129, 40, 0.89)",
  623. "#d44a3a"
  624. ],
  625. "datasource": "Prometheus",
  626. "decimals": null,
  627. "format": "none",
  628. "gauge": {
  629. "maxValue": 70,
  630. "minValue": 0,
  631. "show": true,
  632. "thresholdLabels": false,
  633. "thresholdMarkers": true
  634. },
  635. "gridPos": {
  636. "h": 4,
  637. "w": 9,
  638. "x": 9,
  639. "y": 4
  640. },
  641. "id": 32,
  642. "interval": null,
  643. "links": [],
  644. "mappingType": 1,
  645. "mappingTypes": [
  646. {
  647. "name": "value to text",
  648. "value": 1
  649. },
  650. {
  651. "name": "range to text",
  652. "value": 2
  653. }
  654. ],
  655. "maxDataPoints": 100,
  656. "nullPointMode": "connected",
  657. "nullText": null,
  658. "postfix": "%",
  659. "postfixFontSize": "50%",
  660. "prefix": "",
  661. "prefixFontSize": "50%",
  662. "rangeMaps": [
  663. {
  664. "from": "null",
  665. "text": "N/A",
  666. "to": "null"
  667. }
  668. ],
  669. "sparkline": {
  670. "fillColor": "rgba(31, 118, 189, 0.18)",
  671. "full": false,
  672. "lineColor": "rgb(31, 120, 193)",
  673. "show": false
  674. },
  675. "tableColumn": "",
  676. "targets": [
  677. {
  678. "expr": "sum(jvm_memory_used_bytes{area=\"heap\", instance=~'$instance'})/sum(jvm_memory_max_bytes{area=\"heap\", instance=~'$instance'}) * 100",
  679. "format": "time_series",
  680. "intervalFactor": 1,
  681. "refId": "A"
  682. }
  683. ],
  684. "thresholds": "50,70",
  685. "title": "memory",
  686. "type": "singlestat",
  687. "valueFontSize": "70%",
  688. "valueMaps": [
  689. {
  690. "op": "=",
  691. "text": "N/A",
  692. "value": "null"
  693. }
  694. ],
  695. "valueName": "current"
  696. },
  697. {
  698. "dashboardFilter": "",
  699. "folderId": null,
  700. "gridPos": {
  701. "h": 16,
  702. "w": 6,
  703. "x": 18,
  704. "y": 4
  705. },
  706. "id": 48,
  707. "limit": 10,
  708. "links": [],
  709. "nameFilter": "",
  710. "onlyAlertsOnDashboard": false,
  711. "repeat": null,
  712. "show": "current",
  713. "sortOrder": 1,
  714. "stateFilter": [],
  715. "title": "alert list",
  716. "transparent": false,
  717. "type": "alertlist"
  718. },
  719. {
  720. "cacheTimeout": null,
  721. "colorBackground": false,
  722. "colorPrefix": false,
  723. "colorValue": false,
  724. "colors": [
  725. "#299c46",
  726. "rgba(237, 129, 40, 0.89)",
  727. "#d44a3a"
  728. ],
  729. "datasource": "Prometheus",
  730. "decimals": null,
  731. "format": "none",
  732. "gauge": {
  733. "maxValue": 1500,
  734. "minValue": 0,
  735. "show": true,
  736. "thresholdLabels": false,
  737. "thresholdMarkers": true
  738. },
  739. "gridPos": {
  740. "h": 4,
  741. "w": 9,
  742. "x": 0,
  743. "y": 8
  744. },
  745. "id": 29,
  746. "interval": null,
  747. "links": [],
  748. "mappingType": 1,
  749. "mappingTypes": [
  750. {
  751. "name": "value to text",
  752. "value": 1
  753. },
  754. {
  755. "name": "range to text",
  756. "value": 2
  757. }
  758. ],
  759. "maxDataPoints": 100,
  760. "nullPointMode": "connected",
  761. "nullText": null,
  762. "postfix": "",
  763. "postfixFontSize": "50%",
  764. "prefix": "",
  765. "prefixFontSize": "50%",
  766. "rangeMaps": [
  767. {
  768. "from": "null",
  769. "text": "N/A",
  770. "to": "null"
  771. }
  772. ],
  773. "sparkline": {
  774. "fillColor": "rgba(31, 118, 189, 0.18)",
  775. "full": false,
  776. "lineColor": "rgb(31, 120, 193)",
  777. "show": false
  778. },
  779. "tableColumn": "",
  780. "targets": [
  781. {
  782. "expr": "max(jvm_threads_daemon_threads{instance=~'$instance'})",
  783. "format": "time_series",
  784. "intervalFactor": 1,
  785. "refId": "A"
  786. }
  787. ],
  788. "thresholds": "800,1500",
  789. "title": "threads",
  790. "type": "singlestat",
  791. "valueFontSize": "70%",
  792. "valueMaps": [
  793. {
  794. "op": "=",
  795. "text": "N/A",
  796. "value": "null"
  797. }
  798. ],
  799. "valueName": "current"
  800. },
  801. {
  802. "cacheTimeout": null,
  803. "colorBackground": false,
  804. "colorPrefix": false,
  805. "colorValue": false,
  806. "colors": [
  807. "#299c46",
  808. "rgba(237, 129, 40, 0.89)",
  809. "#d44a3a"
  810. ],
  811. "datasource": "Prometheus",
  812. "decimals": null,
  813. "format": "none",
  814. "gauge": {
  815. "maxValue": 20,
  816. "minValue": 0,
  817. "show": true,
  818. "thresholdLabels": false,
  819. "thresholdMarkers": true
  820. },
  821. "gridPos": {
  822. "h": 4,
  823. "w": 9,
  824. "x": 9,
  825. "y": 8
  826. },
  827. "id": 30,
  828. "interval": null,
  829. "links": [],
  830. "mappingType": 1,
  831. "mappingTypes": [
  832. {
  833. "name": "value to text",
  834. "value": 1
  835. },
  836. {
  837. "name": "range to text",
  838. "value": 2
  839. }
  840. ],
  841. "maxDataPoints": 100,
  842. "nullPointMode": "connected",
  843. "nullText": null,
  844. "postfix": "",
  845. "postfixFontSize": "50%",
  846. "prefix": "",
  847. "prefixFontSize": "50%",
  848. "rangeMaps": [
  849. {
  850. "from": "null",
  851. "text": "N/A",
  852. "to": "null"
  853. }
  854. ],
  855. "sparkline": {
  856. "fillColor": "rgba(31, 118, 189, 0.18)",
  857. "full": false,
  858. "lineColor": "rgb(31, 120, 193)",
  859. "show": false
  860. },
  861. "tableColumn": "",
  862. "targets": [
  863. {
  864. "expr": "max(system_load_average_1m{instance=~'$instance'})",
  865. "format": "time_series",
  866. "intervalFactor": 1,
  867. "refId": "A"
  868. }
  869. ],
  870. "thresholds": "5,10",
  871. "title": "load",
  872. "type": "singlestat",
  873. "valueFontSize": "70%",
  874. "valueMaps": [
  875. {
  876. "op": "=",
  877. "text": "N/A",
  878. "value": "null"
  879. }
  880. ],
  881. "valueName": "current"
  882. },
  883. {
  884. "cacheTimeout": null,
  885. "colorBackground": false,
  886. "colorPrefix": false,
  887. "colorValue": false,
  888. "colors": [
  889. "#299c46",
  890. "rgba(237, 129, 40, 0.89)",
  891. "#d44a3a"
  892. ],
  893. "datasource": "Prometheus",
  894. "decimals": null,
  895. "format": "none",
  896. "gauge": {
  897. "maxValue": 5000,
  898. "minValue": 0,
  899. "show": true,
  900. "thresholdLabels": false,
  901. "thresholdMarkers": true
  902. },
  903. "gridPos": {
  904. "h": 4,
  905. "w": 9,
  906. "x": 0,
  907. "y": 12
  908. },
  909. "id": 61,
  910. "interval": null,
  911. "links": [],
  912. "mappingType": 1,
  913. "mappingTypes": [
  914. {
  915. "name": "value to text",
  916. "value": 1
  917. },
  918. {
  919. "name": "range to text",
  920. "value": 2
  921. }
  922. ],
  923. "maxDataPoints": 100,
  924. "nullPointMode": "connected",
  925. "nullText": null,
  926. "postfix": "ms",
  927. "postfixFontSize": "50%",
  928. "prefix": "",
  929. "prefixFontSize": "50%",
  930. "rangeMaps": [
  931. {
  932. "from": "null",
  933. "text": "N/A",
  934. "to": "null"
  935. }
  936. ],
  937. "sparkline": {
  938. "fillColor": "rgba(31, 118, 189, 0.18)",
  939. "full": false,
  940. "lineColor": "rgb(31, 120, 193)",
  941. "show": false
  942. },
  943. "tableColumn": "",
  944. "targets": [
  945. {
  946. "expr": "sum(rate(nacos_timer_seconds_sum{instance=~'$instance'}[1m]))/sum(rate(nacos_timer_seconds_count{instance=~'$instance'}[1m])) * 1000",
  947. "format": "time_series",
  948. "intervalFactor": 1,
  949. "legendFormat": "",
  950. "refId": "A"
  951. }
  952. ],
  953. "thresholds": "3000,5000",
  954. "title": "notify rt",
  955. "type": "singlestat",
  956. "valueFontSize": "80%",
  957. "valueMaps": [
  958. {
  959. "op": "=",
  960. "text": "N/A",
  961. "value": "null"
  962. }
  963. ],
  964. "valueName": "current"
  965. },
  966. {
  967. "cacheTimeout": null,
  968. "colorBackground": false,
  969. "colorPrefix": false,
  970. "colorValue": false,
  971. "colors": [
  972. "#299c46",
  973. "rgba(237, 129, 40, 0.89)",
  974. "#d44a3a"
  975. ],
  976. "datasource": "Prometheus",
  977. "decimals": null,
  978. "format": "none",
  979. "gauge": {
  980. "maxValue": 5000,
  981. "minValue": 0,
  982. "show": true,
  983. "thresholdLabels": false,
  984. "thresholdMarkers": true
  985. },
  986. "gridPos": {
  987. "h": 4,
  988. "w": 9,
  989. "x": 9,
  990. "y": 12
  991. },
  992. "id": 26,
  993. "interval": null,
  994. "links": [],
  995. "mappingType": 1,
  996. "mappingTypes": [
  997. {
  998. "name": "value to text",
  999. "value": 1
  1000. },
  1001. {
  1002. "name": "range to text",
  1003. "value": 2
  1004. }
  1005. ],
  1006. "maxDataPoints": 100,
  1007. "nullPointMode": "connected",
  1008. "nullText": null,
  1009. "postfix": "ms",
  1010. "postfixFontSize": "50%",
  1011. "prefix": "",
  1012. "prefixFontSize": "50%",
  1013. "rangeMaps": [
  1014. {
  1015. "from": "null",
  1016. "text": "N/A",
  1017. "to": "null"
  1018. }
  1019. ],
  1020. "sparkline": {
  1021. "fillColor": "rgba(31, 118, 189, 0.18)",
  1022. "full": false,
  1023. "lineColor": "rgb(31, 120, 193)",
  1024. "show": false
  1025. },
  1026. "tableColumn": "",
  1027. "targets": [
  1028. {
  1029. "expr": "sum(rate(http_server_requests_seconds_sum{instance=~'$instance'}[1m]))/sum(rate(http_server_requests_seconds_count{instance=~'$instance'}[1m])) * 1000",
  1030. "format": "time_series",
  1031. "intervalFactor": 1,
  1032. "legendFormat": "",
  1033. "refId": "A"
  1034. }
  1035. ],
  1036. "thresholds": "3000,5000",
  1037. "title": "rt",
  1038. "type": "singlestat",
  1039. "valueFontSize": "80%",
  1040. "valueMaps": [
  1041. {
  1042. "op": "=",
  1043. "text": "N/A",
  1044. "value": "null"
  1045. }
  1046. ],
  1047. "valueName": "current"
  1048. },
  1049. {
  1050. "cacheTimeout": null,
  1051. "colorBackground": false,
  1052. "colorPrefix": false,
  1053. "colorValue": false,
  1054. "colors": [
  1055. "#299c46",
  1056. "rgba(237, 129, 40, 0.89)",
  1057. "#d44a3a"
  1058. ],
  1059. "datasource": "Prometheus",
  1060. "decimals": null,
  1061. "format": "none",
  1062. "gauge": {
  1063. "maxValue": 2000,
  1064. "minValue": 0,
  1065. "show": true,
  1066. "thresholdLabels": false,
  1067. "thresholdMarkers": true
  1068. },
  1069. "gridPos": {
  1070. "h": 4,
  1071. "w": 9,
  1072. "x": 0,
  1073. "y": 16
  1074. },
  1075. "id": 25,
  1076. "interval": null,
  1077. "links": [],
  1078. "mappingType": 1,
  1079. "mappingTypes": [
  1080. {
  1081. "name": "value to text",
  1082. "value": 1
  1083. },
  1084. {
  1085. "name": "range to text",
  1086. "value": 2
  1087. }
  1088. ],
  1089. "maxDataPoints": 100,
  1090. "nullPointMode": "connected",
  1091. "nullText": null,
  1092. "postfix": "",
  1093. "postfixFontSize": "50%",
  1094. "prefix": "",
  1095. "prefixFontSize": "50%",
  1096. "rangeMaps": [
  1097. {
  1098. "from": "null",
  1099. "text": "N/A",
  1100. "to": "null"
  1101. }
  1102. ],
  1103. "sparkline": {
  1104. "fillColor": "rgba(31, 118, 189, 0.18)",
  1105. "full": false,
  1106. "lineColor": "rgb(31, 120, 193)",
  1107. "show": false
  1108. },
  1109. "tableColumn": "",
  1110. "targets": [
  1111. {
  1112. "expr": "sum(rate(http_server_requests_seconds_count{instance=~'$instance'}[1m]))",
  1113. "format": "time_series",
  1114. "intervalFactor": 1,
  1115. "legendFormat": "",
  1116. "refId": "A"
  1117. }
  1118. ],
  1119. "thresholds": "1000,2000",
  1120. "title": "qps",
  1121. "type": "singlestat",
  1122. "valueFontSize": "70%",
  1123. "valueMaps": [
  1124. {
  1125. "op": "=",
  1126. "text": "N/A",
  1127. "value": "null"
  1128. }
  1129. ],
  1130. "valueName": "current"
  1131. },
  1132. {
  1133. "cacheTimeout": null,
  1134. "colorBackground": false,
  1135. "colorPrefix": false,
  1136. "colorValue": false,
  1137. "colors": [
  1138. "#299c46",
  1139. "rgba(237, 129, 40, 0.89)",
  1140. "#d44a3a"
  1141. ],
  1142. "datasource": "Prometheus",
  1143. "decimals": null,
  1144. "format": "none",
  1145. "gauge": {
  1146. "maxValue": 5000,
  1147. "minValue": 0,
  1148. "show": true,
  1149. "thresholdLabels": false,
  1150. "thresholdMarkers": true
  1151. },
  1152. "gridPos": {
  1153. "h": 4,
  1154. "w": 9,
  1155. "x": 9,
  1156. "y": 16
  1157. },
  1158. "id": 70,
  1159. "interval": null,
  1160. "links": [],
  1161. "mappingType": 1,
  1162. "mappingTypes": [
  1163. {
  1164. "name": "value to text",
  1165. "value": 1
  1166. },
  1167. {
  1168. "name": "range to text",
  1169. "value": 2
  1170. }
  1171. ],
  1172. "maxDataPoints": 100,
  1173. "nullPointMode": "connected",
  1174. "nullText": null,
  1175. "postfix": "ms",
  1176. "postfixFontSize": "50%",
  1177. "prefix": "",
  1178. "prefixFontSize": "50%",
  1179. "rangeMaps": [
  1180. {
  1181. "from": "null",
  1182. "text": "N/A",
  1183. "to": "null"
  1184. }
  1185. ],
  1186. "sparkline": {
  1187. "fillColor": "rgba(31, 118, 189, 0.18)",
  1188. "full": false,
  1189. "lineColor": "rgb(31, 120, 193)",
  1190. "show": false
  1191. },
  1192. "tableColumn": "",
  1193. "targets": [
  1194. {
  1195. "expr": "max(nacos_monitor{name='avgPushCost', instance=~'$instance'})",
  1196. "format": "time_series",
  1197. "intervalFactor": 1,
  1198. "refId": "A"
  1199. }
  1200. ],
  1201. "thresholds": "1000,5000",
  1202. "title": "avgPushCost",
  1203. "type": "singlestat",
  1204. "valueFontSize": "70%",
  1205. "valueMaps": [
  1206. {
  1207. "op": "=",
  1208. "text": "N/A",
  1209. "value": "null"
  1210. }
  1211. ],
  1212. "valueName": "current"
  1213. },
  1214. {
  1215. "collapsed": false,
  1216. "gridPos": {
  1217. "h": 1,
  1218. "w": 24,
  1219. "x": 0,
  1220. "y": 20
  1221. },
  1222. "id": 78,
  1223. "panels": [],
  1224. "title": "nacos detail",
  1225. "type": "row"
  1226. },
  1227. {
  1228. "aliasColors": {},
  1229. "bars": false,
  1230. "dashLength": 10,
  1231. "dashes": false,
  1232. "datasource": "Prometheus",
  1233. "fill": 1,
  1234. "gridPos": {
  1235. "h": 5,
  1236. "w": 8,
  1237. "x": 0,
  1238. "y": 21
  1239. },
  1240. "id": 20,
  1241. "legend": {
  1242. "avg": false,
  1243. "current": false,
  1244. "max": false,
  1245. "min": false,
  1246. "show": true,
  1247. "total": false,
  1248. "values": false
  1249. },
  1250. "lines": true,
  1251. "linewidth": 1,
  1252. "links": [],
  1253. "nullPointMode": "null",
  1254. "percentage": false,
  1255. "pointradius": 5,
  1256. "points": false,
  1257. "renderer": "flot",
  1258. "seriesOverrides": [],
  1259. "spaceLength": 10,
  1260. "stack": false,
  1261. "steppedLine": false,
  1262. "targets": [
  1263. {
  1264. "expr": "sum(rate(http_server_requests_seconds_sum{uri=~'/v1/cs/configs|/nacos/v1/ns', instance=~'$instance'}[1m])/rate(http_server_requests_seconds_count{uri=~'/v1/cs/configs|/nacos/v1/ns/instance|/nacos/v1/ns/health', instance=~'$instance'}[1m])) by (method,uri) * 1000",
  1265. "format": "time_series",
  1266. "intervalFactor": 1,
  1267. "refId": "A"
  1268. },
  1269. {
  1270. "expr": "sum(rate(http_server_requests_seconds_sum{instance=~'$instance'}[1m]))/sum(rate(http_server_requests_seconds_count{instance=~'$instance'}[1m])) * 1000",
  1271. "format": "time_series",
  1272. "hide": false,
  1273. "intervalFactor": 1,
  1274. "legendFormat": "all",
  1275. "refId": "B"
  1276. }
  1277. ],
  1278. "thresholds": [],
  1279. "timeFrom": null,
  1280. "timeRegions": [],
  1281. "timeShift": null,
  1282. "title": "rt",
  1283. "tooltip": {
  1284. "shared": true,
  1285. "sort": 0,
  1286. "value_type": "individual"
  1287. },
  1288. "type": "graph",
  1289. "xaxis": {
  1290. "buckets": null,
  1291. "mode": "time",
  1292. "name": null,
  1293. "show": true,
  1294. "values": []
  1295. },
  1296. "yaxes": [
  1297. {
  1298. "format": "short",
  1299. "label": null,
  1300. "logBase": 1,
  1301. "max": null,
  1302. "min": null,
  1303. "show": true
  1304. },
  1305. {
  1306. "format": "short",
  1307. "label": null,
  1308. "logBase": 1,
  1309. "max": null,
  1310. "min": null,
  1311. "show": true
  1312. }
  1313. ],
  1314. "yaxis": {
  1315. "align": false,
  1316. "alignLevel": null
  1317. }
  1318. },
  1319. {
  1320. "aliasColors": {},
  1321. "bars": false,
  1322. "dashLength": 10,
  1323. "dashes": false,
  1324. "datasource": "Prometheus",
  1325. "fill": 1,
  1326. "gridPos": {
  1327. "h": 5,
  1328. "w": 8,
  1329. "x": 8,
  1330. "y": 21
  1331. },
  1332. "id": 41,
  1333. "legend": {
  1334. "avg": false,
  1335. "current": false,
  1336. "max": false,
  1337. "min": false,
  1338. "show": true,
  1339. "total": false,
  1340. "values": false
  1341. },
  1342. "lines": true,
  1343. "linewidth": 1,
  1344. "links": [],
  1345. "nullPointMode": "null",
  1346. "percentage": false,
  1347. "pointradius": 5,
  1348. "points": false,
  1349. "renderer": "flot",
  1350. "repeat": "group",
  1351. "repeatDirection": "h",
  1352. "seriesOverrides": [],
  1353. "spaceLength": 10,
  1354. "stack": false,
  1355. "steppedLine": false,
  1356. "targets": [
  1357. {
  1358. "expr": "sum(nacos_monitor{name='longPolling', instance=~'$instance'})",
  1359. "format": "time_series",
  1360. "intervalFactor": 1,
  1361. "legendFormat": "",
  1362. "refId": "A"
  1363. }
  1364. ],
  1365. "thresholds": [],
  1366. "timeFrom": null,
  1367. "timeRegions": [],
  1368. "timeShift": null,
  1369. "title": "long polling",
  1370. "tooltip": {
  1371. "shared": true,
  1372. "sort": 0,
  1373. "value_type": "individual"
  1374. },
  1375. "type": "graph",
  1376. "xaxis": {
  1377. "buckets": null,
  1378. "mode": "time",
  1379. "name": null,
  1380. "show": true,
  1381. "values": []
  1382. },
  1383. "yaxes": [
  1384. {
  1385. "format": "short",
  1386. "label": "",
  1387. "logBase": 1,
  1388. "max": null,
  1389. "min": null,
  1390. "show": true
  1391. },
  1392. {
  1393. "format": "short",
  1394. "label": null,
  1395. "logBase": 1,
  1396. "max": null,
  1397. "min": null,
  1398. "show": true
  1399. }
  1400. ],
  1401. "yaxis": {
  1402. "align": false,
  1403. "alignLevel": null
  1404. }
  1405. },
  1406. {
  1407. "aliasColors": {},
  1408. "bars": false,
  1409. "dashLength": 10,
  1410. "dashes": false,
  1411. "datasource": "Prometheus",
  1412. "fill": 1,
  1413. "gridPos": {
  1414. "h": 5,
  1415. "w": 8,
  1416. "x": 16,
  1417. "y": 21
  1418. },
  1419. "id": 37,
  1420. "legend": {
  1421. "avg": false,
  1422. "current": false,
  1423. "max": false,
  1424. "min": false,
  1425. "show": true,
  1426. "total": false,
  1427. "values": false
  1428. },
  1429. "lines": true,
  1430. "linewidth": 1,
  1431. "links": [],
  1432. "nullPointMode": "null",
  1433. "percentage": false,
  1434. "pointradius": 5,
  1435. "points": false,
  1436. "renderer": "flot",
  1437. "seriesOverrides": [],
  1438. "spaceLength": 10,
  1439. "stack": false,
  1440. "steppedLine": false,
  1441. "targets": [
  1442. {
  1443. "expr": "max(system_load_average_1m{instance=~'$instance'})",
  1444. "format": "time_series",
  1445. "intervalFactor": 1,
  1446. "refId": "A"
  1447. }
  1448. ],
  1449. "thresholds": [],
  1450. "timeFrom": null,
  1451. "timeRegions": [],
  1452. "timeShift": null,
  1453. "title": "load 1m",
  1454. "tooltip": {
  1455. "shared": true,
  1456. "sort": 0,
  1457. "value_type": "individual"
  1458. },
  1459. "type": "graph",
  1460. "xaxis": {
  1461. "buckets": null,
  1462. "mode": "time",
  1463. "name": null,
  1464. "show": true,
  1465. "values": []
  1466. },
  1467. "yaxes": [
  1468. {
  1469. "format": "short",
  1470. "label": null,
  1471. "logBase": 1,
  1472. "max": null,
  1473. "min": null,
  1474. "show": true
  1475. },
  1476. {
  1477. "format": "short",
  1478. "label": null,
  1479. "logBase": 1,
  1480. "max": null,
  1481. "min": null,
  1482. "show": true
  1483. }
  1484. ],
  1485. "yaxis": {
  1486. "align": false,
  1487. "alignLevel": null
  1488. }
  1489. },
  1490. {
  1491. "aliasColors": {},
  1492. "bars": false,
  1493. "dashLength": 10,
  1494. "dashes": false,
  1495. "datasource": "Prometheus",
  1496. "fill": 1,
  1497. "gridPos": {
  1498. "h": 5,
  1499. "w": 8,
  1500. "x": 0,
  1501. "y": 26
  1502. },
  1503. "id": 18,
  1504. "legend": {
  1505. "avg": false,
  1506. "current": false,
  1507. "max": false,
  1508. "min": false,
  1509. "show": true,
  1510. "total": false,
  1511. "values": false
  1512. },
  1513. "lines": true,
  1514. "linewidth": 1,
  1515. "links": [],
  1516. "nullPointMode": "null",
  1517. "percentage": false,
  1518. "pointradius": 5,
  1519. "points": false,
  1520. "renderer": "flot",
  1521. "seriesOverrides": [],
  1522. "spaceLength": 10,
  1523. "stack": false,
  1524. "steppedLine": false,
  1525. "targets": [
  1526. {
  1527. "expr": "sum(rate(http_server_requests_seconds_count{uri=~'/v1/cs/configs|/nacos/v1/ns/instance|/nacos/v1/ns/health', instance=~'$instance'}[1m])) by (method,uri)",
  1528. "format": "time_series",
  1529. "intervalFactor": 1,
  1530. "refId": "A"
  1531. },
  1532. {
  1533. "expr": "sum(rate(http_server_requests_seconds_count[1m]))",
  1534. "format": "time_series",
  1535. "intervalFactor": 1,
  1536. "refId": "B"
  1537. }
  1538. ],
  1539. "thresholds": [],
  1540. "timeFrom": null,
  1541. "timeRegions": [],
  1542. "timeShift": null,
  1543. "title": "qps",
  1544. "tooltip": {
  1545. "shared": true,
  1546. "sort": 0,
  1547. "value_type": "individual"
  1548. },
  1549. "transparent": false,
  1550. "type": "graph",
  1551. "xaxis": {
  1552. "buckets": null,
  1553. "mode": "time",
  1554. "name": null,
  1555. "show": true,
  1556. "values": []
  1557. },
  1558. "yaxes": [
  1559. {
  1560. "format": "short",
  1561. "label": null,
  1562. "logBase": 1,
  1563. "max": null,
  1564. "min": null,
  1565. "show": true
  1566. },
  1567. {
  1568. "format": "short",
  1569. "label": null,
  1570. "logBase": 1,
  1571. "max": null,
  1572. "min": null,
  1573. "show": true
  1574. }
  1575. ],
  1576. "yaxis": {
  1577. "align": false,
  1578. "alignLevel": null
  1579. }
  1580. },
  1581. {
  1582. "aliasColors": {},
  1583. "bars": false,
  1584. "dashLength": 10,
  1585. "dashes": false,
  1586. "datasource": "Prometheus",
  1587. "fill": 1,
  1588. "gridPos": {
  1589. "h": 5,
  1590. "w": 8,
  1591. "x": 8,
  1592. "y": 26
  1593. },
  1594. "id": 52,
  1595. "legend": {
  1596. "avg": false,
  1597. "current": false,
  1598. "max": false,
  1599. "min": false,
  1600. "show": true,
  1601. "total": false,
  1602. "values": false
  1603. },
  1604. "lines": true,
  1605. "linewidth": 1,
  1606. "links": [],
  1607. "nullPointMode": "null",
  1608. "percentage": false,
  1609. "pointradius": 5,
  1610. "points": false,
  1611. "renderer": "flot",
  1612. "seriesOverrides": [],
  1613. "spaceLength": 10,
  1614. "stack": false,
  1615. "steppedLine": false,
  1616. "targets": [
  1617. {
  1618. "expr": "sum(nacos_monitor{name='leaderStatus', instance=~'$instance'})",
  1619. "format": "time_series",
  1620. "intervalFactor": 1,
  1621. "refId": "B"
  1622. }
  1623. ],
  1624. "thresholds": [],
  1625. "timeFrom": null,
  1626. "timeRegions": [],
  1627. "timeShift": null,
  1628. "title": "leaderStatus",
  1629. "tooltip": {
  1630. "shared": true,
  1631. "sort": 0,
  1632. "value_type": "individual"
  1633. },
  1634. "type": "graph",
  1635. "xaxis": {
  1636. "buckets": null,
  1637. "mode": "time",
  1638. "name": null,
  1639. "show": true,
  1640. "values": []
  1641. },
  1642. "yaxes": [
  1643. {
  1644. "format": "short",
  1645. "label": null,
  1646. "logBase": 1,
  1647. "max": null,
  1648. "min": null,
  1649. "show": true
  1650. },
  1651. {
  1652. "format": "short",
  1653. "label": null,
  1654. "logBase": 1,
  1655. "max": null,
  1656. "min": null,
  1657. "show": true
  1658. }
  1659. ],
  1660. "yaxis": {
  1661. "align": false,
  1662. "alignLevel": null
  1663. }
  1664. },
  1665. {
  1666. "aliasColors": {},
  1667. "bars": false,
  1668. "dashLength": 10,
  1669. "dashes": false,
  1670. "datasource": "Prometheus",
  1671. "fill": 1,
  1672. "gridPos": {
  1673. "h": 5,
  1674. "w": 8,
  1675. "x": 16,
  1676. "y": 26
  1677. },
  1678. "id": 50,
  1679. "legend": {
  1680. "avg": false,
  1681. "current": false,
  1682. "max": false,
  1683. "min": false,
  1684. "show": true,
  1685. "total": false,
  1686. "values": false
  1687. },
  1688. "lines": true,
  1689. "linewidth": 1,
  1690. "links": [],
  1691. "nullPointMode": "null",
  1692. "percentage": false,
  1693. "pointradius": 5,
  1694. "points": false,
  1695. "renderer": "flot",
  1696. "seriesOverrides": [],
  1697. "spaceLength": 10,
  1698. "stack": false,
  1699. "steppedLine": false,
  1700. "targets": [
  1701. {
  1702. "expr": "sum(nacos_monitor{name='avgPushCost', instance=~'$instance'})",
  1703. "format": "time_series",
  1704. "intervalFactor": 1,
  1705. "refId": "A"
  1706. }
  1707. ],
  1708. "thresholds": [],
  1709. "timeFrom": null,
  1710. "timeRegions": [],
  1711. "timeShift": null,
  1712. "title": "avgPushCost",
  1713. "tooltip": {
  1714. "shared": true,
  1715. "sort": 0,
  1716. "value_type": "individual"
  1717. },
  1718. "type": "graph",
  1719. "xaxis": {
  1720. "buckets": null,
  1721. "mode": "time",
  1722. "name": null,
  1723. "show": true,
  1724. "values": []
  1725. },
  1726. "yaxes": [
  1727. {
  1728. "format": "short",
  1729. "label": null,
  1730. "logBase": 1,
  1731. "max": null,
  1732. "min": null,
  1733. "show": true
  1734. },
  1735. {
  1736. "format": "short",
  1737. "label": null,
  1738. "logBase": 1,
  1739. "max": null,
  1740. "min": null,
  1741. "show": true
  1742. }
  1743. ],
  1744. "yaxis": {
  1745. "align": false,
  1746. "alignLevel": null
  1747. }
  1748. },
  1749. {
  1750. "aliasColors": {},
  1751. "bars": false,
  1752. "dashLength": 10,
  1753. "dashes": false,
  1754. "datasource": "Prometheus",
  1755. "fill": 1,
  1756. "gridPos": {
  1757. "h": 5,
  1758. "w": 8,
  1759. "x": 0,
  1760. "y": 31
  1761. },
  1762. "id": 53,
  1763. "legend": {
  1764. "avg": false,
  1765. "current": false,
  1766. "max": false,
  1767. "min": false,
  1768. "show": true,
  1769. "total": false,
  1770. "values": false
  1771. },
  1772. "lines": true,
  1773. "linewidth": 1,
  1774. "links": [],
  1775. "nullPointMode": "null",
  1776. "percentage": false,
  1777. "pointradius": 5,
  1778. "points": false,
  1779. "renderer": "flot",
  1780. "seriesOverrides": [],
  1781. "spaceLength": 10,
  1782. "stack": false,
  1783. "steppedLine": false,
  1784. "targets": [
  1785. {
  1786. "expr": "max(nacos_monitor{name='maxPushCost', instance=~'$instance'})",
  1787. "format": "time_series",
  1788. "intervalFactor": 1,
  1789. "refId": "A"
  1790. }
  1791. ],
  1792. "thresholds": [],
  1793. "timeFrom": null,
  1794. "timeRegions": [],
  1795. "timeShift": null,
  1796. "title": "maxPushCost",
  1797. "tooltip": {
  1798. "shared": true,
  1799. "sort": 0,
  1800. "value_type": "individual"
  1801. },
  1802. "type": "graph",
  1803. "xaxis": {
  1804. "buckets": null,
  1805. "mode": "time",
  1806. "name": null,
  1807. "show": true,
  1808. "values": []
  1809. },
  1810. "yaxes": [
  1811. {
  1812. "format": "short",
  1813. "label": null,
  1814. "logBase": 1,
  1815. "max": null,
  1816. "min": null,
  1817. "show": true
  1818. },
  1819. {
  1820. "format": "short",
  1821. "label": null,
  1822. "logBase": 1,
  1823. "max": null,
  1824. "min": null,
  1825. "show": true
  1826. }
  1827. ],
  1828. "yaxis": {
  1829. "align": false,
  1830. "alignLevel": null
  1831. }
  1832. },
  1833. {
  1834. "aliasColors": {},
  1835. "bars": false,
  1836. "dashLength": 10,
  1837. "dashes": false,
  1838. "datasource": "Prometheus",
  1839. "fill": 1,
  1840. "gridPos": {
  1841. "h": 5,
  1842. "w": 8,
  1843. "x": 8,
  1844. "y": 31
  1845. },
  1846. "id": 83,
  1847. "legend": {
  1848. "avg": false,
  1849. "current": false,
  1850. "max": false,
  1851. "min": false,
  1852. "show": true,
  1853. "total": false,
  1854. "values": false
  1855. },
  1856. "lines": true,
  1857. "linewidth": 1,
  1858. "links": [],
  1859. "nullPointMode": "null",
  1860. "percentage": false,
  1861. "pointradius": 5,
  1862. "points": false,
  1863. "renderer": "flot",
  1864. "seriesOverrides": [],
  1865. "spaceLength": 10,
  1866. "stack": false,
  1867. "steppedLine": false,
  1868. "targets": [
  1869. {
  1870. "expr": "sum(nacos_monitor{name='publish', instance=~'$instance'}) by (name)",
  1871. "format": "time_series",
  1872. "intervalFactor": 1,
  1873. "legendFormat": "publish config",
  1874. "refId": "A"
  1875. },
  1876. {
  1877. "expr": "sum(nacos_monitor{name='getConfig', instance=~'$instance'}) by (name)",
  1878. "format": "time_series",
  1879. "intervalFactor": 1,
  1880. "legendFormat": "get config",
  1881. "refId": "B"
  1882. }
  1883. ],
  1884. "thresholds": [],
  1885. "timeFrom": null,
  1886. "timeRegions": [],
  1887. "timeShift": null,
  1888. "title": "config statistics",
  1889. "tooltip": {
  1890. "shared": true,
  1891. "sort": 0,
  1892. "value_type": "individual"
  1893. },
  1894. "type": "graph",
  1895. "xaxis": {
  1896. "buckets": null,
  1897. "mode": "time",
  1898. "name": null,
  1899. "show": true,
  1900. "values": []
  1901. },
  1902. "yaxes": [
  1903. {
  1904. "format": "short",
  1905. "label": null,
  1906. "logBase": 1,
  1907. "max": null,
  1908. "min": null,
  1909. "show": true
  1910. },
  1911. {
  1912. "format": "short",
  1913. "label": null,
  1914. "logBase": 1,
  1915. "max": null,
  1916. "min": null,
  1917. "show": true
  1918. }
  1919. ],
  1920. "yaxis": {
  1921. "align": false,
  1922. "alignLevel": null
  1923. }
  1924. },
  1925. {
  1926. "aliasColors": {},
  1927. "bars": false,
  1928. "dashLength": 10,
  1929. "dashes": false,
  1930. "datasource": "Prometheus",
  1931. "fill": 1,
  1932. "gridPos": {
  1933. "h": 5,
  1934. "w": 8,
  1935. "x": 16,
  1936. "y": 31
  1937. },
  1938. "id": 16,
  1939. "legend": {
  1940. "avg": false,
  1941. "current": false,
  1942. "max": false,
  1943. "min": false,
  1944. "show": true,
  1945. "total": false,
  1946. "values": false
  1947. },
  1948. "lines": true,
  1949. "linewidth": 1,
  1950. "links": [],
  1951. "nullPointMode": "null",
  1952. "percentage": false,
  1953. "pointradius": 5,
  1954. "points": false,
  1955. "renderer": "flot",
  1956. "seriesOverrides": [],
  1957. "spaceLength": 10,
  1958. "stack": false,
  1959. "steppedLine": false,
  1960. "targets": [
  1961. {
  1962. "expr": "sum(rate(nacos_monitor{name=~'.*HealthCheck', instance=~'$instance'}[1m])) by (name) * 60",
  1963. "format": "time_series",
  1964. "intervalFactor": 1,
  1965. "legendFormat": "",
  1966. "refId": "A"
  1967. }
  1968. ],
  1969. "thresholds": [],
  1970. "timeFrom": null,
  1971. "timeRegions": [],
  1972. "timeShift": null,
  1973. "title": "health check",
  1974. "tooltip": {
  1975. "shared": true,
  1976. "sort": 0,
  1977. "value_type": "individual"
  1978. },
  1979. "type": "graph",
  1980. "xaxis": {
  1981. "buckets": null,
  1982. "mode": "time",
  1983. "name": null,
  1984. "show": true,
  1985. "values": []
  1986. },
  1987. "yaxes": [
  1988. {
  1989. "format": "short",
  1990. "label": null,
  1991. "logBase": 1,
  1992. "max": null,
  1993. "min": null,
  1994. "show": true
  1995. },
  1996. {
  1997. "format": "short",
  1998. "label": null,
  1999. "logBase": 1,
  2000. "max": null,
  2001. "min": null,
  2002. "show": true
  2003. }
  2004. ],
  2005. "yaxis": {
  2006. "align": false,
  2007. "alignLevel": null
  2008. }
  2009. },
  2010. {
  2011. "collapsed": false,
  2012. "gridPos": {
  2013. "h": 1,
  2014. "w": 24,
  2015. "x": 0,
  2016. "y": 36
  2017. },
  2018. "id": 74,
  2019. "panels": [],
  2020. "title": "nacos alert",
  2021. "type": "row"
  2022. },
  2023. {
  2024. "alert": {
  2025. "conditions": [
  2026. {
  2027. "evaluator": {
  2028. "params": [
  2029. 50
  2030. ],
  2031. "type": "gt"
  2032. },
  2033. "operator": {
  2034. "type": "and"
  2035. },
  2036. "query": {
  2037. "params": [
  2038. "A",
  2039. "1m",
  2040. "now"
  2041. ]
  2042. },
  2043. "reducer": {
  2044. "params": [],
  2045. "type": "avg"
  2046. },
  2047. "type": "query"
  2048. }
  2049. ],
  2050. "executionErrorState": "keep_state",
  2051. "for": "1m",
  2052. "frequency": "1m",
  2053. "handler": 1,
  2054. "name": "cpu alert",
  2055. "noDataState": "ok",
  2056. "notifications": [
  2057. {
  2058. "id": 1
  2059. }
  2060. ]
  2061. },
  2062. "aliasColors": {},
  2063. "bars": false,
  2064. "dashLength": 10,
  2065. "dashes": false,
  2066. "datasource": "Prometheus",
  2067. "fill": 1,
  2068. "gridPos": {
  2069. "h": 5,
  2070. "w": 8,
  2071. "x": 0,
  2072. "y": 37
  2073. },
  2074. "id": 45,
  2075. "legend": {
  2076. "avg": false,
  2077. "current": false,
  2078. "max": false,
  2079. "min": false,
  2080. "show": true,
  2081. "total": false,
  2082. "values": false
  2083. },
  2084. "lines": true,
  2085. "linewidth": 1,
  2086. "links": [],
  2087. "nullPointMode": "null",
  2088. "percentage": false,
  2089. "pointradius": 5,
  2090. "points": false,
  2091. "renderer": "flot",
  2092. "seriesOverrides": [],
  2093. "spaceLength": 10,
  2094. "stack": false,
  2095. "steppedLine": false,
  2096. "targets": [
  2097. {
  2098. "expr": "max(system_cpu_usage) * 100",
  2099. "format": "time_series",
  2100. "intervalFactor": 1,
  2101. "refId": "A"
  2102. }
  2103. ],
  2104. "thresholds": [
  2105. {
  2106. "colorMode": "critical",
  2107. "fill": true,
  2108. "line": true,
  2109. "op": "gt",
  2110. "value": 50
  2111. }
  2112. ],
  2113. "timeFrom": null,
  2114. "timeRegions": [],
  2115. "timeShift": null,
  2116. "title": "cpu alert",
  2117. "tooltip": {
  2118. "shared": true,
  2119. "sort": 0,
  2120. "value_type": "individual"
  2121. },
  2122. "type": "graph",
  2123. "xaxis": {
  2124. "buckets": null,
  2125. "mode": "time",
  2126. "name": null,
  2127. "show": true,
  2128. "values": []
  2129. },
  2130. "yaxes": [
  2131. {
  2132. "format": "short",
  2133. "label": null,
  2134. "logBase": 1,
  2135. "max": null,
  2136. "min": null,
  2137. "show": true
  2138. },
  2139. {
  2140. "format": "short",
  2141. "label": null,
  2142. "logBase": 1,
  2143. "max": null,
  2144. "min": null,
  2145. "show": true
  2146. }
  2147. ],
  2148. "yaxis": {
  2149. "align": false,
  2150. "alignLevel": null
  2151. }
  2152. },
  2153. {
  2154. "alert": {
  2155. "conditions": [
  2156. {
  2157. "evaluator": {
  2158. "params": [
  2159. 15
  2160. ],
  2161. "type": "gt"
  2162. },
  2163. "operator": {
  2164. "type": "and"
  2165. },
  2166. "query": {
  2167. "params": [
  2168. "A",
  2169. "1m",
  2170. "now"
  2171. ]
  2172. },
  2173. "reducer": {
  2174. "params": [],
  2175. "type": "avg"
  2176. },
  2177. "type": "query"
  2178. }
  2179. ],
  2180. "executionErrorState": "keep_state",
  2181. "frequency": "60s",
  2182. "handler": 1,
  2183. "name": "load 1m alert",
  2184. "noDataState": "ok",
  2185. "notifications": []
  2186. },
  2187. "aliasColors": {},
  2188. "bars": false,
  2189. "dashLength": 10,
  2190. "dashes": false,
  2191. "datasource": "Prometheus",
  2192. "fill": 1,
  2193. "gridPos": {
  2194. "h": 5,
  2195. "w": 8,
  2196. "x": 8,
  2197. "y": 37
  2198. },
  2199. "id": 86,
  2200. "legend": {
  2201. "avg": false,
  2202. "current": false,
  2203. "max": false,
  2204. "min": false,
  2205. "show": true,
  2206. "total": false,
  2207. "values": false
  2208. },
  2209. "lines": true,
  2210. "linewidth": 1,
  2211. "links": [],
  2212. "nullPointMode": "null",
  2213. "percentage": false,
  2214. "pointradius": 5,
  2215. "points": false,
  2216. "renderer": "flot",
  2217. "seriesOverrides": [],
  2218. "spaceLength": 10,
  2219. "stack": false,
  2220. "steppedLine": false,
  2221. "targets": [
  2222. {
  2223. "expr": "max(system_load_average_1m)",
  2224. "format": "time_series",
  2225. "intervalFactor": 1,
  2226. "refId": "A"
  2227. }
  2228. ],
  2229. "thresholds": [
  2230. {
  2231. "colorMode": "critical",
  2232. "fill": true,
  2233. "line": true,
  2234. "op": "gt",
  2235. "value": 15
  2236. }
  2237. ],
  2238. "timeFrom": null,
  2239. "timeRegions": [],
  2240. "timeShift": null,
  2241. "title": "load alert",
  2242. "tooltip": {
  2243. "shared": true,
  2244. "sort": 0,
  2245. "value_type": "individual"
  2246. },
  2247. "type": "graph",
  2248. "xaxis": {
  2249. "buckets": null,
  2250. "mode": "time",
  2251. "name": null,
  2252. "show": true,
  2253. "values": []
  2254. },
  2255. "yaxes": [
  2256. {
  2257. "format": "short",
  2258. "label": null,
  2259. "logBase": 1,
  2260. "max": null,
  2261. "min": null,
  2262. "show": true
  2263. },
  2264. {
  2265. "format": "short",
  2266. "label": null,
  2267. "logBase": 1,
  2268. "max": null,
  2269. "min": null,
  2270. "show": true
  2271. }
  2272. ],
  2273. "yaxis": {
  2274. "align": false,
  2275. "alignLevel": null
  2276. }
  2277. },
  2278. {
  2279. "alert": {
  2280. "conditions": [
  2281. {
  2282. "evaluator": {
  2283. "params": [
  2284. 60
  2285. ],
  2286. "type": "gt"
  2287. },
  2288. "operator": {
  2289. "type": "and"
  2290. },
  2291. "query": {
  2292. "params": [
  2293. "A",
  2294. "5m",
  2295. "now"
  2296. ]
  2297. },
  2298. "reducer": {
  2299. "params": [],
  2300. "type": "avg"
  2301. },
  2302. "type": "query"
  2303. }
  2304. ],
  2305. "executionErrorState": "keep_state",
  2306. "frequency": "60s",
  2307. "handler": 1,
  2308. "name": "memory alert",
  2309. "noDataState": "ok",
  2310. "notifications": []
  2311. },
  2312. "aliasColors": {},
  2313. "bars": false,
  2314. "dashLength": 10,
  2315. "dashes": false,
  2316. "datasource": "Prometheus",
  2317. "fill": 1,
  2318. "gridPos": {
  2319. "h": 5,
  2320. "w": 8,
  2321. "x": 16,
  2322. "y": 37
  2323. },
  2324. "id": 46,
  2325. "legend": {
  2326. "avg": false,
  2327. "current": false,
  2328. "max": false,
  2329. "min": false,
  2330. "show": true,
  2331. "total": false,
  2332. "values": false
  2333. },
  2334. "lines": true,
  2335. "linewidth": 1,
  2336. "links": [],
  2337. "nullPointMode": "null",
  2338. "percentage": false,
  2339. "pointradius": 5,
  2340. "points": false,
  2341. "renderer": "flot",
  2342. "seriesOverrides": [],
  2343. "spaceLength": 10,
  2344. "stack": false,
  2345. "steppedLine": false,
  2346. "targets": [
  2347. {
  2348. "expr": "sum(jvm_memory_used_bytes{area=\"heap\"})/sum(jvm_memory_max_bytes{area=\"heap\"}) * 100",
  2349. "format": "time_series",
  2350. "intervalFactor": 1,
  2351. "refId": "A"
  2352. }
  2353. ],
  2354. "thresholds": [
  2355. {
  2356. "colorMode": "critical",
  2357. "fill": true,
  2358. "line": true,
  2359. "op": "gt",
  2360. "value": 60
  2361. }
  2362. ],
  2363. "timeFrom": null,
  2364. "timeRegions": [],
  2365. "timeShift": null,
  2366. "title": "memory alert",
  2367. "tooltip": {
  2368. "shared": true,
  2369. "sort": 0,
  2370. "value_type": "individual"
  2371. },
  2372. "type": "graph",
  2373. "xaxis": {
  2374. "buckets": null,
  2375. "mode": "time",
  2376. "name": null,
  2377. "show": true,
  2378. "values": []
  2379. },
  2380. "yaxes": [
  2381. {
  2382. "format": "short",
  2383. "label": null,
  2384. "logBase": 1,
  2385. "max": null,
  2386. "min": null,
  2387. "show": true
  2388. },
  2389. {
  2390. "format": "short",
  2391. "label": null,
  2392. "logBase": 1,
  2393. "max": null,
  2394. "min": null,
  2395. "show": true
  2396. }
  2397. ],
  2398. "yaxis": {
  2399. "align": false,
  2400. "alignLevel": null
  2401. }
  2402. },
  2403. {
  2404. "alert": {
  2405. "conditions": [
  2406. {
  2407. "evaluator": {
  2408. "params": [
  2409. 500
  2410. ],
  2411. "type": "gt"
  2412. },
  2413. "operator": {
  2414. "type": "and"
  2415. },
  2416. "query": {
  2417. "params": [
  2418. "A",
  2419. "1m",
  2420. "now"
  2421. ]
  2422. },
  2423. "reducer": {
  2424. "params": [],
  2425. "type": "avg"
  2426. },
  2427. "type": "query"
  2428. }
  2429. ],
  2430. "executionErrorState": "keep_state",
  2431. "frequency": "60s",
  2432. "handler": 1,
  2433. "name": "threads alert",
  2434. "noDataState": "ok",
  2435. "notifications": []
  2436. },
  2437. "aliasColors": {},
  2438. "bars": false,
  2439. "dashLength": 10,
  2440. "dashes": false,
  2441. "datasource": "Prometheus",
  2442. "fill": 1,
  2443. "gridPos": {
  2444. "h": 5,
  2445. "w": 8,
  2446. "x": 0,
  2447. "y": 42
  2448. },
  2449. "id": 39,
  2450. "legend": {
  2451. "avg": false,
  2452. "current": false,
  2453. "max": false,
  2454. "min": false,
  2455. "show": true,
  2456. "total": false,
  2457. "values": false
  2458. },
  2459. "lines": true,
  2460. "linewidth": 1,
  2461. "links": [],
  2462. "nullPointMode": "null",
  2463. "percentage": false,
  2464. "pointradius": 5,
  2465. "points": false,
  2466. "renderer": "flot",
  2467. "seriesOverrides": [],
  2468. "spaceLength": 10,
  2469. "stack": false,
  2470. "steppedLine": false,
  2471. "targets": [
  2472. {
  2473. "expr": "max(jvm_threads_daemon_threads)",
  2474. "format": "time_series",
  2475. "intervalFactor": 1,
  2476. "refId": "A"
  2477. }
  2478. ],
  2479. "thresholds": [
  2480. {
  2481. "colorMode": "critical",
  2482. "fill": true,
  2483. "line": true,
  2484. "op": "gt",
  2485. "value": 500
  2486. }
  2487. ],
  2488. "timeFrom": null,
  2489. "timeRegions": [],
  2490. "timeShift": null,
  2491. "title": "threads alert",
  2492. "tooltip": {
  2493. "shared": true,
  2494. "sort": 0,
  2495. "value_type": "individual"
  2496. },
  2497. "type": "graph",
  2498. "xaxis": {
  2499. "buckets": null,
  2500. "mode": "time",
  2501. "name": null,
  2502. "show": true,
  2503. "values": []
  2504. },
  2505. "yaxes": [
  2506. {
  2507. "format": "short",
  2508. "label": null,
  2509. "logBase": 1,
  2510. "max": null,
  2511. "min": null,
  2512. "show": true
  2513. },
  2514. {
  2515. "format": "short",
  2516. "label": null,
  2517. "logBase": 1,
  2518. "max": null,
  2519. "min": null,
  2520. "show": true
  2521. }
  2522. ],
  2523. "yaxis": {
  2524. "align": false,
  2525. "alignLevel": null
  2526. }
  2527. },
  2528. {
  2529. "alert": {
  2530. "conditions": [
  2531. {
  2532. "evaluator": {
  2533. "params": [
  2534. 5
  2535. ],
  2536. "type": "gt"
  2537. },
  2538. "operator": {
  2539. "type": "and"
  2540. },
  2541. "query": {
  2542. "params": [
  2543. "A",
  2544. "1m",
  2545. "now"
  2546. ]
  2547. },
  2548. "reducer": {
  2549. "params": [],
  2550. "type": "avg"
  2551. },
  2552. "type": "query"
  2553. }
  2554. ],
  2555. "executionErrorState": "keep_state",
  2556. "for": "1m",
  2557. "frequency": "1m",
  2558. "handler": 1,
  2559. "message": "too many full gc",
  2560. "name": "gc alert",
  2561. "noDataState": "ok",
  2562. "notifications": [
  2563. {
  2564. "id": 1
  2565. }
  2566. ]
  2567. },
  2568. "aliasColors": {},
  2569. "bars": false,
  2570. "dashLength": 10,
  2571. "dashes": false,
  2572. "datasource": "Prometheus",
  2573. "fill": 1,
  2574. "gridPos": {
  2575. "h": 5,
  2576. "w": 8,
  2577. "x": 8,
  2578. "y": 42
  2579. },
  2580. "id": 38,
  2581. "legend": {
  2582. "avg": false,
  2583. "current": false,
  2584. "max": false,
  2585. "min": false,
  2586. "show": true,
  2587. "total": false,
  2588. "values": false
  2589. },
  2590. "lines": true,
  2591. "linewidth": 1,
  2592. "links": [],
  2593. "nullPointMode": "null",
  2594. "percentage": false,
  2595. "pointradius": 5,
  2596. "points": false,
  2597. "renderer": "flot",
  2598. "seriesOverrides": [],
  2599. "spaceLength": 10,
  2600. "stack": false,
  2601. "steppedLine": false,
  2602. "targets": [
  2603. {
  2604. "expr": "max(rate(jvm_gc_pause_seconds_count{action=\"end of major GC\"}[5m])) * 300",
  2605. "format": "time_series",
  2606. "intervalFactor": 1,
  2607. "refId": "A"
  2608. }
  2609. ],
  2610. "thresholds": [
  2611. {
  2612. "colorMode": "critical",
  2613. "fill": true,
  2614. "line": true,
  2615. "op": "gt",
  2616. "value": 5
  2617. }
  2618. ],
  2619. "timeFrom": null,
  2620. "timeRegions": [],
  2621. "timeShift": null,
  2622. "title": "gc alert",
  2623. "tooltip": {
  2624. "shared": true,
  2625. "sort": 0,
  2626. "value_type": "individual"
  2627. },
  2628. "type": "graph",
  2629. "xaxis": {
  2630. "buckets": null,
  2631. "mode": "time",
  2632. "name": null,
  2633. "show": true,
  2634. "values": []
  2635. },
  2636. "yaxes": [
  2637. {
  2638. "format": "short",
  2639. "label": null,
  2640. "logBase": 1,
  2641. "max": null,
  2642. "min": null,
  2643. "show": true
  2644. },
  2645. {
  2646. "format": "short",
  2647. "label": null,
  2648. "logBase": 1,
  2649. "max": null,
  2650. "min": null,
  2651. "show": true
  2652. }
  2653. ],
  2654. "yaxis": {
  2655. "align": false,
  2656. "alignLevel": null
  2657. }
  2658. },
  2659. {
  2660. "alert": {
  2661. "conditions": [
  2662. {
  2663. "evaluator": {
  2664. "params": [
  2665. 10
  2666. ],
  2667. "type": "gt"
  2668. },
  2669. "operator": {
  2670. "type": "and"
  2671. },
  2672. "query": {
  2673. "params": [
  2674. "A",
  2675. "1m",
  2676. "now"
  2677. ]
  2678. },
  2679. "reducer": {
  2680. "params": [],
  2681. "type": "avg"
  2682. },
  2683. "type": "query"
  2684. }
  2685. ],
  2686. "executionErrorState": "keep_state",
  2687. "frequency": "60s",
  2688. "handler": 1,
  2689. "name": "notify task alert",
  2690. "noDataState": "ok",
  2691. "notifications": []
  2692. },
  2693. "aliasColors": {},
  2694. "bars": false,
  2695. "dashLength": 10,
  2696. "dashes": false,
  2697. "datasource": "Prometheus",
  2698. "fill": 1,
  2699. "gridPos": {
  2700. "h": 5,
  2701. "w": 8,
  2702. "x": 16,
  2703. "y": 42
  2704. },
  2705. "id": 49,
  2706. "legend": {
  2707. "avg": false,
  2708. "current": false,
  2709. "max": false,
  2710. "min": false,
  2711. "show": true,
  2712. "total": false,
  2713. "values": false
  2714. },
  2715. "lines": true,
  2716. "linewidth": 1,
  2717. "links": [],
  2718. "nullPointMode": "null",
  2719. "percentage": false,
  2720. "pointradius": 5,
  2721. "points": false,
  2722. "renderer": "flot",
  2723. "seriesOverrides": [],
  2724. "spaceLength": 10,
  2725. "stack": false,
  2726. "steppedLine": false,
  2727. "targets": [
  2728. {
  2729. "expr": "sum(nacos_monitor{name='notifyTask'})",
  2730. "format": "time_series",
  2731. "intervalFactor": 1,
  2732. "refId": "A"
  2733. }
  2734. ],
  2735. "thresholds": [
  2736. {
  2737. "colorMode": "critical",
  2738. "fill": true,
  2739. "line": true,
  2740. "op": "gt",
  2741. "value": 10
  2742. }
  2743. ],
  2744. "timeFrom": null,
  2745. "timeRegions": [],
  2746. "timeShift": null,
  2747. "title": "notify task alert",
  2748. "tooltip": {
  2749. "shared": true,
  2750. "sort": 0,
  2751. "value_type": "individual"
  2752. },
  2753. "type": "graph",
  2754. "xaxis": {
  2755. "buckets": null,
  2756. "mode": "time",
  2757. "name": null,
  2758. "show": true,
  2759. "values": []
  2760. },
  2761. "yaxes": [
  2762. {
  2763. "format": "short",
  2764. "label": null,
  2765. "logBase": 1,
  2766. "max": null,
  2767. "min": null,
  2768. "show": true
  2769. },
  2770. {
  2771. "format": "short",
  2772. "label": null,
  2773. "logBase": 1,
  2774. "max": null,
  2775. "min": null,
  2776. "show": true
  2777. }
  2778. ],
  2779. "yaxis": {
  2780. "align": false,
  2781. "alignLevel": null
  2782. }
  2783. },
  2784. {
  2785. "alert": {
  2786. "conditions": [
  2787. {
  2788. "evaluator": {
  2789. "params": [
  2790. 5000
  2791. ],
  2792. "type": "gt"
  2793. },
  2794. "operator": {
  2795. "type": "and"
  2796. },
  2797. "query": {
  2798. "params": [
  2799. "B",
  2800. "1m",
  2801. "now"
  2802. ]
  2803. },
  2804. "reducer": {
  2805. "params": [],
  2806. "type": "avg"
  2807. },
  2808. "type": "query"
  2809. }
  2810. ],
  2811. "executionErrorState": "keep_state",
  2812. "frequency": "60s",
  2813. "handler": 1,
  2814. "name": "rt alert",
  2815. "noDataState": "ok",
  2816. "notifications": []
  2817. },
  2818. "aliasColors": {},
  2819. "bars": false,
  2820. "dashLength": 10,
  2821. "dashes": false,
  2822. "datasource": "Prometheus",
  2823. "fill": 1,
  2824. "gridPos": {
  2825. "h": 5,
  2826. "w": 8,
  2827. "x": 0,
  2828. "y": 47
  2829. },
  2830. "id": 85,
  2831. "legend": {
  2832. "avg": false,
  2833. "current": false,
  2834. "max": false,
  2835. "min": false,
  2836. "show": true,
  2837. "total": false,
  2838. "values": false
  2839. },
  2840. "lines": true,
  2841. "linewidth": 1,
  2842. "links": [],
  2843. "nullPointMode": "null",
  2844. "percentage": false,
  2845. "pointradius": 5,
  2846. "points": false,
  2847. "renderer": "flot",
  2848. "seriesOverrides": [],
  2849. "spaceLength": 10,
  2850. "stack": false,
  2851. "steppedLine": false,
  2852. "targets": [
  2853. {
  2854. "expr": "sum(rate(http_server_requests_seconds_sum[1m]))/sum(rate(http_server_requests_seconds_count[1m])) * 1000",
  2855. "format": "time_series",
  2856. "hide": false,
  2857. "intervalFactor": 1,
  2858. "refId": "B"
  2859. }
  2860. ],
  2861. "thresholds": [
  2862. {
  2863. "colorMode": "critical",
  2864. "fill": true,
  2865. "line": true,
  2866. "op": "gt",
  2867. "value": 5000
  2868. }
  2869. ],
  2870. "timeFrom": null,
  2871. "timeRegions": [],
  2872. "timeShift": null,
  2873. "title": "rt alert",
  2874. "tooltip": {
  2875. "shared": true,
  2876. "sort": 0,
  2877. "value_type": "individual"
  2878. },
  2879. "type": "graph",
  2880. "xaxis": {
  2881. "buckets": null,
  2882. "mode": "time",
  2883. "name": null,
  2884. "show": true,
  2885. "values": []
  2886. },
  2887. "yaxes": [
  2888. {
  2889. "format": "short",
  2890. "label": null,
  2891. "logBase": 1,
  2892. "max": null,
  2893. "min": null,
  2894. "show": true
  2895. },
  2896. {
  2897. "format": "short",
  2898. "label": null,
  2899. "logBase": 1,
  2900. "max": null,
  2901. "min": null,
  2902. "show": true
  2903. }
  2904. ],
  2905. "yaxis": {
  2906. "align": false,
  2907. "alignLevel": null
  2908. }
  2909. },
  2910. {
  2911. "alert": {
  2912. "conditions": [
  2913. {
  2914. "evaluator": {
  2915. "params": [
  2916. 5000
  2917. ],
  2918. "type": "gt"
  2919. },
  2920. "operator": {
  2921. "type": "and"
  2922. },
  2923. "query": {
  2924. "params": [
  2925. "A",
  2926. "1m",
  2927. "now"
  2928. ]
  2929. },
  2930. "reducer": {
  2931. "params": [],
  2932. "type": "avg"
  2933. },
  2934. "type": "query"
  2935. }
  2936. ],
  2937. "executionErrorState": "keep_state",
  2938. "frequency": "60s",
  2939. "handler": 1,
  2940. "name": "long polling alert",
  2941. "noDataState": "ok",
  2942. "notifications": []
  2943. },
  2944. "aliasColors": {},
  2945. "bars": false,
  2946. "dashLength": 10,
  2947. "dashes": false,
  2948. "datasource": "Prometheus",
  2949. "fill": 1,
  2950. "gridPos": {
  2951. "h": 5,
  2952. "w": 8,
  2953. "x": 8,
  2954. "y": 47
  2955. },
  2956. "id": 84,
  2957. "legend": {
  2958. "avg": false,
  2959. "current": false,
  2960. "max": false,
  2961. "min": false,
  2962. "show": true,
  2963. "total": false,
  2964. "values": false
  2965. },
  2966. "lines": true,
  2967. "linewidth": 1,
  2968. "links": [],
  2969. "nullPointMode": "null",
  2970. "percentage": false,
  2971. "pointradius": 5,
  2972. "points": false,
  2973. "renderer": "flot",
  2974. "repeatDirection": "h",
  2975. "seriesOverrides": [],
  2976. "spaceLength": 10,
  2977. "stack": false,
  2978. "steppedLine": false,
  2979. "targets": [
  2980. {
  2981. "expr": "max(nacos_monitor{name='longPolling'})",
  2982. "format": "time_series",
  2983. "intervalFactor": 1,
  2984. "legendFormat": "",
  2985. "refId": "A"
  2986. }
  2987. ],
  2988. "thresholds": [
  2989. {
  2990. "colorMode": "critical",
  2991. "fill": true,
  2992. "line": true,
  2993. "op": "gt",
  2994. "value": 5000
  2995. }
  2996. ],
  2997. "timeFrom": null,
  2998. "timeRegions": [],
  2999. "timeShift": null,
  3000. "title": "long polling alert",
  3001. "tooltip": {
  3002. "shared": true,
  3003. "sort": 0,
  3004. "value_type": "individual"
  3005. },
  3006. "type": "graph",
  3007. "xaxis": {
  3008. "buckets": null,
  3009. "mode": "time",
  3010. "name": null,
  3011. "show": true,
  3012. "values": []
  3013. },
  3014. "yaxes": [
  3015. {
  3016. "format": "short",
  3017. "label": "",
  3018. "logBase": 1,
  3019. "max": null,
  3020. "min": null,
  3021. "show": true
  3022. },
  3023. {
  3024. "format": "short",
  3025. "label": null,
  3026. "logBase": 1,
  3027. "max": null,
  3028. "min": null,
  3029. "show": true
  3030. }
  3031. ],
  3032. "yaxis": {
  3033. "align": false,
  3034. "alignLevel": null
  3035. }
  3036. },
  3037. {
  3038. "alert": {
  3039. "conditions": [
  3040. {
  3041. "evaluator": {
  3042. "params": [
  3043. 1
  3044. ],
  3045. "type": "gt"
  3046. },
  3047. "operator": {
  3048. "type": "and"
  3049. },
  3050. "query": {
  3051. "params": [
  3052. "A",
  3053. "1m",
  3054. "now"
  3055. ]
  3056. },
  3057. "reducer": {
  3058. "params": [],
  3059. "type": "avg"
  3060. },
  3061. "type": "query"
  3062. }
  3063. ],
  3064. "executionErrorState": "keep_state",
  3065. "frequency": "60s",
  3066. "handler": 1,
  3067. "name": "config unhealth exception alert",
  3068. "noDataState": "ok",
  3069. "notifications": []
  3070. },
  3071. "aliasColors": {},
  3072. "bars": false,
  3073. "dashLength": 10,
  3074. "dashes": false,
  3075. "datasource": "Prometheus",
  3076. "fill": 1,
  3077. "gridPos": {
  3078. "h": 5,
  3079. "w": 8,
  3080. "x": 16,
  3081. "y": 47
  3082. },
  3083. "id": 56,
  3084. "legend": {
  3085. "avg": false,
  3086. "current": false,
  3087. "max": false,
  3088. "min": false,
  3089. "show": true,
  3090. "total": false,
  3091. "values": false
  3092. },
  3093. "lines": true,
  3094. "linewidth": 1,
  3095. "links": [],
  3096. "nullPointMode": "null",
  3097. "percentage": false,
  3098. "pointradius": 5,
  3099. "points": false,
  3100. "renderer": "flot",
  3101. "seriesOverrides": [],
  3102. "spaceLength": 10,
  3103. "stack": false,
  3104. "steppedLine": false,
  3105. "targets": [
  3106. {
  3107. "expr": "sum(rate(nacos_exception_total{name='unhealth'}[1m])) * 60",
  3108. "format": "time_series",
  3109. "intervalFactor": 1,
  3110. "refId": "A"
  3111. }
  3112. ],
  3113. "thresholds": [
  3114. {
  3115. "colorMode": "critical",
  3116. "fill": true,
  3117. "line": true,
  3118. "op": "gt",
  3119. "value": 1
  3120. }
  3121. ],
  3122. "timeFrom": null,
  3123. "timeRegions": [],
  3124. "timeShift": null,
  3125. "title": "config unhealth exception alert",
  3126. "tooltip": {
  3127. "shared": true,
  3128. "sort": 0,
  3129. "value_type": "individual"
  3130. },
  3131. "type": "graph",
  3132. "xaxis": {
  3133. "buckets": null,
  3134. "mode": "time",
  3135. "name": null,
  3136. "show": true,
  3137. "values": []
  3138. },
  3139. "yaxes": [
  3140. {
  3141. "format": "short",
  3142. "label": null,
  3143. "logBase": 1,
  3144. "max": null,
  3145. "min": null,
  3146. "show": true
  3147. },
  3148. {
  3149. "format": "short",
  3150. "label": null,
  3151. "logBase": 1,
  3152. "max": null,
  3153. "min": null,
  3154. "show": true
  3155. }
  3156. ],
  3157. "yaxis": {
  3158. "align": false,
  3159. "alignLevel": null
  3160. }
  3161. },
  3162. {
  3163. "alert": {
  3164. "conditions": [
  3165. {
  3166. "evaluator": {
  3167. "params": [
  3168. 1
  3169. ],
  3170. "type": "gt"
  3171. },
  3172. "operator": {
  3173. "type": "and"
  3174. },
  3175. "query": {
  3176. "params": [
  3177. "A",
  3178. "1m",
  3179. "now"
  3180. ]
  3181. },
  3182. "reducer": {
  3183. "params": [],
  3184. "type": "avg"
  3185. },
  3186. "type": "query"
  3187. }
  3188. ],
  3189. "executionErrorState": "keep_state",
  3190. "frequency": "60s",
  3191. "handler": 1,
  3192. "name": "db exception alert",
  3193. "noDataState": "ok",
  3194. "notifications": []
  3195. },
  3196. "aliasColors": {},
  3197. "bars": false,
  3198. "dashLength": 10,
  3199. "dashes": false,
  3200. "datasource": "Prometheus",
  3201. "fill": 1,
  3202. "gridPos": {
  3203. "h": 5,
  3204. "w": 8,
  3205. "x": 0,
  3206. "y": 52
  3207. },
  3208. "id": 54,
  3209. "legend": {
  3210. "avg": false,
  3211. "current": false,
  3212. "max": false,
  3213. "min": false,
  3214. "show": true,
  3215. "total": false,
  3216. "values": false
  3217. },
  3218. "lines": true,
  3219. "linewidth": 1,
  3220. "links": [],
  3221. "nullPointMode": "null",
  3222. "percentage": false,
  3223. "pointradius": 5,
  3224. "points": false,
  3225. "renderer": "flot",
  3226. "seriesOverrides": [],
  3227. "spaceLength": 10,
  3228. "stack": false,
  3229. "steppedLine": false,
  3230. "targets": [
  3231. {
  3232. "expr": "sum(rate(nacos_exception_total{name='db'}[1m])) * 60",
  3233. "format": "time_series",
  3234. "intervalFactor": 1,
  3235. "refId": "A"
  3236. }
  3237. ],
  3238. "thresholds": [
  3239. {
  3240. "colorMode": "critical",
  3241. "fill": true,
  3242. "line": true,
  3243. "op": "gt",
  3244. "value": 1
  3245. }
  3246. ],
  3247. "timeFrom": null,
  3248. "timeRegions": [],
  3249. "timeShift": null,
  3250. "title": "db exception alert",
  3251. "tooltip": {
  3252. "shared": true,
  3253. "sort": 0,
  3254. "value_type": "individual"
  3255. },
  3256. "type": "graph",
  3257. "xaxis": {
  3258. "buckets": null,
  3259. "mode": "time",
  3260. "name": null,
  3261. "show": true,
  3262. "values": []
  3263. },
  3264. "yaxes": [
  3265. {
  3266. "format": "short",
  3267. "label": null,
  3268. "logBase": 1,
  3269. "max": null,
  3270. "min": null,
  3271. "show": true
  3272. },
  3273. {
  3274. "format": "short",
  3275. "label": null,
  3276. "logBase": 1,
  3277. "max": null,
  3278. "min": null,
  3279. "show": true
  3280. }
  3281. ],
  3282. "yaxis": {
  3283. "align": false,
  3284. "alignLevel": null
  3285. }
  3286. },
  3287. {
  3288. "alert": {
  3289. "conditions": [
  3290. {
  3291. "evaluator": {
  3292. "params": [
  3293. 1
  3294. ],
  3295. "type": "gt"
  3296. },
  3297. "operator": {
  3298. "type": "and"
  3299. },
  3300. "query": {
  3301. "params": [
  3302. "A",
  3303. "1m",
  3304. "now"
  3305. ]
  3306. },
  3307. "reducer": {
  3308. "params": [],
  3309. "type": "avg"
  3310. },
  3311. "type": "query"
  3312. }
  3313. ],
  3314. "executionErrorState": "keep_state",
  3315. "frequency": "60s",
  3316. "handler": 1,
  3317. "name": "failedPush alert",
  3318. "noDataState": "ok",
  3319. "notifications": []
  3320. },
  3321. "aliasColors": {},
  3322. "bars": false,
  3323. "dashLength": 10,
  3324. "dashes": false,
  3325. "datasource": "Prometheus",
  3326. "fill": 1,
  3327. "gridPos": {
  3328. "h": 5,
  3329. "w": 8,
  3330. "x": 8,
  3331. "y": 52
  3332. },
  3333. "id": 51,
  3334. "legend": {
  3335. "avg": false,
  3336. "current": false,
  3337. "max": false,
  3338. "min": false,
  3339. "show": true,
  3340. "total": false,
  3341. "values": false
  3342. },
  3343. "lines": true,
  3344. "linewidth": 1,
  3345. "links": [],
  3346. "nullPointMode": "null",
  3347. "percentage": false,
  3348. "pointradius": 5,
  3349. "points": false,
  3350. "renderer": "flot",
  3351. "seriesOverrides": [],
  3352. "spaceLength": 10,
  3353. "stack": false,
  3354. "steppedLine": false,
  3355. "targets": [
  3356. {
  3357. "expr": "sum(nacos_monitor{name='failedPush'})",
  3358. "format": "time_series",
  3359. "intervalFactor": 1,
  3360. "refId": "A"
  3361. }
  3362. ],
  3363. "thresholds": [
  3364. {
  3365. "colorMode": "critical",
  3366. "fill": true,
  3367. "line": true,
  3368. "op": "gt",
  3369. "value": 1
  3370. }
  3371. ],
  3372. "timeFrom": null,
  3373. "timeRegions": [],
  3374. "timeShift": null,
  3375. "title": "failed push alert",
  3376. "tooltip": {
  3377. "shared": true,
  3378. "sort": 0,
  3379. "value_type": "individual"
  3380. },
  3381. "type": "graph",
  3382. "xaxis": {
  3383. "buckets": null,
  3384. "mode": "time",
  3385. "name": null,
  3386. "show": true,
  3387. "values": []
  3388. },
  3389. "yaxes": [
  3390. {
  3391. "format": "short",
  3392. "label": null,
  3393. "logBase": 1,
  3394. "max": null,
  3395. "min": null,
  3396. "show": true
  3397. },
  3398. {
  3399. "format": "short",
  3400. "label": null,
  3401. "logBase": 1,
  3402. "max": null,
  3403. "min": null,
  3404. "show": true
  3405. }
  3406. ],
  3407. "yaxis": {
  3408. "align": false,
  3409. "alignLevel": null
  3410. }
  3411. },
  3412. {
  3413. "alert": {
  3414. "conditions": [
  3415. {
  3416. "evaluator": {
  3417. "params": [
  3418. 1
  3419. ],
  3420. "type": "gt"
  3421. },
  3422. "operator": {
  3423. "type": "and"
  3424. },
  3425. "query": {
  3426. "params": [
  3427. "A",
  3428. "1m",
  3429. "now"
  3430. ]
  3431. },
  3432. "reducer": {
  3433. "params": [],
  3434. "type": "avg"
  3435. },
  3436. "type": "query"
  3437. }
  3438. ],
  3439. "executionErrorState": "keep_state",
  3440. "frequency": "60s",
  3441. "handler": 1,
  3442. "name": "illegalArgument exception alert",
  3443. "noDataState": "ok",
  3444. "notifications": []
  3445. },
  3446. "aliasColors": {},
  3447. "bars": false,
  3448. "dashLength": 10,
  3449. "dashes": false,
  3450. "datasource": "Prometheus",
  3451. "fill": 1,
  3452. "gridPos": {
  3453. "h": 5,
  3454. "w": 8,
  3455. "x": 16,
  3456. "y": 52
  3457. },
  3458. "id": 59,
  3459. "legend": {
  3460. "avg": false,
  3461. "current": false,
  3462. "max": false,
  3463. "min": false,
  3464. "show": true,
  3465. "total": false,
  3466. "values": false
  3467. },
  3468. "lines": true,
  3469. "linewidth": 1,
  3470. "links": [],
  3471. "nullPointMode": "null",
  3472. "percentage": false,
  3473. "pointradius": 5,
  3474. "points": false,
  3475. "renderer": "flot",
  3476. "seriesOverrides": [],
  3477. "spaceLength": 10,
  3478. "stack": false,
  3479. "steppedLine": false,
  3480. "targets": [
  3481. {
  3482. "expr": "sum(rate(nacos_exception_total{name='illegalArgument'}[1m])) * 60",
  3483. "format": "time_series",
  3484. "intervalFactor": 1,
  3485. "refId": "A"
  3486. }
  3487. ],
  3488. "thresholds": [
  3489. {
  3490. "colorMode": "critical",
  3491. "fill": true,
  3492. "line": true,
  3493. "op": "gt",
  3494. "value": 1
  3495. }
  3496. ],
  3497. "timeFrom": null,
  3498. "timeRegions": [],
  3499. "timeShift": null,
  3500. "title": "illegalArgument exception alert",
  3501. "tooltip": {
  3502. "shared": true,
  3503. "sort": 0,
  3504. "value_type": "individual"
  3505. },
  3506. "type": "graph",
  3507. "xaxis": {
  3508. "buckets": null,
  3509. "mode": "time",
  3510. "name": null,
  3511. "show": true,
  3512. "values": []
  3513. },
  3514. "yaxes": [
  3515. {
  3516. "format": "short",
  3517. "label": null,
  3518. "logBase": 1,
  3519. "max": null,
  3520. "min": null,
  3521. "show": true
  3522. },
  3523. {
  3524. "format": "short",
  3525. "label": null,
  3526. "logBase": 1,
  3527. "max": null,
  3528. "min": null,
  3529. "show": true
  3530. }
  3531. ],
  3532. "yaxis": {
  3533. "align": false,
  3534. "alignLevel": null
  3535. }
  3536. },
  3537. {
  3538. "alert": {
  3539. "conditions": [
  3540. {
  3541. "evaluator": {
  3542. "params": [
  3543. 1
  3544. ],
  3545. "type": "gt"
  3546. },
  3547. "operator": {
  3548. "type": "and"
  3549. },
  3550. "query": {
  3551. "params": [
  3552. "A",
  3553. "5m",
  3554. "now"
  3555. ]
  3556. },
  3557. "reducer": {
  3558. "params": [],
  3559. "type": "avg"
  3560. },
  3561. "type": "query"
  3562. }
  3563. ],
  3564. "executionErrorState": "keep_state",
  3565. "frequency": "60s",
  3566. "handler": 1,
  3567. "name": "naming disk exception alert",
  3568. "noDataState": "ok",
  3569. "notifications": []
  3570. },
  3571. "aliasColors": {},
  3572. "bars": false,
  3573. "dashLength": 10,
  3574. "dashes": false,
  3575. "datasource": "Prometheus",
  3576. "fill": 1,
  3577. "gridPos": {
  3578. "h": 5,
  3579. "w": 8,
  3580. "x": 0,
  3581. "y": 57
  3582. },
  3583. "id": 57,
  3584. "legend": {
  3585. "avg": false,
  3586. "current": false,
  3587. "max": false,
  3588. "min": false,
  3589. "show": true,
  3590. "total": false,
  3591. "values": false
  3592. },
  3593. "lines": true,
  3594. "linewidth": 1,
  3595. "links": [],
  3596. "nullPointMode": "null",
  3597. "percentage": false,
  3598. "pointradius": 5,
  3599. "points": false,
  3600. "renderer": "flot",
  3601. "seriesOverrides": [],
  3602. "spaceLength": 10,
  3603. "stack": false,
  3604. "steppedLine": false,
  3605. "targets": [
  3606. {
  3607. "expr": "sum(rate(nacos_exception_total{name='disk'}[1m])) * 60",
  3608. "format": "time_series",
  3609. "intervalFactor": 1,
  3610. "refId": "A"
  3611. }
  3612. ],
  3613. "thresholds": [
  3614. {
  3615. "colorMode": "critical",
  3616. "fill": true,
  3617. "line": true,
  3618. "op": "gt",
  3619. "value": 1
  3620. }
  3621. ],
  3622. "timeFrom": null,
  3623. "timeRegions": [],
  3624. "timeShift": null,
  3625. "title": "naming disk exception alert",
  3626. "tooltip": {
  3627. "shared": true,
  3628. "sort": 0,
  3629. "value_type": "individual"
  3630. },
  3631. "type": "graph",
  3632. "xaxis": {
  3633. "buckets": null,
  3634. "mode": "time",
  3635. "name": null,
  3636. "show": true,
  3637. "values": []
  3638. },
  3639. "yaxes": [
  3640. {
  3641. "format": "short",
  3642. "label": null,
  3643. "logBase": 1,
  3644. "max": null,
  3645. "min": null,
  3646. "show": true
  3647. },
  3648. {
  3649. "format": "short",
  3650. "label": null,
  3651. "logBase": 1,
  3652. "max": null,
  3653. "min": null,
  3654. "show": true
  3655. }
  3656. ],
  3657. "yaxis": {
  3658. "align": false,
  3659. "alignLevel": null
  3660. }
  3661. },
  3662. {
  3663. "alert": {
  3664. "conditions": [
  3665. {
  3666. "evaluator": {
  3667. "params": [
  3668. 1
  3669. ],
  3670. "type": "gt"
  3671. },
  3672. "operator": {
  3673. "type": "and"
  3674. },
  3675. "query": {
  3676. "params": [
  3677. "A",
  3678. "1m",
  3679. "now"
  3680. ]
  3681. },
  3682. "reducer": {
  3683. "params": [],
  3684. "type": "avg"
  3685. },
  3686. "type": "query"
  3687. }
  3688. ],
  3689. "executionErrorState": "keep_state",
  3690. "frequency": "60s",
  3691. "handler": 1,
  3692. "name": "config notify exception alert",
  3693. "noDataState": "ok",
  3694. "notifications": []
  3695. },
  3696. "aliasColors": {},
  3697. "bars": false,
  3698. "dashLength": 10,
  3699. "dashes": false,
  3700. "datasource": "Prometheus",
  3701. "fill": 1,
  3702. "gridPos": {
  3703. "h": 5,
  3704. "w": 8,
  3705. "x": 8,
  3706. "y": 57
  3707. },
  3708. "id": 55,
  3709. "legend": {
  3710. "avg": false,
  3711. "current": false,
  3712. "max": false,
  3713. "min": false,
  3714. "show": true,
  3715. "total": false,
  3716. "values": false
  3717. },
  3718. "lines": true,
  3719. "linewidth": 1,
  3720. "links": [],
  3721. "nullPointMode": "null",
  3722. "percentage": false,
  3723. "pointradius": 5,
  3724. "points": false,
  3725. "renderer": "flot",
  3726. "seriesOverrides": [],
  3727. "spaceLength": 10,
  3728. "stack": false,
  3729. "steppedLine": false,
  3730. "targets": [
  3731. {
  3732. "expr": "sum(rate(nacos_exception_total{name='configNotify'}[1m])) * 60",
  3733. "format": "time_series",
  3734. "intervalFactor": 1,
  3735. "refId": "A"
  3736. }
  3737. ],
  3738. "thresholds": [
  3739. {
  3740. "colorMode": "critical",
  3741. "fill": true,
  3742. "line": true,
  3743. "op": "gt",
  3744. "value": 1
  3745. }
  3746. ],
  3747. "timeFrom": null,
  3748. "timeRegions": [],
  3749. "timeShift": null,
  3750. "title": "config notify exception alert",
  3751. "tooltip": {
  3752. "shared": true,
  3753. "sort": 0,
  3754. "value_type": "individual"
  3755. },
  3756. "type": "graph",
  3757. "xaxis": {
  3758. "buckets": null,
  3759. "mode": "time",
  3760. "name": null,
  3761. "show": true,
  3762. "values": []
  3763. },
  3764. "yaxes": [
  3765. {
  3766. "format": "short",
  3767. "label": null,
  3768. "logBase": 1,
  3769. "max": null,
  3770. "min": null,
  3771. "show": true
  3772. },
  3773. {
  3774. "format": "short",
  3775. "label": null,
  3776. "logBase": 1,
  3777. "max": null,
  3778. "min": null,
  3779. "show": true
  3780. }
  3781. ],
  3782. "yaxis": {
  3783. "align": false,
  3784. "alignLevel": null
  3785. }
  3786. },
  3787. {
  3788. "alert": {
  3789. "conditions": [
  3790. {
  3791. "evaluator": {
  3792. "params": [
  3793. 1
  3794. ],
  3795. "type": "gt"
  3796. },
  3797. "operator": {
  3798. "type": "and"
  3799. },
  3800. "query": {
  3801. "params": [
  3802. "A",
  3803. "1m",
  3804. "now"
  3805. ]
  3806. },
  3807. "reducer": {
  3808. "params": [],
  3809. "type": "avg"
  3810. },
  3811. "type": "query"
  3812. }
  3813. ],
  3814. "executionErrorState": "keep_state",
  3815. "frequency": "60s",
  3816. "handler": 1,
  3817. "name": "naming leader send beat failed exception alert",
  3818. "noDataState": "ok",
  3819. "notifications": []
  3820. },
  3821. "aliasColors": {},
  3822. "bars": false,
  3823. "dashLength": 10,
  3824. "dashes": false,
  3825. "datasource": "Prometheus",
  3826. "fill": 1,
  3827. "gridPos": {
  3828. "h": 5,
  3829. "w": 8,
  3830. "x": 16,
  3831. "y": 57
  3832. },
  3833. "id": 58,
  3834. "legend": {
  3835. "avg": false,
  3836. "current": false,
  3837. "max": false,
  3838. "min": false,
  3839. "show": true,
  3840. "total": false,
  3841. "values": false
  3842. },
  3843. "lines": true,
  3844. "linewidth": 1,
  3845. "links": [],
  3846. "nullPointMode": "null",
  3847. "percentage": false,
  3848. "pointradius": 5,
  3849. "points": false,
  3850. "renderer": "flot",
  3851. "seriesOverrides": [],
  3852. "spaceLength": 10,
  3853. "stack": false,
  3854. "steppedLine": false,
  3855. "targets": [
  3856. {
  3857. "expr": "sum(rate(nacos_exception_total{name='leaderSendBeatFailed'}[1m])) * 60",
  3858. "format": "time_series",
  3859. "intervalFactor": 1,
  3860. "refId": "A"
  3861. }
  3862. ],
  3863. "thresholds": [
  3864. {
  3865. "colorMode": "critical",
  3866. "fill": true,
  3867. "line": true,
  3868. "op": "gt",
  3869. "value": 1
  3870. }
  3871. ],
  3872. "timeFrom": null,
  3873. "timeRegions": [],
  3874. "timeShift": null,
  3875. "title": "naming leader send beat failed exception alert",
  3876. "tooltip": {
  3877. "shared": true,
  3878. "sort": 0,
  3879. "value_type": "individual"
  3880. },
  3881. "type": "graph",
  3882. "xaxis": {
  3883. "buckets": null,
  3884. "mode": "time",
  3885. "name": null,
  3886. "show": true,
  3887. "values": []
  3888. },
  3889. "yaxes": [
  3890. {
  3891. "format": "short",
  3892. "label": null,
  3893. "logBase": 1,
  3894. "max": null,
  3895. "min": null,
  3896. "show": true
  3897. },
  3898. {
  3899. "format": "short",
  3900. "label": null,
  3901. "logBase": 1,
  3902. "max": null,
  3903. "min": null,
  3904. "show": true
  3905. }
  3906. ],
  3907. "yaxis": {
  3908. "align": false,
  3909. "alignLevel": null
  3910. }
  3911. },
  3912. {
  3913. "alert": {
  3914. "conditions": [
  3915. {
  3916. "evaluator": {
  3917. "params": [
  3918. 1
  3919. ],
  3920. "type": "gt"
  3921. },
  3922. "operator": {
  3923. "type": "and"
  3924. },
  3925. "query": {
  3926. "params": [
  3927. "A",
  3928. "1m",
  3929. "now"
  3930. ]
  3931. },
  3932. "reducer": {
  3933. "params": [],
  3934. "type": "avg"
  3935. },
  3936. "type": "query"
  3937. }
  3938. ],
  3939. "executionErrorState": "keep_state",
  3940. "frequency": "60s",
  3941. "handler": 1,
  3942. "name": "nacos_exception alert",
  3943. "noDataState": "ok",
  3944. "notifications": []
  3945. },
  3946. "aliasColors": {},
  3947. "bars": false,
  3948. "dashLength": 10,
  3949. "dashes": false,
  3950. "datasource": "Prometheus",
  3951. "fill": 1,
  3952. "gridPos": {
  3953. "h": 5,
  3954. "w": 8,
  3955. "x": 0,
  3956. "y": 62
  3957. },
  3958. "id": 60,
  3959. "legend": {
  3960. "avg": false,
  3961. "current": false,
  3962. "max": false,
  3963. "min": false,
  3964. "show": true,
  3965. "total": false,
  3966. "values": false
  3967. },
  3968. "lines": true,
  3969. "linewidth": 1,
  3970. "links": [],
  3971. "nullPointMode": "null",
  3972. "percentage": false,
  3973. "pointradius": 5,
  3974. "points": false,
  3975. "renderer": "flot",
  3976. "seriesOverrides": [],
  3977. "spaceLength": 10,
  3978. "stack": false,
  3979. "steppedLine": false,
  3980. "targets": [
  3981. {
  3982. "expr": "sum(rate(nacos_exception_total{name='nacos'}[1m])) * 60",
  3983. "format": "time_series",
  3984. "intervalFactor": 1,
  3985. "refId": "A"
  3986. }
  3987. ],
  3988. "thresholds": [
  3989. {
  3990. "colorMode": "critical",
  3991. "fill": true,
  3992. "line": true,
  3993. "op": "gt",
  3994. "value": 1
  3995. }
  3996. ],
  3997. "timeFrom": null,
  3998. "timeRegions": [],
  3999. "timeShift": null,
  4000. "title": "nacos exception alert",
  4001. "tooltip": {
  4002. "shared": true,
  4003. "sort": 0,
  4004. "value_type": "individual"
  4005. },
  4006. "type": "graph",
  4007. "xaxis": {
  4008. "buckets": null,
  4009. "mode": "time",
  4010. "name": null,
  4011. "show": true,
  4012. "values": []
  4013. },
  4014. "yaxes": [
  4015. {
  4016. "format": "short",
  4017. "label": null,
  4018. "logBase": 1,
  4019. "max": null,
  4020. "min": null,
  4021. "show": true
  4022. },
  4023. {
  4024. "format": "short",
  4025. "label": null,
  4026. "logBase": 1,
  4027. "max": null,
  4028. "min": null,
  4029. "show": true
  4030. }
  4031. ],
  4032. "yaxis": {
  4033. "align": false,
  4034. "alignLevel": null
  4035. }
  4036. }
  4037. ],
  4038. "refresh": false,
  4039. "schemaVersion": 16,
  4040. "style": "dark",
  4041. "tags": [],
  4042. "templating": {
  4043. "list": [
  4044. {
  4045. "allValue": ".*:8848",
  4046. "current": {
  4047. "selected": true,
  4048. "text": "All",
  4049. "value": "$__all"
  4050. },
  4051. "datasource": "Prometheus",
  4052. "definition": "label_values(instance)",
  4053. "hide": 0,
  4054. "includeAll": true,
  4055. "label": "instance",
  4056. "multi": false,
  4057. "name": "instance",
  4058. "options": [],
  4059. "query": "label_values(instance)",
  4060. "refresh": 2,
  4061. "regex": "/.*:8848/",
  4062. "skipUrlSync": false,
  4063. "sort": 0,
  4064. "tagValuesQuery": "",
  4065. "tags": [],
  4066. "tagsQuery": "",
  4067. "type": "query",
  4068. "useTags": false
  4069. }
  4070. ]
  4071. },
  4072. "time": {
  4073. "from": "now-5m",
  4074. "to": "now"
  4075. },
  4076. "timepicker": {
  4077. "refresh_intervals": [
  4078. "5s",
  4079. "10s",
  4080. "30s",
  4081. "1m",
  4082. "5m",
  4083. "15m",
  4084. "30m",
  4085. "1h",
  4086. "2h",
  4087. "1d"
  4088. ],
  4089. "time_options": [
  4090. "5m",
  4091. "15m",
  4092. "1h",
  4093. "6h",
  4094. "12h",
  4095. "24h",
  4096. "2d",
  4097. "7d",
  4098. "30d"
  4099. ]
  4100. },
  4101. "timezone": "",
  4102. "title": "Nacos",
  4103. "uid": "Bz_QALEiz1",
  4104. "version": 38
  4105. }

访问 Grafana 的 Nacos 面板。
image.png

3.2 Nacos 配置管理

pom.xml 文件中添加相关依赖。

<dependency>
    <groupid>com.alibaba.cloud</groupid>
    <artifactid>spring-cloud-starter-alibaba-nacos-config</artifactid>
</dependency>

bootstrap.yaml 文件中新增相关配置。

spring:
  application:
    name: demo
  cloud:
    nacos:
      config:
        server-addr: 192.168.50.163:8848
        namespace: demo
        group: DEFAULT_GROUP
        file-extension: yaml
        username: 开源版 nacos 账号
        password: 开源版 nacos 密码
#        access-key: 阿里云账号名称
#        secret-key: 阿里云账号密码
#        sharedConfigs: # 支持自定义 dataId,支持一个应用对应多个配置文件
#          - data-id: common-db.yaml
#              group: REFRESH_GROUP
#              refresh: true
#          - data-id: common-mq.yaml
#              group: REFRESH_GROUP
#              refresh: true

management:
  endpoints:
    web:
      exposure:
        include: '*'

3.2.1 使用 @RefreshScope 支持 @Value 动态刷新

通过 @Value + @RefreshScope 可以实现配置的注入,但是个人不建议这样使用,请看 3.2.2 小节。

@RefreshScope
@RestController
public class TestController {

    // @Value 可以获取到配置中心的值,但是无法动态感知修改后的值,需要利用 @RefreshScope 注解实现动态刷新
    @Value("${name}")
    private String name;

    @GetMapping("/test")
    public String hello() {
        return name;
    }
}

3.2.2 使用 @ConfigurationProperties 管理配置项

建议使用 @ConfigurationProperties 代替 @Value获取配置值,理由:@Value 使用字符串标识,多处引用不方便维护,很难通过编译报错发现拼错名称的问题。实测 @ConfigurationProperties 是支持动态刷新配置的,当然,你也可以用 @NacosConfigurationProperties 作为备选项。

@ConfigurationProperties(prefix = "test") 
public class TestProperties {

    private String name; // 读取 "test.name" 配置值
}

@Component
public class TestComponent {

    // 注入属性配置对象
    private final TestProperties properties;

    public TestComponent(TestProperties properties) {
      this.properties = properties;
    }

    public void method() {
        // properties.getName();
    }
}

3.3 Sentinel 限流熔断降级

3.3.1 定制 Sentinel 控制台

[

](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0#2-%E5%90%AF%E5%8A%A8%E6%8E%A7%E5%88%B6%E5%8F%B0)

3.3.2 集成 Sentinel 控制台

pom.xml 文件中添加相关依赖。

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

application.yaml 文件中新增相关配置。

spring:
  application:
    name: demo
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080 # Sentinel 控制台地址
        port: 8719 # 另起一个端口和 Sentinel 控制台交互

server:
  port: 8800

# http://localhost:8800/actuator/sentinel
management:
  endpoints:
    web:
      exposure:
        include: '*'

3.3.3 OpenFeign 集成 Sentinel

pom.xml 文件中添加相关依赖。

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

application.yaml 开启 Feign 对 Sentinel 的支持。

spring:
  application:
    name: demo
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080 # Sentinel 控制台地址
        port: 8719 # 另起一个端口和 Sentinel 控制台交互

server:
  port: 8800

# http://localhost:8800/actuator/sentinel
management:
  endpoints:
    web:
      exposure:
        include: '*'

# 开启 Feign 对 Sentinel 的支持
feign:
  sentinel:
    enabled: true

在 Feign 的声明式接口添加 fallback 配置。

@FeignClient(value = "user", path = "/users", fallback = FallbackUserFeignService.class)
public interface UserFeignService {

    @RequestMapping("/{userId}")
    public Response findByUserId(@PathVariable("userId") Long userId);

}

@Component
public class FallbackUserFeignService implements UserFeignService {

    @Override
    public Response findByUserId(Long userId) {
        return Response.buildFailure("B0220", "系统功能降级"); // 参考阿里巴巴错误码
    }
}

或者使用 fallbackFactory 配置。

@FeignClient(value = "user", path = "/users", fallbackFactory = FallbackUserFeignServiceFactory.class)
public interface UserFeignService {

    @RequestMapping("/{userId}")
    public Response findByUserId(@PathVariable("userId") Long userId);

}

@Component
public class FallbackDemoFeignServiceFactory implements FallbackFactory<DemoFeignService> {

    @Override
    public UserFeignService create(Throwable throwable) {

        return new UserFeignService() {

            @Override
            public Response findByUserId(Long userId) {
                 return Response.buildFailure("B0220", "系统功能降级"); // 参考阿里巴巴错误码
            }
        };
    }
}

3.3.4 Dubbo 集成 Sentinel

pom.xml 文件中添加相关依赖。

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-apache-dubbo-adapter</artifactId>
</dependency>

Provider 端全局降级配置初始化。

@PostConstruct
public void init() {
    DubboAdapterGlobalConfig.setProviderFallback(
        (invoker, invocation, ex) ‐> 
        AsyncRpcResult.newDefaultAsyncResult(Response.buildFailure("B0220", "系统功能降级"), invocation));
}

Consumer 端全局降级配置初始化。

@PostConstruct
public void init() {
    DubboAdapterGlobalConfig.setConsumerFallback(
        (invoker, invocation, ex) ‐> 
        AsyncRpcResult.newDefaultAsyncResult(Response.buildFailure("B0220", "系统功能降级"), invocation));
}

3.3.5 RestTemplate 集成 Sentinel

pom.xml 文件中添加相关依赖。

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
</dependency>

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

application.yaml 开启 RestTemplate 对 Sentinel 的支持。

spring:
  application:
    name: demo
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080 # Sentinel 控制台地址
        port: 8719 # 另起一个端口和 Sentinel 控制台交互

server:
  port: 8800

# http://localhost:8800/actuator/sentinel
management:
  endpoints:
    web:
      exposure:
        include: '*'

# 开启 RestTemplate 对 Sentinel 的支持
resttemplate: 
  sentinel: 
    enabled: true

自定义装配 RestTemplate,添加 @SentinelRestTemplate 注解。

@Configuration
public class SentinelRestTemplateAutoConfiguration {

    @Bean
    @LoadBalanced
    @SentinelRestTemplate(
        blockHandler = "handleException", blockHandlerClass = GlobalExceptionHandler.class,
        fallback = "fallback", fallbackClass = GlobalExceptionHandler.class
    )
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}

3.4 Spring Cloud LoadBalancer 客户端负载均衡

3.5 OpenFeign 声明式调用

3.6 Dubbo 分布式服务调用

3.6 Spring Cloud Gateway 服务网关

3.7 Zipkin2 服务链路跟踪

3.7 Seata 分布式事务