Janus-Pro-7B部署全栈监控:Prometheus+Grafana GPU指标看板
Janus-Pro-7B部署全栈监控:Prometheus+Grafana GPU指标看板
1. 引言
当你把Janus-Pro-7B这个强大的多模态模型部署到服务器上,看着它能够理解图片内容、生成精美图像时,心里一定很有成就感。但很快你就会发现一个问题:我怎么知道它运行得怎么样?
模型运行的时候,GPU温度有多高?显存用了多少?生成一张图片到底花了多长时间?这些关键信息如果看不到,就像开车没有仪表盘一样,心里没底。
今天我要分享的就是如何为Janus-Pro-7B搭建一个完整的监控系统。这个系统能让你:
- 实时查看GPU的各项指标
- 历史分析模型运行性能
- 预警通知当资源出现问题时
- 优化决策基于数据调整配置
整个方案基于两个开源工具:Prometheus负责收集指标,Grafana负责可视化展示。我会带你一步步搭建,从零开始到最终看到漂亮的监控面板。
2. 为什么需要监控Janus-Pro-7B?
2.1 模型运行的特点
Janus-Pro-7B作为一个7B参数的多模态模型,运行时有几个明显特点:
资源消耗大
- 模型加载需要约14GB显存
- 推理时GPU利用率会飙升
- 长时间运行可能积累显存碎片
性能波动明显
- 图片问答:5-10秒
- 文本生图:30-60秒
- 不同输入的处理时间差异很大
稳定性要求高
- 服务需要7x24小时运行
- 用户随时可能访问
- 异常需要及时发现
2.2 监控能解决什么问题?
问题诊断 以前遇到服务卡顿,你可能会:
- SSH登录服务器
- 运行
nvidia-smi - 查看日志文件
- 手动分析问题
有了监控系统后:
- 打开浏览器
- 查看监控面板
- 一眼看到问题所在
- 快速定位原因
性能优化
- 发现生成图片时间变长?可能是显存不足
- GPU温度持续偏高?可能需要调整风扇策略
- 内存使用率过高?考虑增加交换空间
容量规划
- 当前配置能支持多少并发?
- 什么时候需要升级硬件?
- 如何合理分配资源?
3. 监控方案架构
3.1 整体架构
我们的监控系统采用经典的三层架构:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ Janus-Pro-7B │───▶│ Prometheus │───▶│ Grafana │
│ 服务 │ │ 数据收集 │ │ 可视化展示 │
│ │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ NVIDIA GPU │ │ 指标存储 │ │ 监控告警 │
│ 指标暴露 │ │ (TSDB) │ │ 规则配置 │
└─────────────────┘ └─────────────────┘ └─────────────────┘
3.2 组件介绍
NVIDIA DCGM Exporter 这是NVIDIA官方提供的工具,专门用于暴露GPU指标。它会:
- 定期采集GPU的各项数据
- 通过HTTP接口提供指标
- 支持Prometheus格式
Prometheus 时序数据库和监控系统,负责:
- 定期从DCGM Exporter拉取数据
- 存储历史指标数据
- 提供查询接口
Grafana 数据可视化平台,能够:
- 从Prometheus读取数据
- 创建漂亮的监控面板
- 设置告警规则
3.3 监控指标范围
我们主要关注以下几类指标:
GPU核心指标
- GPU利用率(%)
- 显存使用量(MB/GB)
- GPU温度(℃)
- 功耗(W)
内存指标
- 系统内存使用率
- 交换空间使用情况
服务指标
- Janus-Pro-7B服务状态
- 请求处理时间
- 错误率
4. 环境准备与安装
4.1 系统要求
在开始之前,确保你的服务器满足以下要求:
硬件要求
- NVIDIA GPU(推荐RTX 3090/4090或更高)
- 至少2GB可用磁盘空间(用于监控数据)
- 网络端口开放(9090, 3000, 9400)
软件要求
- Ubuntu 20.04/22.04或CentOS 7/8
- Docker和Docker Compose
- NVIDIA驱动已安装
- Janus-Pro-7B已部署并运行
验证NVIDIA驱动
# 检查驱动版本
nvidia-smi
# 输出示例
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 535.154.05 Driver Version: 535.154.05 CUDA Version: 12.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... On | 00000000:01:00.0 Off | N/A |
| 30% 45C P0 120W / 350W| 14456MiB / 24576MiB| 78% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
4.2 安装Docker和Docker Compose
如果还没有安装Docker,可以按以下步骤安装:
Ubuntu系统
# 更新包列表
sudo apt-get update
# 安装依赖
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
# 添加Docker官方GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# 添加Docker仓库
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 安装Docker
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# 安装Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# 验证安装
docker --version
docker-compose --version
CentOS系统
# 卸载旧版本
sudo yum remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 安装依赖
sudo yum install -y yum-utils
# 添加Docker仓库
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 安装Docker
sudo yum install -y docker-ce docker-ce-cli containerd.io
# 启动Docker
sudo systemctl start docker
sudo systemctl enable docker
# 安装Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# 验证安装
docker --version
docker-compose --version
4.3 创建监控目录结构
为监控系统创建专门的目录:
# 创建主目录
mkdir -p ~/janus-monitoring
cd ~/janus-monitoring
# 创建子目录
mkdir -p prometheus/data
mkdir -p grafana/data
mkdir -p grafana/provisioning/datasources
mkdir -p grafana/provisioning/dashboards
# 设置权限
sudo chown -R 472:472 grafana/data
sudo chown -R 65534:65534 prometheus/data
5. 部署监控组件
5.1 部署NVIDIA DCGM Exporter
DCGM Exporter是监控GPU的关键组件,它会在9400端口暴露GPU指标。
创建docker-compose.yml文件
version: '3.8'
services:
# NVIDIA DCGM Exporter - GPU指标收集
dcgm-exporter:
image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.4-3.1.5-ubuntu22.04
container_name: dcgm-exporter
restart: unless-stopped
privileged: true
network_mode: host
volumes:
- /run/prometheus:/run/prometheus
command:
- "-f"
- "/etc/dcgm-exporter/dcp-metrics-included.csv"
environment:
- DCGM_EXPORTER_INTERVAL=2000 # 采集间隔2秒
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
启动DCGM Exporter
# 进入监控目录
cd ~/janus-monitoring
# 启动服务
docker-compose up -d dcgm-exporter
# 检查服务状态
docker ps | grep dcgm-exporter
# 测试指标是否正常
curl http://localhost:9400/metrics | head -20
验证指标 访问 http://你的服务器IP:9400/metrics,应该能看到类似这样的输出:
# HELP DCGM_FI_DEV_GPU_TEMP GPU temperature (in C).
# TYPE DCGM_FI_DEV_GPU_TEMP gauge
DCGM_FI_DEV_GPU_TEMP{gpu="0",UUID="GPU-xxxx"} 45
# HELP DCGM_FI_DEV_MEM_COPY_UTIL Memory utilization (in %).
# TYPE DCGM_FI_DEV_MEM_COPY_UTIL gauge
DCGM_FI_DEV_MEM_COPY_UTIL{gpu="0",UUID="GPU-xxxx"} 78
5.2 部署Prometheus
Prometheus负责定期从DCGM Exporter拉取数据并存储。
创建Prometheus配置文件
cd ~/janus-monitoring
nano prometheus/prometheus.yml
prometheus.yml内容
global:
scrape_interval: 15s # 每15秒采集一次
evaluation_interval: 15s # 每15秒评估规则
# 告警规则配置
rule_files:
- "alert.rules.yml"
# 数据采集配置
scrape_configs:
# 监控Prometheus自身
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
scrape_interval: 15s
# 监控GPU指标
- job_name: 'nvidia-gpu'
static_configs:
- targets: ['localhost:9400']
scrape_interval: 5s # GPU指标采集更频繁
metrics_path: /metrics
# 监控Janus-Pro-7B服务(需要Node Exporter)
- job_name: 'janus-service'
static_configs:
- targets: ['localhost:9100'] # Node Exporter端口
scrape_interval: 15s
创建告警规则文件
nano prometheus/alert.rules.yml
alert.rules.yml内容
groups:
- name: gpu_alerts
rules:
# GPU温度过高告警
- alert: GPUTemperatureHigh
expr: DCGM_FI_DEV_GPU_TEMP > 85
for: 2m
labels:
severity: warning
annotations:
summary: "GPU温度过高"
description: "GPU {{ $labels.gpu }} 温度达到 {{ $value }}°C"
# 显存使用率过高告警
- alert: GPUMemoryUsageHigh
expr: (DCGM_FI_DEV_FB_USED / DCGM_FI_DEV_FB_FREE) * 100 > 90
for: 2m
labels:
severity: warning
annotations:
summary: "GPU显存使用率过高"
description: "GPU {{ $labels.gpu }} 显存使用率达到 {{ $value }}%"
# GPU利用率持续为0告警(可能服务异常)
- alert: GPUUtilizationZero
expr: avg_over_time(DCGM_FI_DEV_GPU_UTIL[5m]) == 0
for: 5m
labels:
severity: info
annotations:
summary: "GPU利用率持续为0"
description: "GPU {{ $labels.gpu }} 在过去5分钟内利用率为0,可能服务异常"
更新docker-compose.yml添加Prometheus
version: '3.8'
services:
# NVIDIA DCGM Exporter - GPU指标收集
dcgm-exporter:
image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.4-3.1.5-ubuntu22.04
container_name: dcgm-exporter
restart: unless-stopped
privileged: true
network_mode: host
volumes:
- /run/prometheus:/run/prometheus
command:
- "-f"
- "/etc/dcgm-exporter/dcp-metrics-included.csv"
environment:
- DCGM_EXPORTER_INTERVAL=2000
# Prometheus - 监控数据存储
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/alert.rules.yml:/etc/prometheus/alert.rules.yml
- ./prometheus/data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=30d' # 保留30天数据
- '--web.enable-lifecycle'
depends_on:
- dcgm-exporter
启动Prometheus
# 启动Prometheus
docker-compose up -d prometheus
# 检查服务状态
docker ps | grep prometheus
# 访问Prometheus Web界面
# 浏览器打开:http://你的服务器IP:9090
验证Prometheus 在Prometheus Web界面中:
- 点击顶部菜单"Status" → "Targets"
- 应该看到
nvidia-gpu和prometheus两个target都是"UP"状态 - 点击"Graph"标签,输入
DCGM_FI_DEV_GPU_TEMP,点击"Execute"应该能看到数据
5.3 部署Grafana
Grafana提供漂亮的可视化界面,让我们能够直观地查看监控数据。
创建Grafana数据源配置
cd ~/janus-monitoring
nano grafana/provisioning/datasources/prometheus.yml
prometheus.yml内容
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true
创建Grafana仪表板配置
nano grafana/provisioning/dashboards/dashboards.yml
dashboards.yml内容
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards
更新docker-compose.yml添加Grafana
version: '3.8'
services:
# NVIDIA DCGM Exporter - GPU指标收集
dcgm-exporter:
image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.4-3.1.5-ubuntu22.04
container_name: dcgm-exporter
restart: unless-stopped
privileged: true
network_mode: host
volumes:
- /run/prometheus:/run/prometheus
command:
- "-f"
- "/etc/dcgm-exporter/dcp-metrics-included.csv"
environment:
- DCGM_EXPORTER_INTERVAL=2000
# Prometheus - 监控数据存储
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/alert.rules.yml:/etc/prometheus/alert.rules.yml
- ./prometheus/data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=30d'
- '--web.enable-lifecycle'
depends_on:
- dcgm-exporter
# Grafana - 数据可视化
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: unless-stopped
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin123 # 初始密码,请修改!
- GF_INSTALL_PLUGINS=grafana-piechart-panel
volumes:
- ./grafana/data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
depends_on:
- prometheus
启动Grafana
# 启动所有服务
docker-compose up -d
# 检查所有服务状态
docker-compose ps
# 访问Grafana
# 浏览器打开:http://你的服务器IP:3000
# 用户名:admin
# 密码:admin123(请及时修改!)
6. 配置Grafana监控面板
6.1 初始设置
第一次登录Grafana后,需要完成一些基本配置:
修改管理员密码
- 登录后点击左下角"Admin" → "Profile"
- 点击"Change Password"
- 输入新密码并保存
添加数据源
- 点击左侧菜单"Configuration"(齿轮图标)→ "Data Sources"
- 点击"Add data source"
- 选择"Prometheus"
- 在URL中输入:
http://prometheus:9090 - 点击"Save & Test",应该显示"Data source is working"
6.2 创建GPU监控面板
现在我们来创建一个专门监控Janus-Pro-7B GPU使用情况的仪表板。
创建新仪表板
- 点击左侧"+"图标 → "Dashboard"
- 点击"Add new panel"
添加GPU温度图表
- 在"Query"标签中,选择数据源为"Prometheus"
- 输入查询语句:
DCGM_FI_DEV_GPU_TEMP - 在右侧"Panel"设置中:
- 标题改为"GPU温度"
- 单位选择"Temperature → Celsius (°C)"
- 设置阈值:绿色(<70)、黄色(70-85)、红色(>85)
- 点击"Apply"
添加GPU利用率图表
- 点击仪表板右上角"Add panel"
- 查询语句:
DCGM_FI_DEV_GPU_UTIL - 设置:
- 标题:"GPU利用率"
- 单位:"Percent (0-100)"
- 显示为:"Gauge"(仪表盘)
- 点击"Apply"
添加显存使用图表
- 添加新面板
- 查询语句:
DCGM_FI_DEV_FB_USED / 1024 / 1024(转换为MB) - 设置:
- 标题:"显存使用量"
- 单位:"Data → megabytes(MiB)"
- 添加第二个查询:
DCGM_FI_DEV_FB_FREE / 1024 / 1024(空闲显存) - 显示为:"Stat"(统计值)
- 点击"Apply"
添加功耗图表
- 添加新面板
- 查询语句:
DCGM_FI_DEV_POWER_USAGE - 设置:
- 标题:"GPU功耗"
- 单位:"Power → watt(W)"
- 点击"Apply"
6.3 创建Janus服务监控面板
除了GPU指标,我们还需要监控Janus-Pro-7B服务本身。
添加服务状态面板
- 添加新面板
- 查询语句(需要Node Exporter,后面会安装):
up{job="janus-service"} - 设置:
- 标题:"Janus服务状态"
- 显示为:"Stat"
- 值映射:1 → "运行中",0 → "已停止"
- 点击"Apply"
添加请求处理时间面板
- 添加新面板
- 查询语句(需要自定义指标,后面会讲):
rate(janus_request_duration_seconds_sum[5m]) / rate(janus_request_duration_seconds_count[5m]) - 设置:
- 标题:"平均请求处理时间"
- 单位:"Time → seconds(s)"
- 点击"Apply"
6.4 安装Node Exporter监控系统指标
为了监控系统资源,我们需要安装Node Exporter。
更新docker-compose.yml
version: '3.8'
services:
# ... 之前的服务配置保持不变 ...
# Node Exporter - 系统指标收集
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
ports:
- "9100:9100"
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
更新Prometheus配置 修改prometheus/prometheus.yml,在scrape_configs部分添加:
# 监控系统指标
- job_name: 'node-exporter'
static_configs:
- targets: ['node-exporter:9100']
scrape_interval: 15s
重启服务
# 更新配置
docker-compose up -d
# 验证Node Exporter
curl http://localhost:9100/metrics | head -10
6.5 创建完整的监控仪表板
现在我们可以创建一个完整的Janus-Pro-7B监控仪表板。以下是完整的JSON配置,你可以直接导入:
创建dashboard.json文件
cd ~/janus-monitoring
nano grafana/janus-gpu-dashboard.json
将以下内容粘贴到文件中(这是一个完整的Grafana仪表板配置):
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"links": [],
"panels": [
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "celsius"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "DCGM_FI_DEV_GPU_TEMP",
"instant": false,
"legendFormat": "GPU {{gpu}}",
"range": true,
"refId": "A"
}
],
"title": "GPU温度",
"type": "gauge"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "yellow",
"value": 70
},
{
"color": "red",
"value": 90
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 3,
"options": {
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "DCGM_FI_DEV_GPU_UTIL",
"instant": false,
"legendFormat": "GPU {{gpu}}",
"range": true,
"refId": "A"
}
],
"title": "GPU利用率",
"type": "gauge"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 8
},
"id": 4,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "DCGM_FI_DEV_FB_USED",
"hide": false,
"legendFormat": "已使用",
"range": true,
"refId": "A"
},
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "DCGM_FI_DEV_FB_FREE",
"hide": false,
"legendFormat": "空闲",
"range": true,
"refId": "B"
}
],
"title": "GPU显存使用情况",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"0": {
"color": "red",
"index": 0,
"text": "停止"
},
"1": {
"color": "green",
"index": 1,
"text": "运行中"
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
},
"unit": "short"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 8,
"x": 0,
"y": 16
},
"id": 5,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "value"
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "up{job=\"janus-service\"}",
"instant": true,
"legendFormat": "服务状态",
"range": false,
"refId": "A"
}
],
"title": "Janus服务状态",
"type": "stat"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "watt"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 20
},
"id": 6,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "DCGM_FI_DEV_POWER_USAGE",
"hide": false,
"legendFormat": "GPU功耗",
"range": true,
"refId": "A"
}
],
"title": "GPU功耗",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 20
},
"id": 7,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "100 * (1 - avg(rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) by (instance))",
"hide": false,
"legendFormat": "CPU使用率",
"range": true,
"refId": "A"
}
],
"title": "CPU使用率",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 28
},
"id": 8,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "node_memory_MemTotal_bytes - node_memory_MemFree_bytes - node_memory_Buffers_bytes - node_memory_Cached_bytes",
"hide": false,
"legendFormat": "已使用内存",
"range": true,
"refId": "A"
},
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes",
"hide": false,
"legendFormat": "可用内存",
"range": true,
"refId": "B"
}
],
"title": "系统内存使用",
"type": "timeseries"
},
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 28
},
"id": 9,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "9.5.3",
"targets": [
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "node_filesystem_size_bytes{fstype!=\"tmpfs\"} - node_filesystem_free_bytes{fstype!=\"tmpfs\"}",
"hide": false,
"legendFormat": "已使用磁盘",
"range": true,
"refId": "A"
},
{
"datasource": "Prometheus",
"editorMode": "code",
"expr": "node_filesystem_free_bytes{fstype!=\"tmpfs\"}",
"hide": false,
"legendFormat": "可用磁盘",
"range": true,
"refId": "B"
}
],
"title": "磁盘使用情况",
"type": "timeseries"
}
],
"refresh": "10s",
"schemaVersion": 38,
"style": "dark",
"tags": [
"janus",
"gpu",
"monitoring"
],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Janus-Pro-7B GPU监控面板",
"uid": "janus-gpu-monitoring",
"version": 1,
"weekStart": ""
}
导入仪表板到Grafana
- 在Grafana中,点击左侧"+"图标 → "Import"
- 点击"Upload JSON file"
- 选择刚才创建的
janus-gpu-dashboard.json文件 - 点击"Load"
- 选择Prometheus数据源
- 点击"Import"
现在你应该能看到一个完整的监控面板,包含:
- GPU温度实时显示
- GPU利用率仪表盘
- 显存使用情况图表
- 服务状态指示器
- GPU功耗监控
- CPU使用率
- 系统内存使用
- 磁盘使用情况
7. 监控Janus-Pro-7B自定义指标
7.1 为什么需要自定义指标?
虽然DCGM Exporter提供了GPU硬件指标,但我们还需要监控Janus-Pro-7B服务本身的业务指标,比如:
- 请求处理时间
- 请求成功率
- 并发请求数
- 图片生成时间
- 错误类型统计
7.2 添加Prometheus客户端到Janus服务
我们需要修改Janus-Pro-7B的代码,添加Prometheus指标暴露。这里以Python服务为例:
安装Prometheus客户端库
# 在Janus服务环境中安装
pip install prometheus-client
创建指标收集脚本
# metrics_exporter.py
from prometheus_client import start_http_server, Counter, Histogram, Gauge
import time
import threading
import requests
import json
from datetime import datetime
# 定义指标
REQUEST_COUNT = Counter('janus_requests_total', 'Total number of requests')
REQUEST_DURATION = Histogram('janus_request_duration_seconds', 'Request duration in seconds')
ACTIVE_REQUESTS = Gauge('janus_active_requests', 'Number of active requests')
ERROR_COUNT = Counter('janus_errors_total', 'Total number of errors', ['error_type'])
GPU_MEMORY_USAGE = Gauge('janus_gpu_memory_usage_bytes', 'GPU memory usage in bytes')
IMAGE_GENERATION_TIME = Histogram('janus_image_generation_seconds', 'Image generation time in seconds')
class JanusMetricsExporter:
def __init__(self, port=8000):
self.port = port
self.running = False
def start(self):
"""启动指标导出服务器"""
start_http_server(self.port)
self.running = True
print(f"Metrics exporter started on port {self.port}")
# 启动后台线程收集GPU指标
thread = threading.Thread(target=self._collect_gpu_metrics)
thread.daemon = True
thread.start()
def _collect_gpu_metrics(self):
"""定期收集GPU指标"""
import pynvml
pynvml.nvmlInit()
while self.running:
try:
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
memory_info = pynvml.nvmlDeviceGetMemoryInfo(handle)
GPU_MEMORY_USAGE.set(memory_info.used)
except Exception as e:
print(f"Error collecting GPU metrics: {e}")
time.sleep(5) # 每5秒收集一次
def record_request(self, endpoint, duration):
"""记录请求指标"""
REQUEST_COUNT.inc()
REQUEST_DURATION.observe(duration)
def record_error(self, error_type):
"""记录错误指标"""
ERROR_COUNT.labels(error_type=error_type).inc()
def record_image_generation(self, duration):
"""记录图片生成时间"""
IMAGE_GENERATION_TIME.observe(duration)
def increment_active_requests(self):
"""增加活跃请求计数"""
ACTIVE_REQUESTS.inc()
def decrement_active_requests(self):
"""减少活跃请求计数"""
ACTIVE_REQUESTS.dec()
# 创建全局指标导出器实例
metrics_exporter = JanusMetricsExporter(port=8000)
# 装饰器函数,用于包装Janus服务函数
def monitor_request(func):
"""监控请求的装饰器"""
def wrapper(*args, **kwargs):
metrics_exporter.increment_active_requests()
start_time = time.time()
try:
result = func(*args, **kwargs)
duration = time.time() - start_time
metrics_exporter.record_request(func.__name__, duration)
return result
except Exception as e:
error_type = type(e).__name__
metrics_exporter.record_error(error_type)
raise
finally:
metrics_exporter.decrement_active_requests()
return wrapper
# 在Janus服务启动时启动指标导出器
def start_metrics_exporter():
metrics_exporter.start()
集成到Janus服务中 在你的Janus服务主文件中添加:
# 导入指标导出器
from metrics_exporter import monitor_request, start_metrics_exporter, metrics_exporter
# 启动指标导出器(在服务启动时调用)
start_metrics_exporter()
# 使用装饰器监控关键函数
@monitor_request
def generate_image(prompt, cfg_scale=5, temperature=1.0, seed=12345):
"""生成图片的函数"""
# 原有的生成逻辑
start_time = time.time()
# ... 图片生成代码 ...
duration = time.time() - start_time
metrics_exporter.record_image_generation(duration)
return result
@monitor_request
def answer_question(image, question, temperature=0.1, top_p=0.95, seed=42):
"""回答图片问题的函数"""
# 原有的问答逻辑
return result
7.3 更新Prometheus配置
修改prometheus/prometheus.yml,添加Janus服务指标采集:
scrape_configs:
# ... 之前的配置保持不变 ...
# 监控Janus服务业务指标
- job_name: 'janus-metrics'
static_configs:
- targets: ['你的服务器IP:8000'] # Janus指标导出端口
scrape_interval: 10s
metrics_path: /metrics
7.4 重启服务并验证
# 重启所有服务
cd ~/janus-monitoring
docker-compose down
docker-compose up -d
# 验证Janus指标
curl http://localhost:8000/metrics
# 验证Prometheus是否采集到新指标
# 访问 http://你的服务器IP:9090
# 在Graph页面输入 janus_ 应该能看到相关指标
8. 配置告警通知
8.1 配置Alertmanager
Alertmanager负责处理Prometheus的告警并发送通知。
创建Alertmanager配置
cd ~/janus-monitoring
mkdir -p alertmanager
nano alertmanager/alertmanager.yml
alertmanager.yml内容
global:
smtp_smarthost: 'smtp.gmail.com:587' # 修改为你的SMTP服务器
smtp_from: 'your-email@gmail.com' # 发件人邮箱
smtp_auth_username: 'your-email@gmail.com'
smtp_auth_password: 'your-app-password' # 应用专用密码
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'email-notifications'
receivers:
- name: 'email-notifications'
email_configs:
- to: 'admin@your-company.com' # 收件人邮箱
send_resolved: true
更新docker-compose.yml添加Alertmanager
version: '3.8'
services:
# ... 之前的服务配置保持不变 ...
# Alertmanager - 告警管理
alertmanager:
image: prom/alertmanager:latest
container_name: alertmanager
restart: unless-stopped
ports:
- "9093:9093"
volumes:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./alertmanager/data:/alertmanager
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
depends_on:
- prometheus
更新Prometheus配置支持告警 修改prometheus/prometheus.yml:
# 在文件开头添加
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager:9093
# 原有的rule_files配置保持不变
rule_files:
- "alert.rules.yml"
8.2 创建更详细的告警规则
更新prometheus/alert.rules.yml,添加更多告警规则:
groups:
- name: gpu_alerts
rules:
# GPU温度过高告警
- alert: GPUTemperatureHigh
expr: DCGM_FI_DEV_GPU_TEMP > 85
for: 2m
labels:
severity: warning
annotations:
summary: "GPU温度过高"
description: "GPU {{ $labels.gpu }} 温度达到 {{ $value }}°C,建议检查散热系统"
# 显存使用率过高告警
- alert: GPUMemoryUsageHigh
expr: (DCGM_FI_DEV_FB_USED / DCGM_FI_DEV_FB_FREE) * 100 > 90
for: 2m
labels:
severity: warning
annotations:
summary: "GPU显存使用率过高"
description: "GPU {{ $labels.gpu }} 显存使用率达到 {{ $value }}%,可能影响性能"
# GPU利用率持续为0告警
- alert: GPUUtilizationZero
expr: avg_over_time(DCGM_FI_DEV_GPU_UTIL[5m]) == 0
for: 5m
labels:
severity: info
annotations:
summary: "GPU利用率持续为0"
description: "GPU {{ $labels.gpu }} 在过去5分钟内利用率为0,可能服务异常"
- name: service_alerts
rules:
# Janus服务宕机告警
- alert: JanusServiceDown
expr: up{job="janus-service"} == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Janus服务已停止"
description: "Janus-Pro-7B服务已停止运行,请立即检查"
# 请求错误率过高告警
- alert: HighErrorRate
expr: rate(janus_errors_total[5m]) / rate(janus_requests_total[5m]) > 0.1
for: 2m
labels:
severity: warning
annotations:
summary: "请求错误率过高"
description: "Janus服务错误率达到 {{ $value | humanizePercentage }}"
# 图片生成时间过长告警
- alert: SlowImageGeneration
expr: histogram_quantile(0.95, rate(janus_image_generation_seconds_bucket[5m])) > 120
for: 5m
labels:
severity: warning
annotations:
summary: "图片生成时间过长"
description: "95%的图片生成时间超过120秒,当前为 {{ $value }} 秒"
- name: system_alerts
rules:
# 内存使用率过高告警
- alert: HighMemoryUsage
expr: (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100 > 90
for: 5m
labels:
severity: warning
annotations:
summary: "系统内存使用率过高"
description: "内存使用率达到 {{ $value }}%,可能影响服务性能"
# 磁盘空间不足告警
- alert: LowDiskSpace
expr: (node_filesystem_free_bytes{fstype!="tmpfs"} / node_filesystem_size_bytes{fstype!="tmpfs"}) * 100 < 10
for: 5m
labels:
severity: warning
annotations:
summary: "磁盘空间不足"
description: "磁盘 {{ $labels.mountpoint }} 剩余空间仅 {{ $value }}%"
8.3 重启服务应用告警配置
# 重启所有服务
cd ~/janus-monitoring
docker-compose down
docker-compose up -d
# 验证告警规则
# 访问 http://你的服务器IP:9090/alerts
# 应该能看到配置的告警规则
9. 监控面板使用技巧
9.1 日常监控查看
快速概览 每天早上打开监控面板,快速查看:
- 服务状态:确保Janus服务正常运行
- GPU温度:检查是否在安全范围内(<85°C)
- 显存使用:确认有足够空间处理请求
- 错误率:检查是否有异常错误
历史趋势分析 点击图表右上角的时间选择器,可以查看:
- 最近1小时:实时监控
- 最近24小时:日趋势
- 最近7天:周趋势
- 自定义时间范围:特定时间段分析
9.2 故障排查流程
当收到告警或发现异常时,按以下步骤排查:
步骤1:确认问题
- 查看告警详情
- 检查相关指标图表
- 确认问题发生时间
步骤2:分析原因
- GPU温度高:检查散热、环境温度、负载情况
- 显存不足:检查当前任务、重启服务释放显存
- 服务宕机:查看日志、检查资源占用
- 性能下降:分析请求模式、检查系统负载
步骤3:采取行动
- 临时措施:重启服务、调整参数
- 长期优化:硬件升级、代码优化、架构调整
9.3 性能优化建议
基于监控数据,可以做出以下优化决策:
显存优化
- 如果显存经常接近满载:考虑减少批量大小、优化模型
- 如果显存使用波动大:检查是否有内存泄漏
温度控制
- 如果温度持续偏高:改善散热、降低环境温度
- 如果温度偶尔飙升:检查是否有异常任务
性能调优
- 如果请求处理时间变长:检查系统负载、优化代码
- 如果错误率升高:检查输入数据、更新模型
10. 高级监控功能
10.1 自定义监控面板
除了基本的GPU监控,你还可以创建更专业的监控面板:
请求分析面板
- 请求量趋势图
- 平均响应时间
- 错误类型分布
- 用户地域分布(如果有的话)
业务指标面板
- 图片生成成功率
- 平均生成时间
- 热门提示词统计
- 用户满意度指标
成本监控面板
- GPU使用成本估算
- 电力消耗监控
- 资源利用率分析
10.2 自动化报告
创建日报 使用Grafana的Reporting功能,每天自动发送监控报告到邮箱:
- 在Grafana中,进入要报告的仪表板
- 点击"Share" → "Report"
- 配置收件人、发送时间、频率
- 选择报告格式(PDF/PNG)
周报/月报分析 定期分析监控数据,生成趋势报告:
- 性能变化趋势
- 资源使用情况
- 异常事件汇总
- 优化建议
10.3 集成到现有系统
API集成 Grafana提供API,可以集成到你的管理系统中:
import requests
import json
# 获取面板数据
def get_dashboard_data(panel_id, from_time, to_time):
url = "http://你的grafana地址:3000/api/datasources/proxy/1/api/v1/query_range"
params = {
"query": "DCGM_FI_DEV_GPU_TEMP",
"start": from_time,
"end": to_time,
"step": "60s" # 60秒间隔
}
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, params=params, headers=headers)
return response.json()
# 创建自定义告警
def create_custom_alert(alert_name, condition, duration):
alert_config = {
"name": alert_name,
"condition": condition,
"for": duration,
"annotations": {
"summary": f"{alert_name}告警",
"description": f"条件: {condition}"
}
}
# 调用Prometheus API创建告警规则
# 具体实现取决于你的告警系统
Webhook集成 将告警发送到你的聊天工具(如Slack、钉钉、企业微信):
# 在alertmanager.yml中添加webhook接收器
receivers:
- name: 'webhook-notifications'
webhook_configs:
- url: 'https://你的webhook地址'
send_resolved: true
11. 常见问题与解决方案
11.1 监控系统常见问题
问题1:Prometheus无法采集GPU指标
症状:在Prometheus的Targets页面,nvidia-gpu状态为DOWN
解决:
1. 检查DCGM Exporter是否运行:docker ps | grep dcgm
2. 检查端口9400是否可访问:curl http://localhost:9400/metrics
3. 检查Prometheus配置中的target地址是否正确
问题2:Grafana显示"No Data"
症状:图表显示"No data points"
解决:
1. 检查数据源连接:Grafana → Configuration → Data Sources → Test
2. 检查时间范围:确保选择的时间范围内有数据
3. 检查查询语句:在Explore页面测试查询语句
4. 检查指标名称:确认指标名称拼写正确
问题3:告警不触发
症状:条件满足但告警未触发
解决:
1. 检查告警规则语法:在Prometheus的Rules页面检查
2. 检查for持续时间:条件需要持续满足指定时间
3. 检查Alertmanager配置:确认接收器配置正确
4. 检查网络连接:Prometheus能否访问Alertmanager
11.2 性能优化建议
监控系统资源占用 监控系统本身也会消耗资源,建议:
- 调整采集频率:非关键指标可以降低频率
- 调整数据保留时间:根据需求设置合适的保留时间
- 使用数据降采样:长期数据可以降低精度
磁盘空间管理 监控数据会占用磁盘空间,建议:
- 设置数据保留策略:Prometheus默认保留15天
- 定期清理旧数据:使用Prometheus的API或工具
- 监控磁盘使用:设置磁盘空间告警
11.3 安全考虑
访问控制
- 修改默认密码:Grafana的admin密码
- 限制访问IP:使用防火墙限制访问端口
- 使用HTTPS:生产环境建议启用HTTPS
数据安全
- 定期备份:备份Prometheus和Grafana数据
- 权限控制:为不同用户设置不同权限
- 审计日志:开启访问日志记录
12. 总结
12.1 监控系统价值回顾
通过为Janus-Pro-7B部署这套完整的监控系统,你现在拥有了:
实时可视化监控
- GPU温度、利用率、显存使用一目了然
- 服务状态、请求指标实时更新
- 历史数据随时可查
智能告警通知
- 异常情况及时通知
- 多级告警策略
- 多种通知方式
数据驱动决策
- 基于数据的性能优化
- 容量规划依据
- 故障快速定位
12.2 后续优化方向
监控深度扩展
- 添加业务指标监控(用户行为、模型效果)
- 集成日志监控(ELK Stack)
- 添加链路追踪(Jaeger)
监控广度扩展
- 多节点监控(如果有多台服务器)
- 容器化监控(如果使用Docker/K8s)
- 网络监控(带宽、延迟)
智能化升级
- 异常检测(自动发现异常模式)
- 预测分析(基于历史数据预测)
- 自动优化(基于监控数据自动调整)
12.3 开始使用建议
如果你是第一次搭建监控系统,建议:
第一步:基础监控
- 按照本文部署基础监控
- 熟悉各个监控面板
- 设置基本告警
第二步:业务监控
- 添加Janus服务自定义指标
- 创建业务监控面板
- 设置业务告警规则
第三步:优化完善
- 根据实际使用调整监控项
- 优化告警策略
- 建立监控运维流程
12.4 资源清理与维护
定期维护任务
# 1. 检查服务状态
docker-compose ps
# 2. 查看日志
docker-compose logs --tail=100
# 3. 清理旧数据(保留最近30天)
# Prometheus会自动清理,也可以手动执行
docker exec prometheus promtool tsdb clean --retention.time=30d
# 4. 备份配置
cp -r ~/janus-monitoring ~/janus-monitoring-backup-$(date +%Y%m%d)
# 5. 更新镜像
docker-compose pull
docker-compose up -d
监控系统本身也需要监控 别忘了为监控系统本身也设置监控:
- Prometheus存储空间
- Grafana服务状态
- 网络连通性
获取更多AI镜像
想探索更多AI镜像和应用场景?访问 CSDN星图镜像广场,提供丰富的预置镜像,覆盖大模型推理、图像生成、视频生成、模型微调等多个领域,支持一键部署。
更多推荐




所有评论(0)