fundplatform/docker/grafana/dashboards/fund-platform-dashboard.json
zhangjf 5b80e237b9 feat: Docker容器化部署和Prometheus+Grafana监控
## Docker 容器化部署

### 新增文件
- Dockerfile: 多阶段构建镜像,支持 Java 21
- docker-compose.yml: 完整服务编排配置
  - 基础设施: MySQL 8.0, Redis 7, Nacos 3.0
  - 监控: Prometheus, Grafana
  - 业务服务: Gateway + 9个微服务
- docker/.env: 环境变量配置
- docker/mysql/init/01-init.sql: 数据库初始化脚本

### Docker 特性
- 多阶段构建优化镜像大小
- 非 root 用户运行服务
- 健康检查配置
- 统一时区设置 (Asia/Shanghai)

## Prometheus + Grafana 监控

### Prometheus 配置
- docker/prometheus/prometheus.yml: 服务发现配置
- docker/prometheus/rules/alerts.yml: 告警规则
  - 服务可用性告警
  - JVM 内存告警
  - HTTP 请求告警
  - 数据库连接池告警
  - 系统资源告警

### Grafana 配置
- docker/grafana/provisioning/: 数据源和Dashboard自动导入
- docker/grafana/dashboards/fund-platform-dashboard.json
  - 服务概览面板
  - JVM 内存监控
  - 数据库连接池监控

### Spring Boot Actuator 集成
- pom.xml: 添加 spring-boot-starter-actuator 和 micrometer-registry-prometheus
- application-docker.yml: Prometheus 端点配置

## 服务端口规划
- Gateway: 8000
- fund-sys: 8100
- fund-cust: 8200
- fund-proj: 8300
- fund-req: 8400
- fund-exp: 8500
- fund-receipt: 8600
- fund-report: 8700
- fund-file: 8800
- Prometheus: 9090
- Grafana: 3000
- Nacos: 8848
2026-02-19 18:48:15 +08:00

663 lines
16 KiB
JSON

{
"annotations": {
"list": []
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"links": [],
"liveNow": false,
"panels": [
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 1,
"panels": [],
"title": "服务概览",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 6,
"x": 0,
"y": 1
},
"id": 2,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "10.2.0",
"targets": [
{
"expr": "count(up{job=~\"fund-.*\"})",
"refId": "A",
"legendFormat": "总服务数"
},
{
"expr": "count(up{job=~\"fund-.*\"} == 1)",
"refId": "B",
"legendFormat": "在线服务"
},
{
"expr": "count(up{job=~\"fund-.*\"} == 0)",
"refId": "C",
"legendFormat": "离线服务"
}
],
"title": "服务状态",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 10,
"x": 6,
"y": 1
},
"id": 3,
"options": {
"legend": {
"calcs": ["mean", "max"],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"expr": "sum(rate(http_server_requests_seconds_count{application=~\"$application\"}[5m])) by (application)",
"legendFormat": "{{application}}",
"refId": "A"
}
],
"title": "请求速率 (QPS)",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 8,
"x": 16,
"y": 1
},
"id": 4,
"options": {
"legend": {
"calcs": ["mean", "max"],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"expr": "histogram_quantile(0.95, sum(rate(http_server_requests_seconds_bucket{application=~\"$application\"}[5m])) by (le, application))",
"legendFormat": "{{application}} P95",
"refId": "A"
},
{
"expr": "histogram_quantile(0.99, sum(rate(http_server_requests_seconds_bucket{application=~\"$application\"}[5m])) by (le, application))",
"legendFormat": "{{application}} P99",
"refId": "B"
}
],
"title": "响应时间 (P95/P99)",
"type": "timeseries"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 7
},
"id": 10,
"panels": [],
"title": "JVM 内存",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 11,
"options": {
"legend": {
"calcs": ["mean", "max"],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"expr": "jvm_memory_used_bytes{application=~\"$application\", area=\"heap\"}",
"legendFormat": "{{application}} - Used",
"refId": "A"
},
{
"expr": "jvm_memory_max_bytes{application=~\"$application\", area=\"heap\"}",
"legendFormat": "{{application}} - Max",
"refId": "B"
}
],
"title": "JVM 堆内存使用",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 8
},
"id": 12,
"options": {
"legend": {
"calcs": ["mean", "max"],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"expr": "rate(jvm_gc_pause_seconds_sum{application=~\"$application\"}[5m])",
"legendFormat": "{{application}} - {{action}}",
"refId": "A"
}
],
"title": "GC 时间",
"type": "timeseries"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 16
},
"id": 20,
"panels": [],
"title": "数据库连接池",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "smooth",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 12,
"x": 0,
"y": 17
},
"id": 21,
"options": {
"legend": {
"calcs": ["mean", "max"],
"displayMode": "table",
"placement": "right",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "none"
}
},
"targets": [
{
"expr": "hikaricp_connections_active{application=~\"$application\"}",
"legendFormat": "{{application}} - Active",
"refId": "A"
},
{
"expr": "hikaricp_connections_idle{application=~\"$application\"}",
"legendFormat": "{{application}} - Idle",
"refId": "B"
},
{
"expr": "hikaricp_connections_max{application=~\"$application\"}",
"legendFormat": "{{application}} - Max",
"refId": "C"
}
],
"title": "HikariCP 连接池状态",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"max": 100,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 70
},
{
"color": "red",
"value": 85
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 12,
"x": 12,
"y": 17
},
"id": 22,
"options": {
"orientation": "horizontal",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "10.2.0",
"targets": [
{
"expr": "(hikaricp_connections_active{application=~\"$application\"} / hikaricp_connections_max{application=~\"$application\"}) * 100",
"legendFormat": "{{application}}",
"refId": "A"
}
],
"title": "连接池使用率",
"type": "gauge"
}
],
"refresh": "5s",
"schemaVersion": 38,
"style": "dark",
"tags": ["fundplatform", "springboot", "jvm"],
"templating": {
"list": [
{
"current": {
"selected": true,
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"definition": "label_values(up{job=~\"fund-.*\"}, application)",
"hide": 0,
"includeAll": true,
"label": "Application",
"multi": true,
"name": "application",
"options": [],
"query": {
"query": "label_values(up{job=~\"fund-.*\"}, application)",
"refId": "PrometheusVariableQueryEditor-VariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"type": "query"
}
]
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "资金服务平台监控",
"uid": "fund-platform-dashboard",
"version": 1,
"weekStart": ""
}