参考原文:佛西博客 - Pve使用外部监控Grafana+Prometheus (buduanwang.vip)

一、安装

  1. 创建用户
groupadd --system prometheus
useradd -s /sbin/nologin --system -g prometheus prometheus
mkdir /etc/prometheus/
  1. 安装Node - exporter

    apt install python python-pip
    pip install prometheus-pve-exporter
  2. 创建配置文件

vi /etc/prometheus/pve.yml
  1. 编写用户配置:nodeExporter依赖PVE权限验证,查看自己默认User配置为

default:
user: root@pam
password: your_password_here
verify_ssl: false
  1. 设置一下权限
chown -R prometheus:prometheus /etc/prometheus/
chmod -R 775 /etc/prometheus/
  1. 创建systemed

    tee /etc/systemd/system/prometheus-pve-exporter.service<<EOF
    [Unit]
    Description=Prometheus exporter for Proxmox VE
    Documentation=https://github.com/znerol/prometheus-pve-exporter

    [Service]
    Restart=always
    User=prometheus
    ExecStart=/usr/local/bin/pve_exporter /etc/prometheus/pve.yml

    [Install]
    WantedBy=multi-user.target
    EOF
  2. 设置开机启动

systemctl daemon-reload
systemctl start prometheus-pve-exporter
systemctl enable prometheus-pve-exporter

二、验证

访问:192.168.0.5:9221/pve

三、配置Prometheus配置文件

进入自己的Prometheus主机:vim /opt/sofeware/prometheus/prometheus.yml
添加:

scrape_configs:
- job_name: 'proxmox'
metrics_path: /pve
static_configs:
- targets: ['192.168.0.5:9221']

重启Prometheus:systemctl restart prometheus.service

四、配置Grafana

导入模板:10347 -> Proxmox via Prometheus | Grafana Labs