feat(ops): 添加生产监控告警基线

- 新增 Prometheus/Grafana/Loki/Promtail 监控 profile\n- 覆盖 DB、磁盘、慢 API、慢 Prisma、任务失败和小宝摘要 stale 告警\n- 补充 postgres-exporter 自定义查询、Dashboard、部署文档和校验\n\nCo-Authored-By: GPT-5 Codex <codex@openai.com>
This commit is contained in:
2026-07-08 16:21:07 +08:00
parent eef09d5af4
commit 7837a809ca
15 changed files with 587 additions and 1 deletions

View File

@@ -123,7 +123,117 @@ services:
server:
condition: service_healthy
prometheus:
image: prom/prometheus:v2.53.1
profiles: ['monitoring']
restart: unless-stopped
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION:-15d}'
- '--web.enable-lifecycle'
ports:
- '${PROMETHEUS_PORT:-9090}:9090'
volumes:
- ./deploy/monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./deploy/monitoring/prometheus/alert-rules.yml:/etc/prometheus/alert-rules.yml:ro
- prometheus_data:/prometheus
depends_on:
- postgres-exporter
- node-exporter
- cadvisor
- promtail
- blackbox-exporter
grafana:
image: grafana/grafana:11.1.0
profiles: ['monitoring']
restart: unless-stopped
ports:
- '${GRAFANA_PORT:-3002}:3000'
environment:
GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:-admin}
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:-change-me-monitoring-password}
GF_USERS_ALLOW_SIGN_UP: 'false'
volumes:
- grafana_data:/var/lib/grafana
- ./deploy/monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
- ./deploy/monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
depends_on:
- prometheus
- loki
loki:
image: grafana/loki:2.9.8
profiles: ['monitoring']
restart: unless-stopped
command: ['-config.file=/etc/loki/config.yml']
volumes:
- ./deploy/monitoring/loki/config.yml:/etc/loki/config.yml:ro
- loki_data:/loki
promtail:
image: grafana/promtail:2.9.8
profiles: ['monitoring']
restart: unless-stopped
command: ['-config.file=/etc/promtail/config.yml']
volumes:
- ./deploy/monitoring/promtail/config.yml:/etc/promtail/config.yml:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
depends_on:
- loki
postgres-exporter:
image: quay.io/prometheuscommunity/postgres-exporter:v0.15.0
profiles: ['monitoring']
restart: unless-stopped
command:
- '--extend.query-path=/etc/postgres-exporter/postgres-queries.yml'
environment:
DATA_SOURCE_NAME: postgresql://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-ftb_pm}?sslmode=disable
volumes:
- ./deploy/monitoring/postgres/postgres-queries.yml:/etc/postgres-exporter/postgres-queries.yml:ro
depends_on:
postgres:
condition: service_healthy
node-exporter:
image: prom/node-exporter:v1.8.2
profiles: ['monitoring']
restart: unless-stopped
command:
- '--path.rootfs=/host'
volumes:
- /:/host:ro,rslave
cadvisor:
image: gcr.io/cadvisor/cadvisor:v0.49.1
profiles: ['monitoring']
restart: unless-stopped
privileged: true
devices:
- /dev/kmsg:/dev/kmsg
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
blackbox-exporter:
image: prom/blackbox-exporter:v0.25.0
profiles: ['monitoring']
restart: unless-stopped
command:
- '--config.file=/etc/blackbox/config.yml'
volumes:
- ./deploy/monitoring/blackbox/config.yml:/etc/blackbox/config.yml:ro
volumes:
postgres_data:
redis_data:
server_data:
prometheus_data:
grafana_data:
loki_data: