适用环境:
Proxmox VE(7.x / 8.x / 9.x)
单节点(非集群)
Grafana & Prometheus 直接安装在 PVE 宿主机
Node Exporter 采集 PVE 本机指标
一、基础环境确认
PVE 已正常安装
能通过浏览器访问:
https://PVE_IP:8006
能进入 PVE Shell(网页或 SSH)
系统时间正确(非常重要):
timedatectl
二、安装 Node Exporter(采集系统指标)
Node Exporter 用于采集:
CPU / 内存 / 磁盘 / 网络 / 温度等
进入 PVE Shell
下载并安装:
apt update
apt install -y prometheus-node-exporter
启动并设置开机自启:
systemctl enable node-exporter
systemctl start node-exporter
确认端口:
ss -lntp | grep 9100
正常应看到:
LISTEN *:9100 node_exporter
浏览器测试:
http://PVE_IP:9100/metrics
三、安装 Prometheus(指标存储)
安装 Prometheus:
apt install -y prometheus
编辑配置文件:
nano /etc/prometheus/prometheus.yml
确认包含如下内容:
scrape_configs:
job_name: ‘pve’
static_configs:
targets: [‘localhost:9100’]
重启 Prometheus:
systemctl restart prometheus
systemctl enable prometheus
确认端口:
ss -lntp | grep 9090
浏览器访问:
http://PVE_IP:9090
四、安装 Grafana(可视化界面)
添加 Grafana 官方源:
apt install -y apt-transport-https software-properties-common wget
wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key
echo “deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main”
/etc/apt/sources.list.d/grafana.list
安装 Grafana:
apt update
apt install -y grafana
启动 Grafana:
systemctl daemon-reload
systemctl enable grafana-server
systemctl start grafana-server
确认端口:
ss -lntp | grep 3000
五、Grafana 初始配置
浏览器访问:
http://PVE_IP:3000
默认账号:
用户名:admin
密码:admin
(首次登录会要求修改密码)
六、Grafana 添加 Prometheus 数据源
左侧菜单 → Connections → Data sources
Add data source
选择 Prometheus
URL 填写:
http://localhost:9090
点击:
Save & Test
出现绿色 Successfully 即成功
七、导入 Node Exporter 仪表盘
左侧菜单 → Dashboards → Dashboards
New → Import
在 Dashboard ID 输入:
1860
点击 Load
数据源选择 prometheus
点击 Import
仪表盘名称:
Node Exporter Full
八、CPU 温度监控(可选增强)
进入 Node Exporter Full → Edit
添加新面板(Add panel)
PromQL 示例:
max by (instance) (
node_hwmon_temp_celsius{chip=”platform_coretemp_0″}
)
Visualization 选择 Gauge
单位:°C
设置阈值:
80:红色
90:深红
九、常用 PromQL 公式备忘
CPU 使用率:
100 – (avg by(instance)(
rate(node_cpu_seconds_total{mode=”idle”}[5m])
) * 100)
内存使用率:
(node_memory_MemTotal_bytes – node_memory_MemAvailable_bytes)
/ node_memory_MemTotal_bytes * 100
磁盘使用率(根分区):
(node_filesystem_size_bytes{mountpoint=”/”}
node_filesystem_free_bytes{mountpoint=”/”})
/ node_filesystem_size_bytes{mountpoint=”/”} * 100
十、Grafana 常见误区说明
Dashboards ≠ Playlists
仪表盘在:Dashboards → Dashboards
Playlists 是轮播用的
Grafana 重启后仪表盘不会丢
只有删除数据库才会丢
十一、服务管理命令速查
Grafana:
systemctl restart grafana-server
systemctl status grafana-server
Prometheus:
systemctl restart prometheus
systemctl status prometheus
Node Exporter:
systemctl restart node-exporter
systemctl status node-exporter
十二、最终状态检查清单
✔ 9100 可访问(node exporter)
✔ 9090 可访问(prometheus)
✔ 3000 可访问(grafana)
✔ Grafana 中 Prometheus 测试成功
✔ Node Exporter Full 有数据