chore(config): Unify deployment orchestration and monitoring integration

This commit is contained in:
2026-04-18 18:22:35 +08:00
parent 2247d235ec
commit 6dfd828fe5
30 changed files with 1901 additions and 432 deletions
+40
View File
@@ -0,0 +1,40 @@
# Monitoring
最小可用监控栈包含:
- `Prometheus`
- `Grafana`
- `mysqld-exporter`
- `redis-exporter`
- `node-exporter`
- Spring Boot Actuator `prometheus` 指标端点
目录说明:
- `prometheus/prometheus.local.yml`
单机 Docker Compose 联调抓取配置
- `prometheus/prometheus.ha.yml`
三节点 HA 环境建议的集中抓取配置(默认放在 Node-01)
- `grafana/provisioning`
Grafana 自动配置数据源与仪表盘目录
- `grafana/dashboards/ha-ovp-overview.json`
平台总览面板
单机访问:
- Prometheus: `http://localhost:9090`
- Grafana: `http://localhost:3000`
默认 Grafana 账号密码由 Compose 中环境变量控制:
- 用户名:`admin`
- 密码:`admin123`
当前总览面板已包含:
- 各服务健康状态表
- 总 QPS / P95 响应时间
- 各服务请求速率 / 5xx 错误率
- JVM 堆内存与 GC 概览
- MySQL / Redis exporter 状态与关键指标
- Node Exporter 主机 CPU / 内存占位图
@@ -0,0 +1,887 @@
{
"annotations": {
"list": []
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"links": [],
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [
{
"options": {
"0": {
"color": "red",
"text": "DOWN"
},
"1": {
"color": "green",
"text": "UP"
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 10,
"w": 8,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"enablePagination": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true
},
"pluginVersion": "11.2.0",
"targets": [
{
"editorMode": "code",
"expr": "up{job!=\"prometheus\"}",
"format": "table",
"instant": true,
"legendFormat": "__auto",
"range": false,
"refId": "A"
}
],
"title": "Service Health Status",
"transformations": [
{
"id": "labelsToFields",
"options": {
"mode": "columns"
}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"__name__": true
},
"indexByName": {
"Value": 2,
"application": 0,
"instance": 1,
"job": 3,
"node": 4
},
"renameByName": {
"Value": "status"
}
}
}
],
"type": "table"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 4,
"x": 8,
"y": 0
},
"id": 2,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "sum(up{job!=\"prometheus\"})",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "Healthy Targets",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "background"
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 4,
"x": 12,
"y": 0
},
"id": 3,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "sum(rate(http_server_requests_seconds_count{application!=\"\"}[1m]))",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "Total QPS",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "background"
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 4,
"x": 16,
"y": 0
},
"id": 4,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "avg(system_cpu_usage{application!=\"\"})",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "Average CPU Usage",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "background"
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 4,
"x": 20,
"y": 0
},
"id": 5,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "histogram_quantile(0.95, sum(rate(http_server_requests_seconds_bucket{application!=\"\"}[5m])) by (le)) * 1000",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "P95 Response Time",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 8,
"y": 5
},
"id": 6,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"editorMode": "code",
"expr": "sum by (application) (rate(http_server_requests_seconds_count{application!=\"\"}[1m]))",
"legendFormat": "{{application}}",
"range": true,
"refId": "A"
}
],
"title": "Request Rate By Service",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 16,
"y": 5
},
"id": 7,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"editorMode": "code",
"expr": "histogram_quantile(0.95, sum by (application, le) (rate(http_server_requests_seconds_bucket{application!=\"\"}[5m]))) * 1000",
"legendFormat": "{{application}}",
"range": true,
"refId": "A"
}
],
"title": "P95 Latency By Service",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "reqps"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 0,
"y": 10
},
"id": 8,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"editorMode": "code",
"expr": "sum by (application) (rate(http_server_requests_seconds_count{application!=\"\",status=~\"5..\"}[5m]))",
"legendFormat": "{{application}}",
"range": true,
"refId": "A"
}
],
"title": "5xx Error Rate",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 8,
"y": 14
},
"id": 9,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"editorMode": "code",
"expr": "sum by (application) (jvm_memory_used_bytes{area=\"heap\",application!=\"\"})",
"legendFormat": "{{application}}",
"range": true,
"refId": "A"
}
],
"title": "JVM Heap Memory Used",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 8,
"x": 16,
"y": 14
},
"id": 10,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"editorMode": "code",
"expr": "sum by (application) (rate(jvm_gc_pause_seconds_sum{application!=\"\"}[5m]))",
"legendFormat": "{{application}} GC pause/s",
"range": true,
"refId": "A"
},
{
"editorMode": "code",
"expr": "sum by (application) (rate(jvm_gc_pause_seconds_count{application!=\"\"}[5m]))",
"legendFormat": "{{application}} GC count/s",
"range": true,
"refId": "B"
}
],
"title": "JVM GC Overview",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"0": {
"color": "red",
"text": "DOWN"
},
"1": {
"color": "green",
"text": "UP"
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 0,
"y": 19
},
"id": 11,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "max(mysql_up)",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "MySQL Exporter Status",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 6,
"y": 19
},
"id": 12,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "max(mysql_global_status_threads_connected)",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "MySQL Threads Connected",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"0": {
"color": "red",
"text": "DOWN"
},
"1": {
"color": "green",
"text": "UP"
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 12,
"y": 19
},
"id": 13,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "max(redis_up)",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "Redis Exporter Status",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 18,
"y": 19
},
"id": 14,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"targets": [
{
"editorMode": "code",
"expr": "max(redis_memory_used_bytes)",
"legendFormat": "",
"range": true,
"refId": "A"
}
],
"title": "Redis Memory Used",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 24
},
"id": 15,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"editorMode": "code",
"expr": "avg by (instance) (rate(node_cpu_seconds_total{mode!=\"idle\"}[5m]))",
"legendFormat": "{{instance}}",
"range": true,
"refId": "A"
}
],
"title": "Node CPU Usage",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"unit": "percentunit"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 24
},
"id": 16,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "multi"
}
},
"targets": [
{
"editorMode": "code",
"expr": "1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)",
"legendFormat": "{{instance}}",
"range": true,
"refId": "A"
}
],
"title": "Node Memory Usage",
"type": "timeseries"
}
],
"refresh": "10s",
"schemaVersion": 39,
"style": "dark",
"tags": [
"ha-ovp",
"spring-boot",
"monitoring"
],
"templating": {
"list": []
},
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "HA-OVP Overview",
"uid": "ha-ovp-overview",
"version": 2,
"weekStart": ""
}
@@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: HA-OVP
orgId: 1
folder: HA-OVP
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
- name: Prometheus
uid: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false
@@ -0,0 +1,207 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- prometheus:9090
- job_name: node-01-gateway
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.101:9000
labels:
application: video-gateway
node: node-01
- job_name: node-01-auth
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.101:9001
labels:
application: video-auth
node: node-01
- job_name: node-01-user
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.101:9002
labels:
application: video-user
node: node-01
- job_name: node-01-content
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.101:9003
labels:
application: video-content
node: node-01
- job_name: node-01-comment
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.101:9004
labels:
application: video-comment
node: node-01
- job_name: node-01-recommend
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.101:9005
labels:
application: video-recommend
node: node-01
- job_name: node-01-admin
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.101:9006
labels:
application: video-admin
node: node-01
- job_name: node-02-gateway
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.102:9000
labels:
application: video-gateway
node: node-02
- job_name: node-02-auth
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.102:9001
labels:
application: video-auth
node: node-02
- job_name: node-02-user
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.102:9002
labels:
application: video-user
node: node-02
- job_name: node-02-content
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.102:9003
labels:
application: video-content
node: node-02
- job_name: node-02-comment
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.102:9004
labels:
application: video-comment
node: node-02
- job_name: node-02-recommend
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.102:9005
labels:
application: video-recommend
node: node-02
- job_name: node-02-admin
metrics_path: /actuator/prometheus
static_configs:
- targets:
- 192.168.1.102:9006
labels:
application: video-admin
node: node-02
- job_name: node-01-mysql-exporter
static_configs:
- targets:
- 192.168.1.101:9104
labels:
application: mysql
node: node-01
- job_name: node-02-mysql-exporter
static_configs:
- targets:
- 192.168.1.102:9104
labels:
application: mysql
node: node-02
- job_name: node-03-mysql-exporter
static_configs:
- targets:
- 192.168.1.103:9104
labels:
application: mysql
node: node-03
- job_name: node-01-redis-exporter
static_configs:
- targets:
- 192.168.1.101:9121
labels:
application: redis
node: node-01
- job_name: node-02-redis-exporter
static_configs:
- targets:
- 192.168.1.102:9121
labels:
application: redis
node: node-02
- job_name: node-03-redis-exporter
static_configs:
- targets:
- 192.168.1.103:9121
labels:
application: redis
node: node-03
- job_name: node-01-node-exporter
static_configs:
- targets:
- 192.168.1.101:9100
labels:
application: node
node: node-01
- job_name: node-02-node-exporter
static_configs:
- targets:
- 192.168.1.102:9100
labels:
application: node
node: node-02
- job_name: node-03-node-exporter
static_configs:
- targets:
- 192.168.1.103:9100
labels:
application: node
node: node-03
@@ -0,0 +1,86 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- prometheus:9090
- job_name: video-gateway
metrics_path: /actuator/prometheus
static_configs:
- targets:
- video-gateway:9000
labels:
application: video-gateway
- job_name: video-auth
metrics_path: /actuator/prometheus
static_configs:
- targets:
- video-auth:9001
labels:
application: video-auth
- job_name: video-user
metrics_path: /actuator/prometheus
static_configs:
- targets:
- video-user:9002
labels:
application: video-user
- job_name: video-content
metrics_path: /actuator/prometheus
static_configs:
- targets:
- video-content:9003
labels:
application: video-content
- job_name: video-comment
metrics_path: /actuator/prometheus
static_configs:
- targets:
- video-comment:9004
labels:
application: video-comment
- job_name: video-recommend
metrics_path: /actuator/prometheus
static_configs:
- targets:
- video-recommend:9005
labels:
application: video-recommend
- job_name: video-admin
metrics_path: /actuator/prometheus
static_configs:
- targets:
- video-admin:9006
labels:
application: video-admin
- job_name: mysql-exporter
static_configs:
- targets:
- mysqld-exporter:9104
labels:
application: mysql
- job_name: redis-exporter
static_configs:
- targets:
- redis-exporter:9121
labels:
application: redis
- job_name: node-exporter
static_configs:
- targets:
- node-exporter:9100
labels:
application: node