PVE安装Node-exporter监控Prometheus

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

一、安装

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

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

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

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    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. 设置开机启动

1
2
3
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
添加:

1
2
3
4
5
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